diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc5e4f592..0d2f3f1ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ jobs: name: NetBSD Build, Check, and Test runs-on: ubuntu-latest env: - PKGSRC_BRANCH: 2025Q2 + PKGSRC_BRANCH: 2025Q4 steps: - uses: actions/checkout@v4 - name: Build, Check, and Test @@ -156,18 +156,14 @@ jobs: - name: Check benchmarks run: ./odin check tests/benchmark -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -no-entry-point + - name: Odin check examples/all for Linux i386 if: matrix.os == 'ubuntu-latest' run: ./odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:linux_i386 - - name: Odin check examples/all for Linux arm64 - if: matrix.os == 'ubuntu-latest' - run: ./odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:linux_arm64 - - name: Odin check examples/all for FreeBSD amd64 - if: matrix.os == 'ubuntu-latest' - run: ./odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freebsd_amd64 - name: Odin check examples/all for OpenBSD amd64 if: matrix.os == 'ubuntu-latest' run: ./odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:openbsd_amd64 + - name: Odin check examples/all for js_wasm32 if: matrix.os == 'ubuntu-latest' run: ./odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -no-entry-point -target:js_wasm32 @@ -178,12 +174,6 @@ jobs: - name: Odin check examples/all/sdl3 for Linux i386 if: matrix.os == 'ubuntu-latest' run: ./odin check examples/all/sdl3 -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -no-entry-point -target:linux_i386 - - name: Odin check examples/all/sdl3 for Linux arm64 - if: matrix.os == 'ubuntu-latest' - run: ./odin check examples/all/sdl3 -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -no-entry-point -target:linux_arm64 - - name: Odin check examples/all/sdl3 for FreeBSD amd64 - if: matrix.os == 'ubuntu-latest' - run: ./odin check examples/all/sdl3 -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -no-entry-point -target:freebsd_amd64 - name: Odin check examples/all/sdl3 for OpenBSD amd64 if: matrix.os == 'ubuntu-latest' run: ./odin check examples/all/sdl3 -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -no-entry-point -target:openbsd_amd64 diff --git a/base/runtime/core.odin b/base/runtime/core.odin index 58a0b8ad1..5a0b3766c 100644 --- a/base/runtime/core.odin +++ b/base/runtime/core.odin @@ -122,6 +122,7 @@ Type_Info_Struct_Flag :: enum u8 { raw_union = 1, all_or_none = 2, align = 3, + simple = 4, } Type_Info_Struct :: struct { diff --git a/base/runtime/core_builtin.odin b/base/runtime/core_builtin.odin index 6fecbaad9..02278a356 100644 --- a/base/runtime/core_builtin.odin +++ b/base/runtime/core_builtin.odin @@ -360,7 +360,7 @@ new_aligned :: proc($T: typeid, alignment: int, allocator := context.allocator, @(builtin, require_results) new_clone :: proc(data: $T, allocator := context.allocator, loc := #caller_location) -> (t: ^T, err: Allocator_Error) #optional_allocator_error { - t = (^T)(raw_data(mem_alloc_bytes(size_of(T), align_of(T), allocator, loc) or_return)) + t = (^T)(raw_data(mem_alloc_non_zeroed(size_of(T), align_of(T), allocator, loc) or_return)) if t != nil { t^ = data } @@ -433,7 +433,6 @@ _make_dynamic_array_len_cap :: proc(array: ^Raw_Dynamic_Array, size_of_elem, ali array.data = raw_data(data) array.len = 0 if use_zero else len array.cap = 0 if use_zero else cap - array.allocator = allocator return } diff --git a/base/runtime/error_checks.odin b/base/runtime/error_checks.odin index 32a895c3f..46a8f9b1d 100644 --- a/base/runtime/error_checks.odin +++ b/base/runtime/error_checks.odin @@ -12,7 +12,7 @@ bounds_trap :: proc "contextless" () -> ! { } @(no_instrumentation) -type_assertion_trap :: proc "contextless" () -> ! { +type_assertion_trap_contextless :: proc "contextless" () -> ! { when ODIN_OS == .Windows { windows_trap_type_assertion() } else when ODIN_OS == .Orca { @@ -137,20 +137,22 @@ matrix_bounds_check_error :: proc "contextless" (file: string, line, column: i32 when ODIN_NO_RTTI { - type_assertion_check :: proc "contextless" (ok: bool, file: string, line, column: i32) { + type_assertion_check_with_context :: proc "odin" (ok: bool, file: string, line, column: i32) { if ok { return } @(cold, no_instrumentation) - handle_error :: proc "contextless" (file: string, line, column: i32) -> ! { - print_caller_location(Source_Code_Location{file, line, column, ""}) - print_string(" Invalid type assertion\n") - type_assertion_trap() + handle_error :: proc "odin" (file: string, line, column: i32) -> ! { + p := context.assertion_failure_proc + if p == nil { + p = default_assertion_failure_proc + } + p("type assertion", "Invalid type assertion", Source_Code_Location{file, line, column, ""}) } handle_error(file, line, column) } - type_assertion_check2 :: proc "contextless" (ok: bool, file: string, line, column: i32) { + type_assertion_check_contextless :: proc "contextless" (ok: bool, file: string, line, column: i32) { if ok { return } @@ -158,12 +160,71 @@ when ODIN_NO_RTTI { handle_error :: proc "contextless" (file: string, line, column: i32) -> ! { print_caller_location(Source_Code_Location{file, line, column, ""}) print_string(" Invalid type assertion\n") - type_assertion_trap() + type_assertion_trap_contextless() + } + handle_error(file, line, column) + } + + type_assertion_check2_with_context :: proc "odin" (ok: bool, file: string, line, column: i32) { + if ok { + return + } + @(cold, no_instrumentation) + handle_error :: proc "odin" (file: string, line, column: i32) -> ! { + p := context.assertion_failure_proc + if p == nil { + p = default_assertion_failure_proc + } + p("type assertion", "Invalid type assertion", Source_Code_Location{file, line, column, ""}) + } + + handle_error(file, line, column) + } + + type_assertion_check2_contextless :: proc "contextless" (ok: bool, file: string, line, column: i32) { + if ok { + return + } + @(cold, no_instrumentation) + handle_error :: proc "contextless" (file: string, line, column: i32) -> ! { + print_caller_location(Source_Code_Location{file, line, column, ""}) + print_string(" Invalid type assertion\n") + type_assertion_trap_contextless() } handle_error(file, line, column) } } else { - type_assertion_check :: proc "contextless" (ok: bool, file: string, line, column: i32, from, to: typeid) { + @(private="file") + TYPE_ASSERTION_BUFFER_SIZE :: 1024 + + type_assertion_check_with_context :: proc "odin" (ok: bool, file: string, line, column: i32, from, to: typeid) { + if ok { + return + } + @(cold, no_instrumentation) + handle_error :: proc "odin" (file: string, line, column: i32, from, to: typeid) -> ! { + do_msg :: proc "contextless" (i: ^int, buf: []byte, file: string, line, column: i32, from, to: typeid) -> bool { + write_string(i, buf, "Invalid type assertion from ") or_return + write_typeid(i, buf, from) or_return + write_string(i, buf, " to ") or_return + write_typeid(i, buf, to) or_return + return true + } + + buf: [TYPE_ASSERTION_BUFFER_SIZE]byte + i := 0 + _ = do_msg(&i, buf[:], file, line, column, from, to) + + p := context.assertion_failure_proc + if p == nil { + p = default_assertion_failure_proc + } + p("type assertion", string(buf[:i]), Source_Code_Location{file, line, column, ""}) + } + handle_error(file, line, column, from, to) + } + + type_assertion_check_contextless :: proc "contextless" (ok: bool, file: string, line, column: i32, from, to: typeid) { if ok { return } @@ -175,47 +236,90 @@ when ODIN_NO_RTTI { print_string(" to ") print_typeid(to) print_byte('\n') - type_assertion_trap() + type_assertion_trap_contextless() } handle_error(file, line, column, from, to) } - type_assertion_check2 :: proc "contextless" (ok: bool, file: string, line, column: i32, from, to: typeid, from_data: rawptr) { + @(private="file") + type_assertion_variant_type :: proc "contextless" (id: typeid, data: rawptr) -> typeid { + if id == nil || data == nil { + return id + } + ti := type_info_base(type_info_of(id)) + #partial switch v in ti.variant { + case Type_Info_Any: + return (^any)(data).id + case Type_Info_Union: + if v.tag_type == nil { + if (^rawptr)(data)^ == nil { + return nil + } + return v.variants[0].id + + } + + tag_ptr := uintptr(data) + v.tag_offset + idx := 0 + switch v.tag_type.size { + case 1: idx = int( (^u8)(tag_ptr)^); if !v.no_nil { idx -= 1 } + case 2: idx = int( (^u16)(tag_ptr)^); if !v.no_nil { idx -= 1 } + case 4: idx = int( (^u32)(tag_ptr)^); if !v.no_nil { idx -= 1 } + case 8: idx = int( (^u64)(tag_ptr)^); if !v.no_nil { idx -= 1 } + case 16: idx = int((^u128)(tag_ptr)^); if !v.no_nil { idx -= 1 } + } + if idx < 0 { + return nil + } else if idx < len(v.variants) { + return v.variants[idx].id + } + } + return id + } + + type_assertion_check2_with_context :: proc "odin" (ok: bool, file: string, line, column: i32, from, to: typeid, from_data: rawptr) { if ok { return } - variant_type :: proc "contextless" (id: typeid, data: rawptr) -> typeid { - if id == nil || data == nil { - return id - } - ti := type_info_base(type_info_of(id)) - #partial switch v in ti.variant { - case Type_Info_Any: - return (^any)(data).id - case Type_Info_Union: - tag_ptr := uintptr(data) + v.tag_offset - idx := 0 - switch v.tag_type.size { - case 1: idx = int((^u8)(tag_ptr)^) - 1 - case 2: idx = int((^u16)(tag_ptr)^) - 1 - case 4: idx = int((^u32)(tag_ptr)^) - 1 - case 8: idx = int((^u64)(tag_ptr)^) - 1 - case 16: idx = int((^u128)(tag_ptr)^) - 1 - } - if idx < 0 { - return nil - } else if idx < len(v.variants) { - return v.variants[idx].id + @(cold, no_instrumentation) + handle_error :: proc "odin" (file: string, line, column: i32, from, to: typeid, from_data: rawptr) -> ! { + do_msg :: proc "contextless" (i: ^int, buf: []byte, file: string, line, column: i32, from, to, actual: typeid) -> bool { + write_string(i, buf, "Invalid type assertion from ") or_return + write_typeid(i, buf, from) or_return + write_string(i, buf, " to ") or_return + write_typeid(i, buf, to) or_return + if actual != from { + write_string(i, buf, ", actual type: ") or_return + write_typeid(i, buf, actual) or_return } + return true } - return id + + actual := type_assertion_variant_type(from, from_data) + + buf: [TYPE_ASSERTION_BUFFER_SIZE]byte + i := 0 + _ = do_msg(&i, buf[:], file, line, column, from, to, actual) + + p := context.assertion_failure_proc + if p == nil { + p = default_assertion_failure_proc + } + p("type assertion", string(buf[:i]), Source_Code_Location{file, line, column, ""}) + } + handle_error(file, line, column, from, to, from_data) + } + + type_assertion_check2_contextless :: proc "contextless" (ok: bool, file: string, line, column: i32, from, to: typeid, from_data: rawptr) { + if ok { + return } @(cold, no_instrumentation) handle_error :: proc "contextless" (file: string, line, column: i32, from, to: typeid, from_data: rawptr) -> ! { - actual := variant_type(from, from_data) + actual := type_assertion_variant_type(from, from_data) print_caller_location(Source_Code_Location{file, line, column, ""}) print_string(" Invalid type assertion from ") @@ -227,7 +331,7 @@ when ODIN_NO_RTTI { print_typeid(actual) } print_byte('\n') - type_assertion_trap() + type_assertion_trap_contextless() } handle_error(file, line, column, from, to, from_data) } diff --git a/base/runtime/print.odin b/base/runtime/print.odin index 4ef142037..2cdde8152 100644 --- a/base/runtime/print.odin +++ b/base/runtime/print.odin @@ -280,11 +280,22 @@ print_type :: #force_no_inline proc "contextless" (ti: ^Type_Info) { print_byte('i' if info.signed else 'u') print_u64(u64(8*ti.size)) } + switch info.endianness { + case .Platform: // nothing + case .Little: print_string("le") + case .Big: print_string("be") + } + case Type_Info_Rune: print_string("rune") case Type_Info_Float: print_byte('f') print_u64(u64(8*ti.size)) + switch info.endianness { + case .Platform: // nothing + case .Little: print_string("le") + case .Big: print_string("be") + } case Type_Info_Complex: print_string("complex") print_u64(u64(8*ti.size)) @@ -410,6 +421,7 @@ print_type :: #force_no_inline proc "contextless" (ti: ^Type_Info) { if .packed in info.flags { print_string("#packed ") } if .raw_union in info.flags { print_string("#raw_union ") } if .all_or_none in info.flags { print_string("#all_or_none ") } + if .simple in info.flags { print_string("#simple ") } if .align in info.flags { print_string("#align(") print_u64(u64(ti.align)) @@ -494,6 +506,9 @@ print_type :: #force_no_inline proc "contextless" (ti: ^Type_Info) { print_type(info.elem) case Type_Info_Matrix: + if info.layout == .Row_Major { + print_string("#row_major ") + } print_string("matrix[") print_u64(u64(info.row_count)) print_string(", ") @@ -502,3 +517,419 @@ print_type :: #force_no_inline proc "contextless" (ti: ^Type_Info) { print_type(info.elem) } } + + +@(require_results) +write_string :: proc "contextless" (i: ^int, dst: []byte, src: string) -> bool { + if i^ < len(dst) { + i^ += copy(dst[i^:], src) + return true + } + return false +} + + +@(require_results) +write_byte :: proc "contextless" (i: ^int, dst: []byte, src: byte) -> bool { + if i^ < len(dst) { + dst[i^] = src + i^ += 1 + return true + } + return false +} + + +@(require_results) +write_u64 :: proc "contextless" (j: ^int, dst: []byte, x: u64) -> bool { + if j^ < len(dst) { + b :: u64(10) + u := x + + a: [129]byte + i := len(a) + for u >= b { + i -= 1; a[i] = _INTEGER_DIGITS_VAR[u % b] + u /= b + } + i -= 1; a[i] = _INTEGER_DIGITS_VAR[u % b] + + return write_string(j, dst, string(a[i:])) + } + return false +} + +@(require_results) +write_i64 :: proc "contextless" (j: ^int, dst: []byte, x: i64) -> bool { + if j^ < len(dst) { + b :: u64(10) + u := u64(abs(x)) + neg := x < 0 + + a: [129]byte + i := len(a) + for u >= b { + i -= 1; a[i] = _INTEGER_DIGITS_VAR[u % b] + u /= b + } + i -= 1; a[i] = _INTEGER_DIGITS_VAR[u % b] + if neg { + i -= 1; a[i] = '-' + } + + return write_string(j, dst, string(a[i:])) + } + return false +} + + +@(require_results) +write_caller_location :: #force_no_inline proc "contextless" (i: ^int, buf: []byte, loc: Source_Code_Location) -> bool { + write_string(i, buf, loc.file_path) or_return + + when ODIN_ERROR_POS_STYLE == .Default { + write_byte(i, buf, '(') or_return + write_u64 (i, buf, u64(loc.line)) or_return + if loc.column != 0 { + write_byte(i, buf, ':') or_return + write_u64 (i, buf, u64(loc.column)) or_return + } + write_byte(i, buf, ')') or_return + return true + } else when ODIN_ERROR_POS_STYLE == .Unix { + write_byte(i, buf, ':') or_return + write_u64 (i, buf, u64(loc.line)) or_return + if loc.column != 0 { + write_byte(i, buf, ':') or_return + write_u64 (i, buf, u64(loc.column)) or_return + } + write_byte(i, buf, ':') or_return + return true + } else { + #panic("unhandled ODIN_ERROR_POS_STYLE") + } +} + +@(require_results) +write_typeid :: #force_no_inline proc "contextless" (i: ^int, buf: []byte, id: typeid) -> bool { + when ODIN_NO_RTTI { + if id == nil { + write_string(i, buf, "nil") or_return + } else { + write_string(i, buf, "") or_return + } + } else { + if id == nil { + write_string(i, buf, "nil") or_return + } else { + ti := type_info_of(id) + write_write_type(i, buf, ti) or_return + } + } + return true +} + + +@(require_results) +write_rune :: #force_no_inline proc "contextless" (i: ^int, buf: []byte, r: rune) -> (written: int, ok: bool) #no_bounds_check { + RUNE_SELF :: 0x80 + + if r < RUNE_SELF { + write_byte(i, buf,byte(r)) or_return + return 1, true + } + + b, n := encode_rune(r) + prev := i^ + write_string(i, buf, string(b[:n])) or_return + return i^ - prev, true +} + +@(require_results) +write_encoded_rune :: #force_no_inline proc "contextless" (i: ^int, buf: []byte, r: rune) -> bool { + write_byte(i, buf, '\'') or_return + + switch r { + case '\a': write_string(i, buf, "\\a") or_return + case '\b': write_string(i, buf, "\\b") or_return + case '\e': write_string(i, buf, "\\e") or_return + case '\f': write_string(i, buf, "\\f") or_return + case '\n': write_string(i, buf, "\\n") or_return + case '\r': write_string(i, buf, "\\r") or_return + case '\t': write_string(i, buf, "\\t") or_return + case '\v': write_string(i, buf, "\\v") or_return + case: + if r <= 0 { + write_string(i, buf, "\\x00") or_return + } else if r < 32 { + n0, n1 := u8(r) >> 4, u8(r) & 0xf + write_string(i, buf, "\\x") or_return + write_byte (i, buf, _INTEGER_DIGITS_VAR[n0]) or_return + write_byte (i, buf, _INTEGER_DIGITS_VAR[n1]) or_return + } else { + _ = write_rune(i, buf, r) or_return + } + } + + write_byte(i, buf, '\'') or_return + return true +} + +@(optimization_mode="favor_size") +write_write_type :: #force_no_inline proc "contextless" (i: ^int, buf: []byte, ti: ^Type_Info) -> bool { + if ti == nil { + write_string(i, buf, "nil") or_return + return true + } + + switch info in ti.variant { + case Type_Info_Named: + write_string(i, buf, info.name) or_return + case Type_Info_Integer: + switch ti.id { + case int: write_string(i, buf, "int") or_return + case uint: write_string(i, buf, "uint") or_return + case uintptr: write_string(i, buf, "uintptr") or_return + case: + write_byte(i, buf, 'i' if info.signed else 'u') or_return + write_u64 (i, buf, u64(8*ti.size)) or_return + } + switch info.endianness { + case .Platform: // nothing + case .Little: write_string(i, buf, "le") or_return + case .Big: write_string(i, buf, "be") or_return + } + + case Type_Info_Rune: + write_string(i, buf, "rune") or_return + case Type_Info_Float: + write_byte(i, buf, 'f') or_return + write_u64(i, buf, u64(8*ti.size)) or_return + switch info.endianness { + case .Platform: // nothing + case .Little: write_string(i, buf, "le") or_return + case .Big: write_string(i, buf, "be") or_return + } + + case Type_Info_Complex: + write_string(i, buf, "complex") or_return + write_u64 (i, buf, u64(8*ti.size)) or_return + case Type_Info_Quaternion: + write_string(i, buf, "quaternion") or_return + write_u64 (i, buf, u64(8*ti.size)) or_return + case Type_Info_String: + if info.is_cstring { + write_byte(i, buf, 'c') or_return + } + write_string(i, buf, "string") or_return + switch info.encoding { + case .UTF_8: /**/ + case .UTF_16: write_string(i, buf, "16") or_return + } + case Type_Info_Boolean: + switch ti.id { + case bool: write_string(i, buf, "bool") or_return + case: + write_byte(i, buf, 'b') or_return + write_u64 (i, buf, u64(8*ti.size)) or_return + } + case Type_Info_Any: + write_string(i, buf, "any") or_return + case Type_Info_Type_Id: + write_string(i, buf, "typeid") or_return + + case Type_Info_Pointer: + if info.elem == nil { + write_string(i, buf, "rawptr") or_return + } else { + write_string (i, buf, "^") or_return + write_write_type(i, buf, info.elem) or_return + } + case Type_Info_Multi_Pointer: + write_string (i, buf, "[^]") or_return + write_write_type(i, buf, info.elem) or_return + case Type_Info_Soa_Pointer: + write_string (i, buf, "#soa ^") or_return + write_write_type(i, buf, info.elem) or_return + case Type_Info_Procedure: + write_string(i, buf, "proc") or_return + if info.params == nil { + write_string(i, buf, "()") or_return + } else { + t := info.params.variant.(Type_Info_Parameters) + write_byte(i, buf, '(') or_return + for t, j in t.types { + if j > 0 { write_string(i, buf, ", ") or_return } + write_write_type(i, buf, t) or_return + } + write_string(i, buf, ")") or_return + } + if info.results != nil { + write_string (i, buf, " -> ") or_return + write_write_type(i, buf, info.results) or_return + } + case Type_Info_Parameters: + count := len(info.names) + if count != 1 { write_byte(i, buf, '(') or_return } + for name, j in info.names { + if j > 0 { write_string(i, buf, ", ") or_return } + + t := info.types[j] + + if len(name) > 0 { + write_string(i, buf, name) or_return + write_string(i, buf, ": ") or_return + } + write_write_type(i, buf, t) or_return + } + if count != 1 { write_string(i, buf, ")") or_return } + + case Type_Info_Array: + write_byte (i, buf, '[') or_return + write_u64 (i, buf, u64(info.count)) or_return + write_byte (i, buf, ']') or_return + write_write_type(i, buf, info.elem) or_return + + case Type_Info_Enumerated_Array: + if info.is_sparse { + write_string(i, buf, "#sparse") or_return + } + write_byte (i, buf, '[') or_return + write_write_type(i, buf, info.index) or_return + write_byte (i, buf, ']') or_return + write_write_type(i, buf, info.elem) or_return + + + case Type_Info_Dynamic_Array: + write_string (i, buf, "[dynamic]") or_return + write_write_type(i, buf, info.elem) or_return + case Type_Info_Slice: + write_string (i, buf, "[]") or_return + write_write_type(i, buf, info.elem) or_return + + case Type_Info_Map: + write_string (i, buf, "map[") or_return + write_write_type(i, buf, info.key) or_return + write_byte (i, buf, ']') or_return + write_write_type(i, buf, info.value) or_return + + case Type_Info_Struct: + switch info.soa_kind { + case .None: // Ignore + case .Fixed: + write_string (i, buf, "#soa[") or_return + write_u64 (i, buf, u64(info.soa_len)) or_return + write_byte (i, buf, ']') or_return + write_write_type(i, buf, info.soa_base_type) or_return + return true + case .Slice: + write_string (i, buf, "#soa[]") or_return + write_write_type(i, buf, info.soa_base_type) or_return + return true + case .Dynamic: + write_string (i, buf, "#soa[dynamic]") or_return + write_write_type(i, buf, info.soa_base_type) or_return + return true + } + + write_string(i, buf, "struct ") or_return + if .packed in info.flags { write_string(i, buf, "#packed ") or_return } + if .raw_union in info.flags { write_string(i, buf, "#raw_union ") or_return } + if .all_or_none in info.flags { write_string(i, buf, "#all_or_none ") or_return } + if .simple in info.flags { write_string(i, buf, "#simple ") or_return } + if .align in info.flags { + write_string(i, buf, "#align(") or_return + write_u64(i, buf, u64(ti.align)) or_return + write_string(i, buf, ") ") or_return + } + write_byte(i, buf, '{') or_return + for name, j in info.names[:info.field_count] { + if j > 0 { write_string(i, buf, ", ") or_return } + write_string (i, buf, name) or_return + write_string (i, buf, ": ") or_return + write_write_type(i, buf, info.types[j]) or_return + } + write_byte(i, buf, '}') or_return + + case Type_Info_Union: + write_string(i, buf, "union ") or_return + if info.custom_align { + write_string(i, buf, "#align(") or_return + write_u64 (i, buf, u64(ti.align)) or_return + write_string(i, buf, ") ") or_return + } + if info.no_nil { + write_string(i, buf, "#no_nil ") or_return + } + write_byte(i, buf, '{') or_return + for variant, j in info.variants { + if j > 0 { write_string(i, buf, ", ") or_return } + write_write_type(i, buf, variant) or_return + } + write_string(i, buf, "}") or_return + + case Type_Info_Enum: + write_string (i, buf, "enum ") or_return + write_write_type(i, buf, info.base) or_return + write_string (i, buf, " {") or_return + for name, j in info.names { + if j > 0 { write_string(i, buf, ", ") or_return } + write_string(i, buf, name) or_return + } + write_string(i, buf, "}") or_return + + case Type_Info_Bit_Set: + write_string(i, buf, "bit_set[") or_return + + #partial switch elem in type_info_base(info.elem).variant { + case Type_Info_Enum: + write_write_type(i, buf, info.elem) or_return + case Type_Info_Rune: + write_encoded_rune(i, buf, rune(info.lower)) or_return + write_string (i, buf, "..") or_return + write_encoded_rune(i, buf, rune(info.upper)) or_return + case: + write_i64 (i, buf, info.lower) or_return + write_string(i, buf, "..") or_return + write_i64 (i, buf, info.upper) or_return + } + if info.underlying != nil { + write_string (i, buf, "; ") or_return + write_write_type(i, buf, info.underlying) or_return + } + write_byte(i, buf, ']') or_return + + case Type_Info_Bit_Field: + write_string (i, buf, "bit_field ") or_return + write_write_type(i, buf, info.backing_type) or_return + write_string (i, buf, " {") or_return + for name, j in info.names[:info.field_count] { + if j > 0 { write_string(i, buf, ", ") or_return } + write_string (i, buf, name) or_return + write_string (i, buf, ": ") or_return + write_write_type(i, buf, info.types[j]) or_return + write_string (i, buf, " | ") or_return + write_u64 (i, buf, u64(info.bit_sizes[j])) or_return + } + write_byte(i, buf, '}') or_return + + + case Type_Info_Simd_Vector: + write_string (i, buf, "#simd[") or_return + write_u64 (i, buf, u64(info.count)) or_return + write_byte (i, buf, ']') or_return + write_write_type(i, buf, info.elem) or_return + + case Type_Info_Matrix: + if info.layout == .Row_Major { + write_string(i, buf, "#row_major ") or_return + } + write_string (i, buf, "matrix[") or_return + write_u64 (i, buf, u64(info.row_count)) or_return + write_string (i, buf, ", ") or_return + write_u64 (i, buf, u64(info.column_count)) or_return + write_string (i, buf, "]") or_return + write_write_type(i, buf, info.elem) or_return + } + return true +} \ No newline at end of file diff --git a/core/container/handle_map/doc.odin b/core/container/handle_map/doc.odin new file mode 100644 index 000000000..c1949ffdd --- /dev/null +++ b/core/container/handle_map/doc.odin @@ -0,0 +1,56 @@ +/* +Handle-based map using fixed-length arrays. + +Example: + import hm "core:container/handle_map" + + Handle :: hm.Handle32 + + Entity :: struct { + handle: Handle, + pos: [2]f32, + } + + { // static map + entities: hm.Static_Handle_Map(1024, Entity, Handle) + + h1 := hm.add(&entities, Entity{pos = {1, 4}}) + h2 := hm.add(&entities, Entity{pos = {9, 16}}) + + if e, ok := hm.get(&entities, h2); ok { + e.pos.x += 32 + } + + hm.remove(&entities, h1) + + h3 := hm.add(&entities, Entity{pos = {6, 7}}) + + it := hm.iterator_make(&entities) + for e, h in hm.iterate(&it) { + e.pos += {1, 2} + } + } + + { // dynamic map + entities: hm.Dynamic_Handle_Map(Entity, Handle) + hm.dynamic_init(&entities, context.allocator) + defer hm.dynamic_destroy(&entities) + + h1 := hm.add(&entities, Entity{pos = {1, 4}}) + h2 := hm.add(&entities, Entity{pos = {9, 16}}) + + if e, ok := hm.get(&entities, h2); ok { + e.pos.x += 32 + } + + hm.remove(&entities, h1) + + h3 := hm.add(&entities, Entity{pos = {6, 7}}) + + it := hm.iterator_make(&entities) + for e, h in hm.iterate(&it) { + e.pos += {1, 2} + } + } +*/ +package container_handle_map \ No newline at end of file diff --git a/core/container/handle_map/dynamic_handle_map.odin b/core/container/handle_map/dynamic_handle_map.odin new file mode 100644 index 000000000..067212a54 --- /dev/null +++ b/core/container/handle_map/dynamic_handle_map.odin @@ -0,0 +1,141 @@ +package container_handle_map + +import "base:runtime" +import "base:builtin" +import "base:intrinsics" +@(require) import "core:container/xar" + +Dynamic_Handle_Map :: struct($T: typeid, $Handle_Type: typeid) + where + intrinsics.type_has_field(Handle_Type, "idx"), + intrinsics.type_has_field(Handle_Type, "gen"), + intrinsics.type_is_unsigned(intrinsics.type_field_type(Handle_Type, "idx")), + intrinsics.type_is_unsigned(intrinsics.type_field_type(Handle_Type, "gen")), + intrinsics.type_field_type(Handle_Type, "idx") == intrinsics.type_field_type(Handle_Type, "gen"), + + intrinsics.type_has_field (T, "handle"), + intrinsics.type_field_type(T, "handle") == Handle_Type { + + items: xar.Array(T, 4), + unused_items: xar.Array(u32, 4), +} + +dynamic_init :: proc(m: ^$D/Dynamic_Handle_Map($T, $Handle_Type), allocator: runtime.Allocator) { + xar.init(&m.items, allocator) + xar.init(&m.unused_items, allocator) +} + +dynamic_destroy :: proc(m: ^$D/Dynamic_Handle_Map($T, $Handle_Type)) { + xar.destroy(&m.unused_items) + xar.destroy(&m.items) +} + +@(require_results) +dynamic_add :: proc(m: ^$D/Dynamic_Handle_Map($T, $Handle_Type), item: T, loc := #caller_location) -> (handle: Handle_Type, err: runtime.Allocator_Error) { + if xar.len(m.unused_items) > 0 { + i := xar.pop(&m.unused_items) + ptr := xar.get_ptr_unsafe(&m.items, i) + prev_gen := ptr.handle.gen + ptr^ = item + + ptr.handle.idx = auto_cast i + ptr.handle.gen = auto_cast (prev_gen + 1) + return ptr.handle, nil + } + + if xar.len(m.items) == 0 { + // initialize the zero-value sentinel + xar.append(&m.items, T{}, loc) or_return + } + + i := xar.append(&m.items, item, loc) or_return + + ptr := xar.get_ptr_unsafe(&m.items, i) + ptr^ = item + + ptr.handle.idx = auto_cast i + ptr.handle.gen = 1 + return ptr.handle, nil +} + +@(require_results) +dynamic_get :: proc "contextless" (m: ^$D/Dynamic_Handle_Map($T, $Handle_Type), h: Handle_Type) -> (^T, bool) #optional_ok { + if h.idx <= 0 || int(u32(h.idx)) >= xar.len(m.items) { + return nil, false + } + if e := xar.get_ptr_unsafe(&m.items, h.idx); e.handle == h { + return e, true + } + return nil, false +} + +dynamic_remove :: proc(m: ^$D/Dynamic_Handle_Map($T, $Handle_Type), h: Handle_Type, loc := #caller_location) -> (found: bool, err: runtime.Allocator_Error) { + if h.idx <= 0 || int(u32(h.idx)) >= xar.len(m.items) { + return false, nil + } + + if item := xar.get_ptr(&m.items, h.idx); item.handle == h { + xar.append(&m.unused_items, u32(h.idx), loc) or_return + item.handle.idx = 0 + return true, nil + } + + return false, nil +} + +@(require_results) +dynamic_is_valid :: proc "contextless" (m: ^$D/Dynamic_Handle_Map($T, $Handle_Type), h: Handle_Type) -> bool { + return h.idx > 0 && int(u32(h.idx)) < xar.len(m.items) && xar.get_ptr_unsafe(&m.items, h.idx).handle == h +} + +// Returns the number of possibly valid items in the handle map. +@(require_results) +dynamic_len :: proc "contextless" (m: $D/Dynamic_Handle_Map($T, $Handle_Type)) -> uint { + n := xar.len(m.items) - xar.len(m.unused_items) + return uint(n-1 if n > 0 else 0) +} + +@(require_results) +dynamic_cap :: proc "contextless" (m: $D/Dynamic_Handle_Map($T, $Handle_Type)) -> uint { + n := xar.cap(m.items) + return uint(n-1 if n > 0 else 0) +} + +dynamic_clear :: proc "contextless" (m: ^$D/Dynamic_Handle_Map($T, $Handle_Type)) { + xar.clear(&m.items) + xar.clear(&m.unused_items) +} + + +// An iterator for a handle map. +Dynamic_Handle_Map_Iterator :: struct($D: typeid) { + m: ^D, + index: int, +} + +// Makes an iterator from a handle map. +@(require_results) +dynamic_iterator_make :: proc "contextless" (m: ^$D/Dynamic_Handle_Map($T, $Handle_Type)) -> Dynamic_Handle_Map_Iterator(D) { + return {m, 1} +} + +/* + Iterate over a handle map. It will skip over unused item slots (e.g. handle.idx == 0). + Usage: + it := hm.dynamic_iterator_make(&the_dynamic_handle_map) + for item, handle in hm.iterate(&it) { + ... + } +*/ +@(require_results) +dynamic_iterate :: proc "contextless" (it: ^$DHI/Dynamic_Handle_Map_Iterator($D/Dynamic_Handle_Map($T, $Handle_Type))) -> (val: ^T, h: Handle_Type, ok: bool) { + for _ in it.index.. (handle: Handle_Type, ok: bool) #optional_ok { + if i := m.next_unused; i != 0 { + ptr := &m.items[i] + + m.next_unused = m.unused_items[i] + m.unused_items[i] = 0 + + prev_gen := ptr.handle.gen + ptr^ = item + + ptr.handle.idx = auto_cast i + ptr.handle.gen = auto_cast (prev_gen + 1) + m.unused_len -= 1 + return ptr.handle, true + } + + if m.used_len == 0 { + // initialize the zero-value sentinel + m.items[0] = {} + m.used_len += 1 + } + + if m.used_len == builtin.len(m.items) { + return {}, false + } + + ptr := &m.items[m.used_len] + ptr^ = item + + ptr.handle.idx = auto_cast m.used_len + ptr.handle.gen = 1 + m.used_len += 1 + return ptr.handle, true +} + +// `get` a stable pointer of type `^T` by resolving the handle `h`. If the handle is not valid, then `nil, false` is returned. +@(require_results) +static_get :: proc "contextless" (m: ^$H/Static_Handle_Map($N, $T, $Handle_Type), h: Handle_Type) -> (^T, bool) #optional_ok { + if h.idx <= 0 || u32(h.idx) >= m.used_len { + return nil, false + } + if e := &m.items[h.idx]; e.handle == h { + return e, true + } + return nil, false +} + +// `remove` an item from the handle map from the handle `h`. +static_remove :: proc "contextless" (m: ^$H/Static_Handle_Map($N, $T, $Handle_Type), h: Handle_Type) -> bool { + if h.idx <= 0 || u32(h.idx) >= m.used_len { + return false + } + + if item := &m.items[h.idx]; item.handle == h { + m.unused_items[h.idx] = m.next_unused + m.next_unused = u32(h.idx) + m.unused_len += 1 + item.handle.idx = 0 + return true + } + + return false +} + +// Returns true when the handle `h` is valid relating to the handle map. +@(require_results) +static_is_valid :: proc "contextless" (m: $H/Static_Handle_Map($N, $T, $Handle_Type), h: Handle_Type) -> bool { + return h.idx > 0 && u32(h.idx) < m.used_len && m.items[h.idx].handle == h +} + +// Returns the number of possibly valid items in the handle map. +@(require_results) +static_len :: proc "contextless" (m: $H/Static_Handle_Map($N, $T, $Handle_Type)) -> uint { + n := uint(m.used_len) - uint(m.unused_len) + return n-1 if n > 0 else 0 +} + +// Returns the capacity of the items in a handle map. +// This is equivalent to `N-1` as the zero value is reserved for the zero-value sentinel. +@(require_results) +static_cap :: proc "contextless" (m: $H/Static_Handle_Map($N, $T, $Handle_Type)) -> uint { + // We could just return `N` but I am doing this for clarity + return builtin.len(m.items)-1 +} + +// `clear` the handle map by zeroing all of the memory. +// Internally this does not do `m^ = {}` but rather uses `intrinsics.mem_zero` explicitly improve performance. +static_clear :: proc "contextless" (m: ^$H/Static_Handle_Map($N, $T, $Handle_Type)) { + intrinsics.mem_zero(m, size_of(m^)) +} + +// An iterator for a handle map. +Static_Handle_Map_Iterator :: struct($H: typeid) { + m: ^H, + index: u32, +} + +// Makes an iterator from a handle map. +@(require_results) +static_iterator_make :: proc "contextless" (m: ^$H/Static_Handle_Map($N, $T, $Handle_Type)) -> Static_Handle_Map_Iterator(H) { + return {m, 1} +} + +/* + Iterate over a handle map. It will skip over unused item slots (e.g. handle.idx == 0). + Usage: + it := hm.iterator_make(&the_handle_map) + for item, handle in hm.iterate(&it) { + ... + } +*/ +@(require_results) +static_iterate :: proc "contextless" (it: ^$HI/Static_Handle_Map_Iterator($H/Static_Handle_Map($N, $T, $Handle_Type))) -> (val: ^T, h: Handle_Type, ok: bool) { + for _ in it.index.. (err: mem.Allocator_Error) + where intrinsics.type_has_field(T, link_field), + intrinsics.type_field_type(T, link_field) == ^T { + p.link_off = offset_of_by_string(T, link_field) + return _pool_arena_init(&p.arena, block_size) +} + +destroy :: proc(p: ^Pool($T)) { + elem := sync.atomic_exchange_explicit(&p.free_list, nil, .Acquire) + + sync.atomic_store_explicit(&p.num_ready, 0, .Relaxed) + + when .Address in ODIN_SANITIZER_FLAGS { + for ; elem != nil; elem = _get_next(p, elem) { + _unpoison_elem(p, elem) + } + } else { + _ = elem + } + + _pool_arena_destroy(&p.arena) + p.arena = {} +} + +@(require_results) +get :: proc(p: ^Pool($T)) -> (elem: ^T, err: mem.Allocator_Error) #optional_allocator_error { + defer sync.atomic_add_explicit(&p.num_outstanding, 1, .Relaxed) + + for { + elem = sync.atomic_load_explicit(&p.free_list, .Acquire) + if elem == nil { + // NOTE: pool arena has an internal lock. + return new(T, _pool_arena_allocator(&p.arena)) + } + + if _, ok := sync.atomic_compare_exchange_weak_explicit(&p.free_list, elem, _get_next(p, elem), .Acquire, .Relaxed); ok { + _set_next(p, elem, nil) + _unpoison_elem(p, elem) + sync.atomic_sub_explicit(&p.num_ready, 1, .Relaxed) + return + } + } +} + +put :: proc(p: ^Pool($T), elem: ^T) { + mem.zero_item(elem) + _poison_elem(p, elem) + + defer sync.atomic_sub_explicit(&p.num_outstanding, 1, .Relaxed) + defer sync.atomic_add_explicit(&p.num_ready, 1, .Relaxed) + + for { + head := sync.atomic_load_explicit(&p.free_list, .Relaxed) + _set_next(p, elem, head) + if _, ok := sync.atomic_compare_exchange_weak_explicit(&p.free_list, head, elem, .Release, .Relaxed); ok { + return + } + } +} + +num_outstanding :: proc(p: ^Pool($T)) -> int { + return sync.atomic_load(&p.num_outstanding) +} + +num_ready :: proc(p: ^Pool($T)) -> int { + return sync.atomic_load(&p.num_ready) +} + +cap :: proc(p: ^Pool($T)) -> int { + return sync.atomic_load(&p.num_ready) + sync.atomic_load(&p.num_outstanding) +} + +_get_next :: proc(p: ^Pool($T), elem: ^T) -> ^T { + return (^^T)(uintptr(elem) + p.link_off)^ +} + +_set_next :: proc(p: ^Pool($T), elem: ^T, next: ^T) { + (^^T)(uintptr(elem) + p.link_off)^ = next +} + +@(disabled=.Address not_in ODIN_SANITIZER_FLAGS) +_poison_elem :: proc(p: ^Pool($T), elem: ^T) { + if p.link_off > 0 { + sanitizer.address_poison_rawptr(elem, int(p.link_off)) + } + + len := size_of(T) - p.link_off - size_of(rawptr) + if len > 0 { + ptr := rawptr(uintptr(elem) + p.link_off + size_of(rawptr)) + sanitizer.address_poison_rawptr(ptr, int(len)) + } +} + +@(disabled=.Address not_in ODIN_SANITIZER_FLAGS) +_unpoison_elem :: proc(p: ^Pool($T), elem: ^T) { + if p.link_off > 0 { + sanitizer.address_unpoison_rawptr(elem, int(p.link_off)) + } + + len := size_of(T) - p.link_off - size_of(rawptr) + if len > 0 { + ptr := rawptr(uintptr(elem) + p.link_off + size_of(rawptr)) + sanitizer.address_unpoison_rawptr(ptr, int(len)) + } +} diff --git a/core/container/pool/pool_arena_others.odin b/core/container/pool/pool_arena_others.odin new file mode 100644 index 000000000..3069076f7 --- /dev/null +++ b/core/container/pool/pool_arena_others.odin @@ -0,0 +1,29 @@ +#+build !darwin +#+build !freebsd +#+build !openbsd +#+build !netbsd +#+build !linux +#+build !windows +#+private +package container_pool + +import "base:runtime" + +import "core:mem" + +_Pool_Arena :: runtime.Arena + +_DEFAULT_BLOCK_SIZE :: mem.Megabyte + +_pool_arena_init :: proc(arena: ^Pool_Arena, block_size: uint = DEFAULT_BLOCK_SIZE) -> (err: runtime.Allocator_Error) { + runtime.arena_init(arena, block_size, runtime.default_allocator()) or_return + return +} + +_pool_arena_allocator :: proc(arena: ^Pool_Arena) -> runtime.Allocator { + return runtime.arena_allocator(arena) +} + +_pool_arena_destroy :: proc(arena: ^Pool_Arena) { + runtime.arena_destroy(arena) +} diff --git a/core/container/pool/pool_arena_virtual.odin b/core/container/pool/pool_arena_virtual.odin new file mode 100644 index 000000000..192e60260 --- /dev/null +++ b/core/container/pool/pool_arena_virtual.odin @@ -0,0 +1,24 @@ +#+build darwin, freebsd, openbsd, netbsd, linux, windows +package container_pool + +import "base:runtime" + +import "core:mem" +import "core:mem/virtual" + +_Pool_Arena :: virtual.Arena + +_DEFAULT_BLOCK_SIZE :: mem.Gigabyte + +_pool_arena_init :: proc(arena: ^Pool_Arena, block_size: uint = DEFAULT_BLOCK_SIZE) -> (err: runtime.Allocator_Error) { + virtual.arena_init_growing(arena, block_size) or_return + return +} + +_pool_arena_allocator :: proc(arena: ^Pool_Arena) -> runtime.Allocator { + return virtual.arena_allocator(arena) +} + +_pool_arena_destroy :: proc(arena: ^Pool_Arena) { + virtual.arena_destroy(arena) +} diff --git a/core/container/rbtree/rbtree.odin b/core/container/rbtree/rbtree.odin index 35ce21413..e892188d7 100644 --- a/core/container/rbtree/rbtree.odin +++ b/core/container/rbtree/rbtree.odin @@ -91,7 +91,7 @@ destroy :: proc(t: ^$T/Tree($Key, $Value), call_on_remove: bool = true) { } } -len :: proc "contextless" (t: ^$T/Tree($Key, $Value)) -> (node_count: int) { +len :: proc "contextless" (t: $T/Tree($Key, $Value)) -> (node_count: int) { return t._size } @@ -108,7 +108,7 @@ last :: proc "contextless" (t: ^$T/Tree($Key, $Value)) -> ^Node(Key, Value) { } // find finds the key in the tree, and returns the corresponding node, or nil iff the value is not present. -find :: proc(t: ^$T/Tree($Key, $Value), key: Key) -> (node: ^Node(Key, Value)) { +find :: proc(t: $T/Tree($Key, $Value), key: Key) -> (node: ^Node(Key, Value)) { node = t._root for node != nil { switch t._cmp_fn(key, node.key) { @@ -121,7 +121,7 @@ find :: proc(t: ^$T/Tree($Key, $Value), key: Key) -> (node: ^Node(Key, Value)) { } // find_value finds the key in the tree, and returns the corresponding value, or nil iff the value is not present. -find_value :: proc(t: ^$T/Tree($Key, $Value), key: Key) -> (value: Value, ok: bool) #optional_ok { +find_value :: proc(t: $T/Tree($Key, $Value), key: Key) -> (value: Value, ok: bool) #optional_ok { if n := find(t, key); n != nil { return n.value, true } @@ -166,7 +166,7 @@ remove :: proc { // removal was successful. While the node's key + value will be left intact, // the node itself will be freed via the tree's node allocator. remove_key :: proc(t: ^$T/Tree($Key, $Value), key: Key, call_on_remove := true) -> bool { - n := find(t, key) + n := find(t^, key) if n == nil { return false // Key not found, nothing to do } diff --git a/core/container/xar/xar.odin b/core/container/xar/xar.odin index 616a05e06..556f93ee5 100644 --- a/core/container/xar/xar.odin +++ b/core/container/xar/xar.odin @@ -12,7 +12,7 @@ import "core:container/xar" example :: proc() { - x: xar.Xar(int, 4) + x: xar.Array(int, 4) defer xar.destroy(&x) xar.push_back(&x, 10) @@ -38,7 +38,7 @@ MAX_SHIFT :: PLATFORM_BITS>>1 /* An Exponential Array with stable element addresses. - Unlike `[dynamic]T` which reallocates and moves elements when growing, `Xar` + Unlike `[dynamic]T` which reallocates and moves elements when growing, `Array` allocates separate chunks of exponentially increasing size. This guarantees that pointers to elements remain valid for the lifetime of the container. @@ -66,11 +66,11 @@ MAX_SHIFT :: PLATFORM_BITS>>1 example :: proc() { // Xar with initial chunk size of 16 (1 << 4) - x: xar.Xar(My_Struct, 4) + x: xar.Array(My_Struct, 4) defer xar.destroy(&x) } */ -Xar :: struct($T: typeid, $SHIFT: uint) where 0 < SHIFT, SHIFT <= MAX_SHIFT { +Array :: struct($T: typeid, $SHIFT: uint) where 0 < SHIFT, SHIFT <= MAX_SHIFT { chunks: [(1 << (_LOG2_PLATFORM_BITS - intrinsics.constant_log2(SHIFT))) + 1][^]T, len: int, allocator: mem.Allocator, @@ -84,7 +84,7 @@ Initializes an exponential array with the given allocator. - `x`: Pointer to the exponential array to initialize - `allocator`: Allocator to use for chunk allocations (defaults to context.allocator) */ -init :: proc(x: ^$X/Xar($T, $SHIFT), allocator := context.allocator) { +init :: proc(x: ^$X/Array($T, $SHIFT), allocator := context.allocator) { x^ = {allocator = allocator} } @@ -94,7 +94,7 @@ Frees all allocated chunks and resets the exponential array. **Inputs** - `x`: Pointer to the exponential array to destroy */ -destroy :: proc(x: ^$X/Xar($T, $SHIFT)) { +destroy :: proc(x: ^$X/Array($T, $SHIFT)) { #reverse for c, i in x.chunks { if c != nil { n := 1 << (SHIFT + uint(i if i > 0 else 1) - 1) @@ -109,19 +109,19 @@ destroy :: proc(x: ^$X/Xar($T, $SHIFT)) { Resets the array's length to zero without freeing memory. Allocated chunks are retained for reuse. */ -clear :: proc(x: ^$X/Xar($T, $SHIFT)) { +clear :: proc "contextless" (x: ^$X/Array($T, $SHIFT)) { x.len = 0 } // Returns the length of the exponential-array @(require_results) -len :: proc(x: $X/Xar($T, $SHIFT)) -> int { +len :: proc "contextless" (x: $X/Array($T, $SHIFT)) -> int { return x.len } // Returns the number of allocated elements @(require_results) -cap :: proc(x: $X/Xar($T, $SHIFT)) -> int { +cap :: proc "contextless" (x: $X/Array($T, $SHIFT)) -> int { #reverse for c, i in x.chunks { if c != nil { return 1 << (SHIFT + uint(i if i > 0 else 1)) @@ -132,7 +132,7 @@ cap :: proc(x: $X/Xar($T, $SHIFT)) -> int { // Internal: computes chunk index, element index within chunk, and chunk capacity for a given index. @(require_results) -_meta_get :: #force_inline proc($SHIFT: uint, index: uint) -> (chunk_idx, elem_idx, chunk_cap: uint) { +_meta_get :: #force_inline proc "contextless" ($SHIFT: uint, index: uint) -> (chunk_idx, elem_idx, chunk_cap: uint) { elem_idx = index chunk_cap = uint(1) << SHIFT chunk_idx = 0 @@ -161,7 +161,7 @@ Get a copy of the element at the specified index. - a copy of the element */ @(require_results) -get :: proc(x: ^$X/Xar($T, $SHIFT), #any_int index: int, loc := #caller_location) -> (val: T) #no_bounds_check { +get :: proc(x: ^$X/Array($T, $SHIFT), #any_int index: int, loc := #caller_location) -> (val: T) #no_bounds_check { runtime.bounds_check_error_loc(loc, index, x.len) chunk_idx, elem_idx, _ := _meta_get(SHIFT, uint(index)) return x.chunks[chunk_idx][elem_idx] @@ -185,7 +185,7 @@ Example: import "core:container/xar" get_ptr_example :: proc() { - x: xar.Xar(int, 4) + x: xar.Array(int, 4) defer xar.destroy(&x) xar.push_back(&x, 100) @@ -200,12 +200,19 @@ Example: } */ @(require_results) -get_ptr :: proc(x: ^$X/Xar($T, $SHIFT), #any_int index: int, loc := #caller_location) -> (val: ^T) #no_bounds_check { +get_ptr :: proc(x: ^$X/Array($T, $SHIFT), #any_int index: int, loc := #caller_location) -> (val: ^T) #no_bounds_check { runtime.bounds_check_error_loc(loc, index, x.len) chunk_idx, elem_idx, _ := _meta_get(SHIFT, uint(index)) return &x.chunks[chunk_idx][elem_idx] } +// No bounds checking +@(require_results) +get_ptr_unsafe :: proc "contextless" (x: ^$X/Array($T, $SHIFT), #any_int index: int) -> (val: ^T) #no_bounds_check { + chunk_idx, elem_idx, _ := _meta_get(SHIFT, uint(index)) + return &x.chunks[chunk_idx][elem_idx] +} + /* Set the element at the specified index to the given value. @@ -214,7 +221,7 @@ Set the element at the specified index to the given value. - `index`: Position of the element (0-indexed) - `value`: The value to set */ -set :: proc(x: ^$X/Xar($T, $SHIFT), #any_int index: int, value: T, loc := #caller_location) #no_bounds_check { +set :: proc(x: ^$X/Array($T, $SHIFT), #any_int index: int, value: T, loc := #caller_location) #no_bounds_check { runtime.bounds_check_error_loc(loc, index, x.len) chunk_idx, elem_idx, _ := _meta_get(SHIFT, uint(index)) x.chunks[chunk_idx][elem_idx] = value @@ -240,7 +247,7 @@ Example: import "core:container/xar" push_back_example :: proc() { - x: xar.Xar(string, 4) + x: xar.Array(string, 4) defer xar.destroy(&x) xar.push_back(&x, "hello") @@ -250,7 +257,7 @@ Example: fmt.println(xar.get(&x, 1)) // world } */ -push_back_elem :: proc(x: ^$X/Xar($T, $SHIFT), value: T, loc := #caller_location) -> (n: int, err: mem.Allocator_Error) { +push_back_elem :: proc(x: ^$X/Array($T, $SHIFT), value: T, loc := #caller_location) -> (n: int, err: mem.Allocator_Error) { if x.allocator.procedure == nil { // to minic `[dynamic]T` behaviour x.allocator = context.allocator @@ -277,7 +284,7 @@ Append multiple elements to the end of the exponential array. - number of elements successfully added - allocation error if chunk allocation failed (partial append possible) */ -push_back_elems :: proc(x: ^$X/Xar($T, $SHIFT), values: ..T, loc := #caller_location) -> (n: int, err: mem.Allocator_Error) { +push_back_elems :: proc(x: ^$X/Array($T, $SHIFT), values: ..T, loc := #caller_location) -> (n: int, err: mem.Allocator_Error) { for value in values { n += push_back_elem(x, value, loc) or_return } @@ -303,7 +310,7 @@ Example: import "core:container/xar" push_back_and_get_ptr_example :: proc() { - x: xar.Xar(My_Struct, 4) + x: xar.Array(My_Struct, 4) defer xar.destroy(&x) ptr := xar.push_back_elem_and_get_ptr(&x, My_Struct{}) or_else panic("alloc failed") @@ -311,7 +318,7 @@ Example: } */ @(require_results) -push_back_elem_and_get_ptr :: proc(x: ^$X/Xar($T, $SHIFT), value: T, loc := #caller_location) -> (ptr: ^T, err: mem.Allocator_Error) { +push_back_elem_and_get_ptr :: proc(x: ^$X/Array($T, $SHIFT), value: T, loc := #caller_location) -> (ptr: ^T, err: mem.Allocator_Error) { if x.allocator.procedure == nil { // to minic `[dynamic]T` behaviour x.allocator = context.allocator @@ -323,7 +330,6 @@ push_back_elem_and_get_ptr :: proc(x: ^$X/Xar($T, $SHIFT), value: T, loc := #cal } x.chunks[chunk_idx][elem_idx] = value x.len += 1 - n = 1 ptr = &x.chunks[chunk_idx][elem_idx] return } @@ -331,7 +337,7 @@ push_back_elem_and_get_ptr :: proc(x: ^$X/Xar($T, $SHIFT), value: T, loc := #cal // `pop` will remove and return the end value of an exponential array `x` and reduces the length of the array by 1. // // Note: If the exponential array has no elements (`xar.len(x) == 0`), this procedure will panic. -pop :: proc(x: ^$X/Xar($T, $SHIFT), loc := #caller_location) -> (val: T) { +pop :: proc(x: ^$X/Array($T, $SHIFT), loc := #caller_location) -> (val: T) { assert(x.len > 0, loc=loc) index := uint(x.len-1) chunk_idx, elem_idx, _ := _meta_get(SHIFT, index) @@ -342,7 +348,7 @@ pop :: proc(x: ^$X/Xar($T, $SHIFT), loc := #caller_location) -> (val: T) { // `pop_safe` trys to remove and return the end value of dynamic array `x` and reduces the length of the array by 1. // If the operation is not possible, it will return false. @(require_results) -pop_safe :: proc(x: ^$X/Xar($T, $SHIFT)) -> (val: T, ok: bool) { +pop_safe :: proc(x: ^$X/Array($T, $SHIFT)) -> (val: T, ok: bool) { if x.len == 0 { return } @@ -370,7 +376,7 @@ pop_safe :: proc(x: ^$X/Xar($T, $SHIFT)) -> (val: T, ok: bool) { import "core:encoding/xar" unordered_remove_example :: proc() { - x: xar.Xar(int, 4) + x: xar.Array(int, 4) defer xar.destroy(&x) xar.push_back(&x, 10) @@ -384,7 +390,7 @@ pop_safe :: proc(x: ^$X/Xar($T, $SHIFT)) -> (val: T, ok: bool) { fmt.println(xar.get(&x, 1)) // 20 } */ -unordered_remove :: proc(x: ^$X/Xar($T, $SHIFT), #any_int index: int, loc := #caller_location) { +unordered_remove :: proc(x: ^$X/Array($T, $SHIFT), #any_int index: int, loc := #caller_location) { runtime.bounds_check_error_loc(loc, index, x.len) n := x.len-1 if index != n { @@ -403,7 +409,7 @@ Fields: - `idx`: Current iteration index */ Iterator :: struct($T: typeid, $SHIFT: uint) { - xar: ^Xar(T, SHIFT), + xar: ^Array(T, SHIFT), idx: int, } @@ -418,10 +424,11 @@ Create an iterator for traversing the exponential array. Example: - import "lib:xar" + import "core:container/xar" + import "core:fmt" - iteration_example :: proc() { - x: xar.Xar(int, 4) + iterator_example :: proc() { + x: xar.Array(int, 4) defer xar.destroy(&x) xar.push_back(&x, 10) @@ -440,7 +447,7 @@ Output: 20 30 */ -iterator :: proc(xar: ^$X/Xar($T, $SHIFT)) -> Iterator(T, SHIFT) { +iterator :: proc(xar: ^$X/Array($T, $SHIFT)) -> Iterator(T, SHIFT) { return {xar = auto_cast xar, idx = 0} } diff --git a/core/crypto/_chacha20/ref/chacha20_ref.odin b/core/crypto/_chacha20/ref/chacha20_ref.odin index c111c1c76..c4e6bca98 100644 --- a/core/crypto/_chacha20/ref/chacha20_ref.odin +++ b/core/crypto/_chacha20/ref/chacha20_ref.odin @@ -4,133 +4,68 @@ import "core:crypto/_chacha20" import "core:encoding/endian" import "core:math/bits" +// At least with LLVM21 force_inline produces identical perf to +// manual inlining, yay. +@(private) +quarter_round :: #force_inline proc "contextless" (a, b, c, d: u32) -> (u32, u32, u32, u32) { + a, b, c, d := a, b, c, d + + a += b + d ~= a + d = bits.rotate_left32(d, 16) + + c += d + b ~= c + b = bits.rotate_left32(b, 12) + + a += b + d ~= a + d = bits.rotate_left32(d, 8) + + c += d + b ~= c + b = bits.rotate_left32(b, 7) + + return a, b, c, d +} + stream_blocks :: proc(ctx: ^_chacha20.Context, dst, src: []byte, nr_blocks: int) { // Enforce the maximum consumed keystream per IV. _chacha20.check_counter_limit(ctx, nr_blocks) dst, src := dst, src x := &ctx._s + + + // Filippo Valsorda made an observation that only one of the column + // round depends on the counter (s12), so it is worth precomputing + // and reusing across multiple blocks. As far as I know, only Go's + // chacha implementation does this. + + p1, p5, p9, p13 := quarter_round(_chacha20.SIGMA_1, x[5], x[9], x[13]) + p2, p6, p10, p14 := quarter_round(_chacha20.SIGMA_2, x[6], x[10], x[14]) + p3, p7, p11, p15 := quarter_round(_chacha20.SIGMA_3, x[7], x[11], x[15]) + for n := 0; n < nr_blocks; n = n + 1 { - x0, x1, x2, x3 := - _chacha20.SIGMA_0, _chacha20.SIGMA_1, _chacha20.SIGMA_2, _chacha20.SIGMA_3 - x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15 := - x[4], x[5], x[6], x[7], x[8], x[9], x[10], x[11], x[12], x[13], x[14], x[15] + // First column round that depends on the counter + p0, p4, p8, p12 := quarter_round(_chacha20.SIGMA_0, x[4], x[8], x[12]) - for i := _chacha20.ROUNDS; i > 0; i = i - 2 { - // Even when forcing inlining manually inlining all of - // these is decently faster. + // First diagonal round + x0, x5, x10, x15 := quarter_round(p0, p5, p10, p15) + x1, x6, x11, x12 := quarter_round(p1, p6, p11, p12) + x2, x7, x8, x13 := quarter_round(p2, p7, p8, p13) + x3, x4, x9, x14 := quarter_round(p3, p4, p9, p14) - // quarterround(x, 0, 4, 8, 12) - x0 += x4 - x12 ~= x0 - x12 = bits.rotate_left32(x12, 16) - x8 += x12 - x4 ~= x8 - x4 = bits.rotate_left32(x4, 12) - x0 += x4 - x12 ~= x0 - x12 = bits.rotate_left32(x12, 8) - x8 += x12 - x4 ~= x8 - x4 = bits.rotate_left32(x4, 7) + for i := _chacha20.ROUNDS - 2; i > 0; i = i - 2 { + x0, x4, x8, x12 = quarter_round(x0, x4, x8, x12) + x1, x5, x9, x13 = quarter_round(x1, x5, x9, x13) + x2, x6, x10, x14 = quarter_round(x2, x6, x10, x14) + x3, x7, x11, x15 = quarter_round(x3, x7, x11, x15) - // quarterround(x, 1, 5, 9, 13) - x1 += x5 - x13 ~= x1 - x13 = bits.rotate_left32(x13, 16) - x9 += x13 - x5 ~= x9 - x5 = bits.rotate_left32(x5, 12) - x1 += x5 - x13 ~= x1 - x13 = bits.rotate_left32(x13, 8) - x9 += x13 - x5 ~= x9 - x5 = bits.rotate_left32(x5, 7) - - // quarterround(x, 2, 6, 10, 14) - x2 += x6 - x14 ~= x2 - x14 = bits.rotate_left32(x14, 16) - x10 += x14 - x6 ~= x10 - x6 = bits.rotate_left32(x6, 12) - x2 += x6 - x14 ~= x2 - x14 = bits.rotate_left32(x14, 8) - x10 += x14 - x6 ~= x10 - x6 = bits.rotate_left32(x6, 7) - - // quarterround(x, 3, 7, 11, 15) - x3 += x7 - x15 ~= x3 - x15 = bits.rotate_left32(x15, 16) - x11 += x15 - x7 ~= x11 - x7 = bits.rotate_left32(x7, 12) - x3 += x7 - x15 ~= x3 - x15 = bits.rotate_left32(x15, 8) - x11 += x15 - x7 ~= x11 - x7 = bits.rotate_left32(x7, 7) - - // quarterround(x, 0, 5, 10, 15) - x0 += x5 - x15 ~= x0 - x15 = bits.rotate_left32(x15, 16) - x10 += x15 - x5 ~= x10 - x5 = bits.rotate_left32(x5, 12) - x0 += x5 - x15 ~= x0 - x15 = bits.rotate_left32(x15, 8) - x10 += x15 - x5 ~= x10 - x5 = bits.rotate_left32(x5, 7) - - // quarterround(x, 1, 6, 11, 12) - x1 += x6 - x12 ~= x1 - x12 = bits.rotate_left32(x12, 16) - x11 += x12 - x6 ~= x11 - x6 = bits.rotate_left32(x6, 12) - x1 += x6 - x12 ~= x1 - x12 = bits.rotate_left32(x12, 8) - x11 += x12 - x6 ~= x11 - x6 = bits.rotate_left32(x6, 7) - - // quarterround(x, 2, 7, 8, 13) - x2 += x7 - x13 ~= x2 - x13 = bits.rotate_left32(x13, 16) - x8 += x13 - x7 ~= x8 - x7 = bits.rotate_left32(x7, 12) - x2 += x7 - x13 ~= x2 - x13 = bits.rotate_left32(x13, 8) - x8 += x13 - x7 ~= x8 - x7 = bits.rotate_left32(x7, 7) - - // quarterround(x, 3, 4, 9, 14) - x3 += x4 - x14 ~= x3 - x14 = bits.rotate_left32(x14, 16) - x9 += x14 - x4 ~= x9 - x4 = bits.rotate_left32(x4, 12) - x3 += x4 - x14 ~= x3 - x14 = bits.rotate_left32(x14, 8) - x9 += x14 - x4 ~= x9 - x4 = bits.rotate_left32(x4, 7) + x0, x5, x10, x15 = quarter_round(x0, x5, x10, x15) + x1, x6, x11, x12 = quarter_round(x1, x6, x11, x12) + x2, x7, x8, x13 = quarter_round(x2, x7, x8, x13) + x3, x4, x9, x14 = quarter_round(x3, x4, x9, x14) } x0 += _chacha20.SIGMA_0 @@ -236,117 +171,15 @@ hchacha20 :: proc "contextless" (dst, key, iv: []byte) { x15 := endian.unchecked_get_u32le(iv[12:16]) for i := _chacha20.ROUNDS; i > 0; i = i - 2 { - // quarterround(x, 0, 4, 8, 12) - x0 += x4 - x12 ~= x0 - x12 = bits.rotate_left32(x12, 16) - x8 += x12 - x4 ~= x8 - x4 = bits.rotate_left32(x4, 12) - x0 += x4 - x12 ~= x0 - x12 = bits.rotate_left32(x12, 8) - x8 += x12 - x4 ~= x8 - x4 = bits.rotate_left32(x4, 7) + x0, x4, x8, x12 = quarter_round(x0, x4, x8, x12) + x1, x5, x9, x13 = quarter_round(x1, x5, x9, x13) + x2, x6, x10, x14 = quarter_round(x2, x6, x10, x14) + x3, x7, x11, x15 = quarter_round(x3, x7, x11, x15) - // quarterround(x, 1, 5, 9, 13) - x1 += x5 - x13 ~= x1 - x13 = bits.rotate_left32(x13, 16) - x9 += x13 - x5 ~= x9 - x5 = bits.rotate_left32(x5, 12) - x1 += x5 - x13 ~= x1 - x13 = bits.rotate_left32(x13, 8) - x9 += x13 - x5 ~= x9 - x5 = bits.rotate_left32(x5, 7) - - // quarterround(x, 2, 6, 10, 14) - x2 += x6 - x14 ~= x2 - x14 = bits.rotate_left32(x14, 16) - x10 += x14 - x6 ~= x10 - x6 = bits.rotate_left32(x6, 12) - x2 += x6 - x14 ~= x2 - x14 = bits.rotate_left32(x14, 8) - x10 += x14 - x6 ~= x10 - x6 = bits.rotate_left32(x6, 7) - - // quarterround(x, 3, 7, 11, 15) - x3 += x7 - x15 ~= x3 - x15 = bits.rotate_left32(x15, 16) - x11 += x15 - x7 ~= x11 - x7 = bits.rotate_left32(x7, 12) - x3 += x7 - x15 ~= x3 - x15 = bits.rotate_left32(x15, 8) - x11 += x15 - x7 ~= x11 - x7 = bits.rotate_left32(x7, 7) - - // quarterround(x, 0, 5, 10, 15) - x0 += x5 - x15 ~= x0 - x15 = bits.rotate_left32(x15, 16) - x10 += x15 - x5 ~= x10 - x5 = bits.rotate_left32(x5, 12) - x0 += x5 - x15 ~= x0 - x15 = bits.rotate_left32(x15, 8) - x10 += x15 - x5 ~= x10 - x5 = bits.rotate_left32(x5, 7) - - // quarterround(x, 1, 6, 11, 12) - x1 += x6 - x12 ~= x1 - x12 = bits.rotate_left32(x12, 16) - x11 += x12 - x6 ~= x11 - x6 = bits.rotate_left32(x6, 12) - x1 += x6 - x12 ~= x1 - x12 = bits.rotate_left32(x12, 8) - x11 += x12 - x6 ~= x11 - x6 = bits.rotate_left32(x6, 7) - - // quarterround(x, 2, 7, 8, 13) - x2 += x7 - x13 ~= x2 - x13 = bits.rotate_left32(x13, 16) - x8 += x13 - x7 ~= x8 - x7 = bits.rotate_left32(x7, 12) - x2 += x7 - x13 ~= x2 - x13 = bits.rotate_left32(x13, 8) - x8 += x13 - x7 ~= x8 - x7 = bits.rotate_left32(x7, 7) - - // quarterround(x, 3, 4, 9, 14) - x3 += x4 - x14 ~= x3 - x14 = bits.rotate_left32(x14, 16) - x9 += x14 - x4 ~= x9 - x4 = bits.rotate_left32(x4, 12) - x3 += x4 - x14 ~= x3 - x14 = bits.rotate_left32(x14, 8) - x9 += x14 - x4 ~= x9 - x4 = bits.rotate_left32(x4, 7) + x0, x5, x10, x15 = quarter_round(x0, x5, x10, x15) + x1, x6, x11, x12 = quarter_round(x1, x6, x11, x12) + x2, x7, x8, x13 = quarter_round(x2, x7, x8, x13) + x3, x4, x9, x14 = quarter_round(x3, x4, x9, x14) } endian.unchecked_put_u32le(dst[0:4], x0) diff --git a/core/crypto/_edwards25519/edwards25519.odin b/core/crypto/_edwards25519/edwards25519.odin index d6f01d497..12192102d 100644 --- a/core/crypto/_edwards25519/edwards25519.odin +++ b/core/crypto/_edwards25519/edwards25519.odin @@ -195,7 +195,6 @@ ge_generator :: proc "contextless" (ge: ^Group_Element) { ge_set(ge, &GE_BASEPOINT) } -@(private) Addend_Group_Element :: struct { y2_minus_x2: field.Loose_Field_Element, // t1 y2_plus_x2: field.Loose_Field_Element, // t3 @@ -203,7 +202,6 @@ Addend_Group_Element :: struct { two_times_z2: field.Loose_Field_Element, // t5 } -@(private) ge_addend_set :: proc "contextless" (ge_a: ^Addend_Group_Element, ge: ^Group_Element) { field.fe_sub(&ge_a.y2_minus_x2, &ge.y, &ge.x) field.fe_add(&ge_a.y2_plus_x2, &ge.y, &ge.x) @@ -420,6 +418,6 @@ ge_in_prime_order_subgroup_vartime :: proc "contextless" (ge: ^Group_Element) -> // that is a ~50% speedup, and a lot of added complexity for something // that is better solved by "just use ristretto255". tmp: Group_Element = --- - _ge_scalarmult(&tmp, ge, &SC_ELL, true) + ge_scalarmult_raw(&tmp, ge, &SC_ELL, true) return ge_equal(&tmp, &GE_IDENTITY) == 1 } diff --git a/core/crypto/_edwards25519/edwards25519_scalar_mul.odin b/core/crypto/_edwards25519/edwards25519_scalar_mul.odin index 757a51257..d4ffa1075 100644 --- a/core/crypto/_edwards25519/edwards25519_scalar_mul.odin +++ b/core/crypto/_edwards25519/edwards25519_scalar_mul.odin @@ -1,130 +1,24 @@ package _edwards25519 +import "core:crypto" import field "core:crypto/_fiat/field_scalar25519" -import "core:math/bits" +import subtle "core:crypto/_subtle" import "core:mem" -// GE_BASEPOINT_TABLE is 1 * G, ... 15 * G, in precomputed format. -// -// Note: When generating, the values were reduced to Tight_Field_Element -// ranges, even though that is not required. -@(private) -GE_BASEPOINT_TABLE := Multiply_Table { - { - {62697248952638, 204681361388450, 631292143396476, 338455783676468, 1213667448819585}, - {1288382639258501, 245678601348599, 269427782077623, 1462984067271730, 137412439391563}, - {301289933810280, 1259582250014073, 1422107436869536, 796239922652654, 1953934009299142}, - {2, 0, 0, 0, 0}, - }, - { - {1519297034332653, 1098796920435767, 1823476547744119, 808144629470969, 2110930855619772}, - {338005982828284, 1667856962156925, 100399270107451, 1604566703601691, 1950338038771369}, - {1920505767731247, 1443759578976892, 1659852098357048, 1484431291070208, 275018744912646}, - {763163817085987, 2195095074806923, 2167883174351839, 1868059999999762, 911071066608705}, - }, - { - {960627541894068, 1314966688943942, 1126875971034044, 2059608312958945, 605975666152586}, - {1714478358025626, 2209607666607510, 1600912834284834, 496072478982142, 481970031861896}, - {851735079403194, 1088965826757164, 141569479297499, 602804610059257, 2004026468601520}, - {197585529552380, 324719066578543, 564481854250498, 1173818332764578, 35452976395676}, - }, - { - {1152980410747203, 2196804280851952, 25745194962557, 1915167295473129, 1266299690309224}, - {809905889679060, 979732230071345, 1509972345538142, 188492426534402, 818965583123815}, - {997685409185036, 1451818320876327, 2126681166774509, 2000509606057528, 235432372486854}, - {887734189279642, 1460338685162044, 877378220074262, 102436391401299, 153369156847490}, - }, - { - {2056621900836770, 1821657694132497, 1627986892909426, 1163363868678833, 1108873376459226}, - {1187697490593623, 1066539945237335, 885654531892000, 1357534489491782, 359370291392448}, - {1509033452137525, 1305318174298508, 613642471748944, 1987256352550234, 1044283663101541}, - {220105720697037, 387661783287620, 328296827867762, 360035589590664, 795213236824054}, - }, - { - {1820794733038396, 1612235121681074, 757405923441402, 1094031020892801, 231025333128907}, - {1639067873254194, 1484176557946322, 300800382144789, 1329915446659183, 1211704578730455}, - {641900794791527, 1711751746971612, 179044712319955, 576455585963824, 1852617592509865}, - {743549047192397, 685091042550147, 1952415336873496, 1965124675654685, 513364998442917}, - }, - { - {1004557076870448, 1762911374844520, 1330807633622723, 384072910939787, 953849032243810}, - {2178275058221458, 257933183722891, 376684351537894, 2010189102001786, 1981824297484148}, - {1332915663881114, 1286540505502549, 1741691283561518, 977214932156314, 1764059494778091}, - {429702949064027, 1368332611650677, 2019867176450999, 2212258376161746, 526160996742554}, - }, - { - {2098932988258576, 2203688382075948, 2120400160059479, 1748488020948146, 1203264167282624}, - {677131386735829, 1850249298025188, 672782146532031, 2144145693078904, 2088656272813787}, - {1065622343976192, 1573853211848116, 223560413590068, 333846833073379, 27832122205830}, - {1781008836504573, 917619542051793, 544322748939913, 882577394308384, 1720521246471195}, - }, - { - {660120928379860, 2081944024858618, 1878411111349191, 424587356517195, 2111317439894005}, - {1834193977811532, 1864164086863319, 797334633289424, 150410812403062, 2085177078466389}, - {1438117271371866, 783915531014482, 388731514584658, 292113935417795, 1945855002546714}, - {1678140823166658, 679103239148744, 614102761596238, 1052962498997885, 1863983323810390}, - }, - { - {1690309392496233, 1116333140326275, 1377242323631039, 717196888780674, 82724646713353}, - {1722370213432106, 74265192976253, 264239578448472, 1714909985012994, 2216984958602173}, - {2010482366920922, 1294036471886319, 566466395005815, 1631955803657320, 1751698647538458}, - {1073230604155753, 1159087041338551, 1664057985455483, 127472702826203, 1339591128522371}, - }, - { - {478053307175577, 2179515791720985, 21146535423512, 1831683844029536, 462805561553981}, - {1945267486565588, 1298536818409655, 2214511796262989, 1904981051429012, 252904800782086}, - {268945954671210, 222740425595395, 1208025911856230, 1080418823003555, 75929831922483}, - {1884784014268948, 643868448202966, 978736549726821, 46385971089796, 1296884812292320}, - }, - { - {1861159462859103, 7077532564710, 963010365896826, 1938780006785270, 766241051941647}, - {1778966986051906, 1713995999765361, 1394565822271816, 1366699246468722, 1213407027149475}, - {1978989286560907, 2135084162045594, 1951565508865477, 671788336314416, 293123929458176}, - {902608944504080, 2167765718046481, 1285718473078022, 1222562171329269, 492109027844479}, - }, - { - {1820807832746213, 1029220580458586, 1101997555432203, 1039081975563572, 202477981158221}, - {1866134980680205, 2222325502763386, 1830284629571201, 1046966214478970, 418381946936795}, - {1783460633291322, 1719505443254998, 1810489639976220, 877049370713018, 2187801198742619}, - {197118243000763, 305493867565736, 518814410156522, 1656246186645170, 901894734874934}, - }, - { - {225454942125915, 478410476654509, 600524586037746, 643450007230715, 1018615928259319}, - {1733330584845708, 881092297970296, 507039890129464, 496397090721598, 2230888519577628}, - {690155664737246, 1010454785646677, 753170144375012, 1651277613844874, 1622648796364156}, - {1321310321891618, 1089655277873603, 235891750867089, 815878279563688, 1709264240047556}, - }, - { - {805027036551342, 1387174275567452, 1156538511461704, 1465897486692171, 1208567094120903}, - {2228417017817483, 202885584970535, 2182114782271881, 2077405042592934, 1029684358182774}, - {460447547653983, 627817697755692, 524899434670834, 1228019344939427, 740684787777653}, - {849757462467675, 447476306919899, 422618957298818, 302134659227815, 675831828440895}, - }, -} - ge_scalarmult :: proc "contextless" (ge, p: ^Group_Element, sc: ^Scalar) { tmp: field.Non_Montgomery_Domain_Field_Element field.fe_from_montgomery(&tmp, sc) - _ge_scalarmult(ge, p, &tmp) + ge_scalarmult_raw(ge, p, &tmp) mem.zero_explicit(&tmp, size_of(tmp)) } -ge_scalarmult_basepoint :: proc "contextless" (ge: ^Group_Element, sc: ^Scalar) { - // Something like the comb method from "Fast and compact elliptic-curve - // cryptography" Section 3.3, would be more performant, but more - // complex. - // - // - https://eprint.iacr.org/2012/309 - ge_scalarmult(ge, &GE_BASEPOINT, sc) -} - ge_scalarmult_vartime :: proc "contextless" (ge, p: ^Group_Element, sc: ^Scalar) { tmp: field.Non_Montgomery_Domain_Field_Element field.fe_from_montgomery(&tmp, sc) - _ge_scalarmult(ge, p, &tmp, true) + ge_scalarmult_raw(ge, p, &tmp, true) } ge_double_scalarmult_basepoint_vartime :: proc "contextless" ( @@ -147,6 +41,12 @@ ge_double_scalarmult_basepoint_vartime :: proc "contextless" ( A_tbl: Multiply_Table = --- mul_tbl_set(&A_tbl, A, &tmp_add) + when crypto.COMPACT_IMPLS == true { + G_tbl: Multiply_Table = --- + mul_tbl_set(&G_tbl, &GE_BASEPOINT, &tmp_add) + } else { + tmp_bp_addend: Basepoint_Addend_Group_Element = --- + } sc_a, sc_b: field.Non_Montgomery_Domain_Field_Element field.fe_from_montgomery(&sc_a, a) @@ -170,21 +70,28 @@ ge_double_scalarmult_basepoint_vartime :: proc "contextless" ( ge_double(&tmp, &tmp, &tmp_dbl) } mul_tbl_add(&tmp, &A_tbl, hi_a, &tmp_add, &tmp_addend, true) - mul_tbl_add(&tmp, &GE_BASEPOINT_TABLE, hi_b, &tmp_add, &tmp_addend, true) + when crypto.COMPACT_IMPLS == true { + mul_tbl_add(&tmp, &G_tbl, hi_b, &tmp_add, &tmp_addend, true) + } else { + mul_bp_tbl_add(&tmp, GE_BASEPOINT_TABLE, hi_b, &tmp_add, &tmp_bp_addend, true) + } ge_double(&tmp, &tmp, &tmp_dbl) ge_double(&tmp, &tmp, &tmp_dbl) ge_double(&tmp, &tmp, &tmp_dbl) ge_double(&tmp, &tmp, &tmp_dbl) mul_tbl_add(&tmp, &A_tbl, lo_a, &tmp_add, &tmp_addend, true) - mul_tbl_add(&tmp, &GE_BASEPOINT_TABLE, lo_b, &tmp_add, &tmp_addend, true) + when crypto.COMPACT_IMPLS == true { + mul_tbl_add(&tmp, &G_tbl, lo_b, &tmp_add, &tmp_addend, true) + } else { + mul_bp_tbl_add(&tmp, GE_BASEPOINT_TABLE, lo_b, &tmp_add, &tmp_bp_addend, true) + } } ge_set(ge, &tmp) } -@(private) -_ge_scalarmult :: proc "contextless" ( +ge_scalarmult_raw :: proc "contextless" ( ge, p: ^Group_Element, sc: ^field.Non_Montgomery_Domain_Field_Element, unsafe_is_vartime := false, @@ -281,8 +188,8 @@ mul_tbl_add :: proc "contextless" ( {2, 0, 0, 0, 0}, // z * 2 } for i := u64(1); i < 16; i = i + 1 { - _, ctrl := bits.sub_u64(0, (i ~ idx), 0) - ge_addend_conditional_assign(tmp_addend, &tbl[i - 1], int(~ctrl) & 1) + ctrl := subtle.eq(i, idx) + ge_addend_conditional_assign(tmp_addend, &tbl[i - 1], int(ctrl)) } ge_add_addend(ge, ge, tmp_addend, tmp_add) } diff --git a/core/crypto/_edwards25519/edwards25519_scalar_mul_base.odin b/core/crypto/_edwards25519/edwards25519_scalar_mul_base.odin new file mode 100644 index 000000000..6820d618e --- /dev/null +++ b/core/crypto/_edwards25519/edwards25519_scalar_mul_base.odin @@ -0,0 +1,147 @@ +package _edwards25519 + +import "core:crypto" +import field "core:crypto/_fiat/field_curve25519" +import scalar "core:crypto/_fiat/field_scalar25519" +import subtle "core:crypto/_subtle" +import "core:mem" + +ge_scalarmult_basepoint :: proc "contextless" (ge: ^Group_Element, sc: ^Scalar) { + when crypto.COMPACT_IMPLS == true { + ge_scalarmult(ge, &GE_BASEPOINT, sc) + } else { + tmp_sc: scalar.Non_Montgomery_Domain_Field_Element + scalar.fe_from_montgomery(&tmp_sc, sc) + + tmp_add: Add_Scratch = --- + tmp_addend: Basepoint_Addend_Group_Element = --- + + ge_identity(ge) + for i in 0..<32 { + limb := i / 8 + shift := uint(i & 7) * 8 + limb_byte := tmp_sc[limb] >> shift + + hi, lo := (limb_byte >> 4) & 0x0f, limb_byte & 0x0f + mul_bp_tbl_add(ge, &Gen_Multiply_Table_edwards25519_lo[i], lo, &tmp_add, &tmp_addend, false) + mul_bp_tbl_add(ge, &Gen_Multiply_Table_edwards25519_hi[i], hi, &tmp_add, &tmp_addend, false) + } + + mem.zero_explicit(&tmp_sc, size_of(tmp_sc)) + mem.zero_explicit(&tmp_add, size_of(Add_Scratch)) + mem.zero_explicit(&tmp_addend, size_of(Basepoint_Addend_Group_Element)) + } +} + +when crypto.COMPACT_IMPLS == false { + @(private="file",rodata) + TWO_TIMES_Z2 := field.Loose_Field_Element{2, 0, 0, 0, 0} + + @(private) + Basepoint_Addend_Group_Element :: struct { + y2_minus_x2: field.Loose_Field_Element, // t1 + y2_plus_x2: field.Loose_Field_Element, // t3 + k_times_t2: field.Tight_Field_Element, // t4 + } + + @(private) + Basepoint_Multiply_Table :: [15]Basepoint_Addend_Group_Element + + @(private) + ge_bp_addend_conditional_assign :: proc "contextless" (ge_a, a: ^Basepoint_Addend_Group_Element, ctrl: int) { + field.fe_cond_select(&ge_a.y2_minus_x2, &ge_a.y2_minus_x2, &a.y2_minus_x2, ctrl) + field.fe_cond_select(&ge_a.y2_plus_x2, &ge_a.y2_plus_x2, &a.y2_plus_x2, ctrl) + field.fe_cond_select(&ge_a.k_times_t2, &ge_a.k_times_t2, &a.k_times_t2, ctrl) + } + + @(private) + ge_add_bp_addend :: proc "contextless" ( + ge, a: ^Group_Element, + b: ^Basepoint_Addend_Group_Element, + scratch: ^Add_Scratch, + ) { + // https://www.hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html#addition-add-2008-hwcd-3 + // Assumptions: k=2*d, z = 1 (precomputation ftw) + // + // t0 = Y1-X1 + // t1 = Y2-X2 + // A = t0*t1 + // t2 = Y1+X1 + // t3 = Y2+X2 + // B = t2*t3 + // t4 = k*T2 + // C = T1*t4 + // t5 = 2*Z2 + // D = Z1*t5 + // E = B-A + // F = D-C + // G = D+C + // H = B+A + // X3 = E*F + // Y3 = G*H + // T3 = E*H + // Z3 = F*G + // + // In order to make the scalar multiply faster, the addend is provided + // as a `Addend_Group_Element` with t1, t3, t4, and t5 precomputed, as + // it is trivially obvious that those are the only values used by the + // formula that are directly dependent on `b`, and are only dependent + // on `b` and constants. This saves 1 sub, 2 adds, and 1 multiply, + // each time the intermediate representation can be reused. + + A, B, C, D := &scratch.A, &scratch.B, &scratch.C, &scratch.D + E, F, G, H := &scratch.E, &scratch.F, &scratch.G, &scratch.H + t0, t2 := &scratch.t0, &scratch.t2 + + field.fe_sub(t0, &a.y, &a.x) + t1 := &b.y2_minus_x2 + field.fe_carry_mul(A, t0, t1) + field.fe_add(t2, &a.y, &a.x) + t3 := &b.y2_plus_x2 + field.fe_carry_mul(B, t2, t3) + t4 := &b.k_times_t2 + field.fe_carry_mul(C, field.fe_relax_cast(&a.t), field.fe_relax_cast(t4)) + field.fe_carry_mul(D, field.fe_relax_cast(&a.z), &TWO_TIMES_Z2) + field.fe_sub(E, B, A) + field.fe_sub(F, D, C) + field.fe_add(G, D, C) + field.fe_add(H, B, A) + field.fe_carry_mul(&ge.x, E, F) + field.fe_carry_mul(&ge.y, G, H) + field.fe_carry_mul(&ge.t, E, H) + field.fe_carry_mul(&ge.z, F, G) + } + + @(private) + mul_bp_tbl_add :: proc "contextless" ( + ge: ^Group_Element, + tbl: ^Basepoint_Multiply_Table, + idx: u64, + tmp_add: ^Add_Scratch, + tmp_addend: ^Basepoint_Addend_Group_Element, + unsafe_is_vartime: bool, + ) { + // Variable time lookup, with the addition omitted entirely if idx == 0. + if unsafe_is_vartime { + // Skip adding the point at infinity. + if idx != 0 { + ge_add_bp_addend(ge, ge, &tbl[idx-1], tmp_add) + } + return + } + + // Constant time lookup. + tmp_addend^ = { + // Point at infinity (0, 1, 1, 0) in precomputed form, note + // that the precomputed tables rescale so that `Z = 1`. + {1, 0, 0, 0, 0}, // y - x + {1, 0, 0, 0, 0}, // y + x + {0, 0, 0, 0, 0}, // t * 2d + } + for i := u64(1); i < 16; i = i + 1 { + ctrl := subtle.eq(i, idx) + ge_bp_addend_conditional_assign(tmp_addend, &tbl[i - 1], int(ctrl)) + } + ge_add_bp_addend(ge, ge, tmp_addend, tmp_add) + } +} diff --git a/core/crypto/_edwards25519/edwards25519_table.odin b/core/crypto/_edwards25519/edwards25519_table.odin new file mode 100644 index 000000000..029b08418 --- /dev/null +++ b/core/crypto/_edwards25519/edwards25519_table.odin @@ -0,0 +1,4947 @@ +package _edwards25519 + +/* + ------ GENERATED ------ DO NOT EDIT ------ GENERATED ------ DO NOT EDIT ------ GENERATED ------ +*/ + +import "core:crypto" + +when crypto.COMPACT_IMPLS == false { + @(private,rodata) + Gen_Multiply_Table_edwards25519_lo := [32]Basepoint_Multiply_Table { + { + { + {4566296876323096, 4708280988758944, 2883091957081722, 4842055411046963, 5717267076190079}, + {3540182452943730, 2497478415033846, 2521227595762870, 1462984067271729, 2389212253076811}, + {301289933810280, 1259582250014073, 1422107436869536, 796239922652654, 1953934009299142}, + }, + { + {4966907458672021, 4936584233144657, 6114240989277698, 5254498676225494, 4146642117106832}, + {3632771708514775, 790832306631235, 2067202295274102, 1995808275510000, 1566530869037010}, + {748439484463711, 1033211726465151, 1396005112841647, 1611506220286469, 1972177495910992}, + }, + { + {4820158664987218, 4429624038632138, 3711242400124238, 3713328211397903, 3003390509798844}, + {1601611775252272, 1720807796594148, 1132070835939856, 3512254832574799, 2147779492816910}, + {1850748884277385, 1200145853858453, 1068094770532492, 672251375690438, 1586055907191707}, + }, + { + {3946190272469145, 6239505675006654, 5208669189437987, 5151632689063553, 5199813637784664}, + {934282339813791, 1846903124198670, 1172395437954843, 1007037127761661, 1830588347719256}, + {1121406372216585, 192876649532226, 190294192191717, 1994165897297032, 2245000007398739}, + }, + { + {4928851390486164, 2860263086157808, 4946162173083730, 5341365721927258, 4878154719998387}, + {769950342298400, 2384754244604994, 3095885746880802, 3225892188161580, 2977876099231263}, + {1086255230780037, 274979815921559, 1960002765731872, 929474102396301, 1190409889297339}, + }, + { + {4510980453010577, 4649810060060977, 4808503203819400, 5702468951241614, 3249489646904341}, + {1388594989461809, 316767091099457, 2646098655878230, 1230079486801004, 1440737038838979}, + {1181317918772081, 114573476638901, 262805072233344, 265712217171332, 294181933805782}, + }, + { + {4271167442657675, 2928511714391884, 4614310625181828, 3360446656227271, 5021391587042608}, + {2916800678241215, 2065379846933858, 2622030924071124, 2602788184473875, 1233371373142984}, + {965130719900578, 247011430587952, 526356006571389, 91986625355052, 2157223321444601}, + }, + { + {4325401225737414, 4534620752133203, 4768100597167576, 4751634318022197, 3282052041613534}, + {4320419353804412, 4218074731744053, 957728544705548, 729906502578991, 2411634706750414}, + {551790716293402, 1989538725166328, 801169423371717, 2052451893578887, 678432056995012}, + }, + { + {6229274597883966, 4185445767544427, 3794144352961029, 6271388400944242, 5801047593299399}, + {1802695059464988, 1664899123557221, 2845359304426105, 2160434469266658, 3179370264440279}, + {1381809363726107, 1430341051343062, 2061843536018959, 1551778050872521, 2036394857967624}, + }, + { + {3190293695332791, 4165728475672253, 4346255112396895, 3238346181288697, 4562115113555210}, + {1569908045411451, 706723917266915, 1500941167088851, 2522858060362189, 3442327746686552}, + {1454533688490200, 416156769327623, 1344514353803379, 1816391251363763, 259908591619060}, + }, + { + {4322190032257826, 3710718875543082, 5127771470387916, 5558932420078259, 4937587148103002}, + {4222693909998302, 2779866139518454, 1619374932191226, 2207306624415883, 1169170329061080}, + {893653801273833, 1168026499324677, 1242553501121234, 1306366254304474, 1086752658510815}, + }, + { + {4366666225767590, 5094682881462444, 5444160766003964, 2663859630225193, 4386427788371457}, + {1548398643541286, 3090755542662214, 2368065889335542, 1878116023572279, 2384475613352909}, + {1571032457823571, 1253760059932116, 665829584253800, 109400965270906, 981221002823741}, + }, + { + {6475278226276205, 4841626135259659, 5265997707342765, 5158696113477971, 4545898660066816}, + {2465253816303469, 3191571337672685, 1159882208056013, 2569188183312765, 621213314200686}, + {177130678690680, 1754759263300204, 1864311296286618, 1180675631479880, 1292726903152791}, + }, + { + {3248252964508250, 5061531253750778, 5542769770211014, 4619085244233909, 5311803534193606}, + {2375959787421170, 2263885670311134, 2822409136676350, 3122669455540755, 1947192330052816}, + {498660636760962, 1605652986893012, 893278769679967, 1769999239723039, 646478004325289}, + }, + { + {5574001150447352, 3524291821486207, 4161953422248557, 4327379335382018, 3442969602526468}, + {1913163449625248, 2712579013977241, 2193883288642313, 1008900146920800, 1721983679009502}, + {692896803108118, 500174642072499, 2068223309439677, 1162190621851337, 1426986007309901}, + }, + }, + { + { + {5457238221803851, 3344133750480297, 5923374394087185, 3057477798065323, 3111028807187760}, + {1368953770187805, 3042147450398169, 2689308289352409, 2142576377050579, 1932081720066286}, + {1200766035879111, 20142053207432, 1465634435977050, 1645256912097844, 295121984874596}, + }, + { + {5563698449899448, 3838625675758736, 4715900944610621, 4227102525088801, 5170323687134830}, + {1735718747031538, 1248237894295956, 1204753118328107, 976066523550493, 2317743583219840}, + {1091990273418756, 1572899409348578, 80968014455247, 306009358661350, 1520450739132526}, + }, + { + {4403130087311393, 3013844998431429, 3939874146236762, 3074845922691006, 3159402582764738}, + {3732317023121341, 1511153322193951, 3496143672676420, 2556587964178488, 2620936670181690}, + {2047386910586836, 168470092900250, 1552838872594810, 340951180073789, 360819374702533}, + }, + { + {5483833971283375, 6215856366616550, 5092534899560758, 4707898440462492, 3093598134728534}, + {1982622644432037, 2014393600336956, 2380709022489462, 3869592437614438, 2357094095599062}, + {197561292938973, 454817274782871, 1963754960082318, 2113372252160468, 971377527342673}, + }, + { + {5235862574050758, 3926212577912309, 4434256219348056, 5854494381844745, 2810258686980493}, + {2416499262514576, 2254927265442919, 3451304785234000, 1766155447043651, 1899238924683527}, + {2103305098582922, 1960809151316468, 715134605001343, 1454892949167181, 40827143824949}, + }, + { + {4483855840793217, 3239143728269862, 4367394306679708, 4071397886477406, 3371105467700097}, + {1239289043050193, 1744654158124578, 758702410031698, 4048562808759936, 2253402870349013}, + {320153677847348, 939613871605645, 641883205761567, 1930009789398224, 329165806634126}, + }, + { + {4780421392687930, 3788635404873276, 3557012555097608, 4565073531580670, 4303176850668304}, + {3232730304159378, 1242488692177892, 1251446316964684, 1086618677993530, 1961430968465772}, + {833449923882501, 1750270368490475, 1123347002068295, 185477424765687, 278090826653186}, + }, + { + {3756645926444593, 3454896102689928, 5065739048841913, 4777932644822338, 3536143867460687}, + {794524995833413, 1849907304548286, 2305148486158393, 1272368559505216, 1147304168324779}, + {483048732424432, 2116063063343382, 30120189902313, 292451576741007, 1156379271702225}, + }, + { + {5884070579505425, 5535277330947453, 5603542025663670, 4776593639127153, 4995715838681551}, + {2505290486961759, 2288457607049763, 1322694247668132, 2996684795874985, 1441775943403867}, + {1862130357601747, 1576563056403606, 1053598539514442, 836379099899856, 1745075449649052}, + }, + { + {4271432792719273, 4354519732898601, 3841949260311002, 4278872468826501, 3182588946344969}, + {994086190120795, 2265566763472579, 1778668799717474, 1759565368702851, 1705243805775865}, + {208457126969992, 1306788169067141, 1504881061177412, 778305094530678, 286650467791603}, + }, + { + {3704308183084302, 4667642921024280, 3735446294701327, 4710970560312866, 5219863835152358}, + {1155946475009464, 1378854908418478, 3050476655608427, 738141412602796, 1805371589338096}, + {1627667107954997, 2038498693464737, 380348381597727, 693747096546728, 1241364634477378}, + }, + { + {4610118268113321, 3236474426265456, 4804410568671572, 4099577866548348, 3504102383946080}, + {748123900738723, 2239140288387656, 322477057520882, 2644973441419796, 1290933190145308}, + {2218076336525385, 339947754397137, 1735892619490, 1441988709036711, 932991353908008}, + }, + { + {5176295056640358, 3403895808063209, 3860193783232080, 4018349594328251, 4528337169205809}, + {2638983432827646, 2268258692789757, 3287339174338050, 1299412654822337, 936917254750873}, + {430804656367208, 1812394904738259, 550528638373630, 2103769550939254, 443986453677108}, + }, + { + {4019814909194368, 2925457503142305, 3944973873459804, 4250278944002558, 4031746156495663}, + {3925945607985574, 2164215477088927, 2286513560718006, 3385980103702156, 1734257170111047}, + {38890723392351, 853701573154564, 966467672212375, 417321296433946, 554926061377915}, + }, + { + {5000002949084352, 4896484517581292, 5148976024567894, 4815058842461170, 4176010608048328}, + {1720782684885150, 798987029915204, 1610161967147136, 3970529737234552, 936254274515738}, + {562662523022136, 737396420860869, 1964828496205405, 271079414894445, 1393713695470127}, + }, + }, + { + { + {4641332589184683, 2958470737602587, 5890637714236266, 6469243441056846, 3636576929381593}, + {3180171966714267, 2147692869914563, 1455665844462196, 1986737809425946, 2437006863943337}, + {481144981981577, 2053319313589856, 2065402289827512, 617954271490316, 1106602634668125}, + }, + { + {5160989980743332, 3250299780570808, 5495492964276292, 5314069834477255, 2594939618294032}, + {2948097833334040, 3145099472726142, 1148636718636008, 2278533891034865, 2203955659340680}, + {791736669492960, 934767652997115, 824656780392914, 1759463253018643, 361530362383518}, + }, + { + {5791086827335700, 4467111755065554, 3804728204617233, 6168459157050691, 3376804788950489}, + {2022541353055578, 4346500076272714, 3802807888710933, 2494585331103411, 2947785218648809}, + {677434665154918, 989582503122485, 1817429540898386, 1052904935475344, 1143826298169798}, + }, + { + {3025160502526487, 6318980957908565, 4867373065037870, 5043229614440699, 3035080247933683}, + {2619066141993637, 2570231002607651, 2947429167440602, 2885885471266079, 2276381426249673}, + {180820816194166, 168937968377394, 748416242794470, 1227281252254508, 1567587861004268}, + }, + { + {4236540720225255, 5582763806770724, 3307821162947907, 3911758370168910, 3340328882710774}, + {2730575372268893, 2062896624554806, 2951191072970647, 2609899222113120, 1277310261461760}, + {580736401511151, 1842931091388998, 1177201471228238, 2075460256527244, 1301133425678027}, + }, + { + {3547095551954881, 3966542127392273, 5049182669833076, 6538011303633046, 3765047903698852}, + {1515728832059163, 1575261009617579, 1510246567196186, 2442877836294952, 2368461529974388}, + {230710545179830, 30821514358353, 760704303452229, 390668103790604, 573437871383156}, + }, + { + {4354054137171033, 3822632479902001, 4538296533915119, 4245013553492583, 4574238179641958}, + {3421179921230875, 2514967047430861, 4274701112739695, 3071700566936367, 4275698278559832}, + {894132856735058, 548675863558441, 845349339503395, 1942269668326667, 1615682209874691}, + }, + { + {5296988143897756, 3567256897335281, 4224086813027664, 4153625766737702, 4841869104592905}, + {3539470031223082, 1222355136884919, 1846481788678694, 1150426571265110, 1613523400722047}, + {550201530671806, 778605267108140, 2063911101902983, 115500557286349, 2041641272971022}, + }, + { + {2639140850252425, 3988225053741778, 4109492541046027, 4467731762307139, 4788525019017799}, + {1956266817271455, 2914237312642832, 2018010448016151, 4042065159660719, 3422400064417223}, + {1185820244523867, 953640094456191, 1426524678517613, 1191533398208458, 1993578549159852}, + }, + { + {4724762102005390, 3941768459309593, 3168985852401486, 5230753070525336, 5120855380354436}, + {2162922301975048, 2584871642802941, 2903836488265486, 2034914383000476, 1973107217149520}, + {1225503059018859, 1744932331605022, 393061606917651, 2045141059558447, 1187823695528756}, + }, + { + {3873867956612972, 5901886943623014, 4214442512189194, 3726570129804851, 4003114175771373}, + {2499971111138236, 1856344473990516, 2851460465748678, 1490509710033167, 3414551741933391}, + {1569106592395768, 1670704805332568, 2011861983976474, 822492307064908, 1138495702641636}, + }, + { + {4611233673112936, 4109919865110418, 3874636387071312, 4304609757893158, 4158539624577373}, + {3888656531434102, 3371559592472684, 2495053387333630, 3579436360572308, 1114431352259831}, + {2209993507106795, 1762615018349199, 1687296090930185, 9491601628221, 870532128794902}, + }, + { + {4833972836221169, 5399132877586271, 4606616407949355, 4080860583790927, 4239964386503137}, + {1305913677624121, 3558400184075999, 3275823038503467, 3454063433790229, 1309514508446881}, + {1566723549675548, 1397175496983691, 504231980459915, 306990234666329, 1744893526714441}, + }, + { + {4014795958128859, 5054570465100501, 3081378639295577, 5833550217358299, 3899560884622359}, + {972376391789061, 1850852472634117, 2719443704140285, 2186622623776515, 3209686661433313}, + {2171782442569495, 1594104418173184, 1848207566547320, 2195471209947031, 1091928745815642}, + }, + { + {4698583634348737, 4028817484747578, 3922491723357167, 4921897981297279, 5070174707952522}, + {3952749170677737, 509151538148928, 2600240333845125, 2270835069234179, 3790913978189516}, + {1587050028613976, 1757976429633698, 440367736554514, 102469500615778, 1293087093446941}, + }, + }, + { + { + {4765314848902696, 4047154143755239, 3748677840535530, 5003339347891547, 4892630780044264}, + {717255318455100, 519313764361315, 2080406977303708, 541981206705521, 774328150311600}, + {1997217696294013, 1717306351628065, 1684313917746180, 1644426076011410, 1857378133465451}, + }, + { + {4274106452868777, 5229895690942370, 4818944681819138, 3310533142834467, 5951800763431172}, + {3727234538477877, 2328731709971226, 3368528843456914, 2002544139318041, 2977347647489186}, + {1710065158525665, 1895094923036397, 123988286168546, 1145519900776355, 1607510767693874}, + }, + { + {6052094801116259, 4945910156597034, 3249872360685630, 5056653985755776, 5148423953746665}, + {2813405189107769, 1071733543815036, 2383296312486238, 1946868434569998, 3079937947649451}, + {1445526537029440, 2225519789662536, 914628859347385, 1064754194555068, 1660295614401091}, + }, + { + {5380526401591301, 2806418790173460, 3263856123526812, 3091761635239858, 3666299153992924}, + {3451490036797185, 2275827949507588, 2318438102929588, 2309425969971222, 2816893781664854}, + {703047626104145, 1266841406201770, 165556500219173, 486991595001879, 1011325891650656}, + }, + { + {4838486554794399, 4993110726592022, 4632760493337220, 3972608926828727, 2871500009334501}, + {1622861044480487, 1156394801573634, 4120932379100752, 2578903799462977, 2095342781472283}, + {1646545795166119, 1758370782583567, 714746174550637, 1472693650165135, 898994790308209}, + }, + { + {4062996033667232, 5572569452904097, 4793202602203933, 4240755857296838, 5367161970768862}, + {2585203586724508, 2547572356138185, 1693106465353609, 912330357530760, 2723035471635610}, + {906282429780072, 2108672665779781, 432396390473936, 150625823801893, 1708930497638539}, + }, + { + {3731585820952935, 6242481486437170, 4572245823847061, 4398306869785574, 5751262444905966}, + {925664675702309, 2273216662253932, 4083236455546587, 601157008940112, 2623617868729744}, + {52035296774456, 939969390708103, 312023458773250, 59873523517659, 1231345905848899}, + }, + { + {4632957969763174, 4184611431390023, 5680349018170176, 4901639977232284, 5674379295460919}, + {2895154920100990, 2541986621181021, 2013561737429022, 2571447883196794, 2645536492181409}, + {2051980782668029, 121859921510665, 2048329875753063, 1235229850149665, 519062146124755}, + }, + { + {4207228868621988, 4953881226819951, 4139842782246336, 4298958943276773, 3359727402165629}, + {947983997565204, 1512975730400883, 4017071259732234, 765863411195419, 2287620622340759}, + {2248717923990509, 953644234015146, 118881148429301, 1244045737066019, 519708790776758}, + }, + { + {5697680122778496, 6228365759267448, 4861216723530833, 4702869303488893, 5552489090348314}, + {1440754265571108, 2717772629254708, 2851948946836421, 3389483713931559, 1448786922664578}, + {843777949621211, 1435525643946674, 1087149831109219, 1794919173070415, 1112222323032617}, + }, + { + {5102037877608319, 4652686712219969, 3897951345871191, 3585818368367414, 5206224086433126}, + {1659077274827511, 3292962448731851, 3877468219103951, 1516723029470630, 2756801757695330}, + {1080269027468022, 217052522911549, 1656325362355128, 1627927536138189, 547476742306034}, + }, + { + {4629572650764889, 5482991583454262, 5026118951697692, 3386284302539994, 4183091862778757}, + {4049116095173975, 2853051218008192, 874408124299498, 2811479573934506, 3061819813989639}, + {1673853233469462, 2069508754540826, 444570721431342, 318669192295723, 1286647860911061}, + }, + { + {5230179910306733, 4570722910725029, 2679420725332655, 3219299251684998, 5101899978929471}, + {3368016050367733, 1864179846991811, 2025579249953153, 2185933453914170, 3081358815633795}, + {1120488984292940, 268864491510849, 230793761352121, 54153081190951, 1544798876643945}, + }, + { + {4594071143939477, 4032573207368795, 3586642054806445, 2633280388282362, 4204685405148786}, + {3215023450765629, 1989745848107067, 2317683847606295, 2073505048594828, 792770882411102}, + {213368529611304, 716996641453362, 1913278462832177, 1585475497182388, 563601091454134}, + }, + { + {2835663672936090, 4829603014808807, 3487022863582034, 2792788055117753, 4407939774570859}, + {1893732627269868, 2896260158734549, 1988156739597398, 2606708976150985, 1947694156880429}, + {1687313081048019, 7705508083870, 487993091259388, 560742684726806, 779697153923449}, + }, + }, + { + { + {4089455896800313, 6013733676182565, 5409863301562555, 4072864011490980, 5068974752046796}, + {3859970785658325, 2667608874045675, 1350468408164765, 2038620059057678, 3278704299674360}, + {578027192365650, 2034800251375322, 2128954087207123, 478816193810521, 2196171989962750}, + }, + { + {4965788985850512, 4036616547844474, 3863134115336615, 3555738077628787, 5211189187689919}, + {1633188840273120, 3104586986058956, 1548762607215795, 1266275218902681, 3359018017010381}, + {1038829280972848, 38176604650029, 753193246598573, 1136076426528122, 595709990562434}, + }, + { + {4508300680732578, 6151240693672842, 5551152629612579, 4175434827081223, 4710569942272560}, + {3660251634545082, 2194984964010832, 2198361797561729, 1061962440055713, 1645147963442934}, + {1750479161778571, 1362553355169293, 1891721260220598, 966109370862782, 1024913988299801}, + }, + { + {5140408161043668, 3514001525352806, 4894551007701094, 3915220506382540, 5065550949127901}, + {2464498862816952, 1117950018299774, 1873945661751056, 3655602735669306, 2382695896337945}, + {520731594438141, 1446301499955692, 273753264629267, 1565101517999256, 1019411827004672}, + }, + { + {3716451775537782, 3735537109406964, 3771250375020764, 3413229645449032, 4909514625550472}, + {3178327305714638, 3443653291096626, 734233225181170, 2435838701226518, 4042225960010590}, + {996126634382301, 796204125879525, 127517800546509, 344155944689303, 615279846169038}, + }, + { + {5126516964784293, 5722588804459529, 5788457340217086, 5474101689079853, 4854624835487584}, + {2990523894660505, 2188666632415295, 1961313708559162, 1506545807547587, 3403101452654988}, + {2067814584765580, 1677855129927492, 2086109782475197, 235286517313238, 1416314046739645}, + }, + { + {5182089550298661, 4268457398409278, 4594577010420123, 5530431534605076, 5118871120313016}, + {2838644076315587, 2559244195637442, 458399356043425, 2853867838192310, 3280348017100490}, + {301225714012278, 1094837270268560, 1202288391010439, 644352775178361, 1647055902137983}, + }, + { + {5639203700568665, 3935121894170720, 5272747431747178, 4338487944274660, 5404045310490874}, + {1210746697896459, 1416608304244708, 2938287290903104, 3496931005119382, 3303038150540984}, + {1971518477615628, 401909519527336, 448627091057375, 1409486868273821, 1214789035034363}, + }, + { + {5099963449143288, 5521329395009146, 5925708408867572, 4221709339736212, 4612387286592975}, + {1894554173291056, 3439387781984292, 2885767225889068, 620075308547710, 1923191105660691}, + {2193142205372254, 2249202758109308, 136771833945490, 2136446252990850, 1913453314551631}, + }, + { + {3519416739470062, 5800837512824035, 5629830750568439, 3858242948002290, 4384918516791051}, + {1031287572005306, 2743053635058531, 1307200063174499, 886968262945288, 322139622562321}, + {1603190765881197, 1131168289986667, 1851325240689452, 1811918922856612, 1688789764638099}, + }, + { + {5675121438563826, 3813646429348722, 6155915780969232, 4550135853787182, 3281226794470063}, + {1227916715088978, 3565721991039408, 2825753167382054, 446650609575830, 3201068492916497}, + {465975618381320, 1757724298980204, 2172737911773281, 1844204403201116, 367200393612929}, + }, + { + {4053304559591831, 4763567221009860, 6256382270106074, 5569940279565028, 4297628970970611}, + {522695684014153, 2454309386747442, 1812320598717590, 1790060723730286, 513480358702681}, + {1695032670616248, 1588968761785032, 699742416328216, 547685855993128, 1790235994988743}, + }, + { + {3776137870634381, 3800031162558423, 5542451196069607, 4330978223940644, 5450131593237007}, + {3411403847639229, 1506626399353463, 2324339461338721, 1195836709245006, 2829489236982793}, + {263703254267006, 1082588170565097, 2024394221181425, 46543794553459, 2110417854356146}, + }, + { + {5712489756196259, 4857601027744288, 4243491518458906, 4901936639181452, 4456074323550475}, + {2520601556174181, 1164555774547222, 2770926848501726, 3208860864993280, 497236288525621}, + {247502314830666, 1623351904090299, 1162047175878913, 1697644630093486, 776531516340321}, + }, + { + {2686302584388573, 3722578779150130, 6045187633044733, 3467509394641570, 3302975571798606}, + {2408284467064191, 2899235622132542, 2270755745458389, 1460665123127634, 2622446416668442}, + {625008843842459, 305089228555404, 1124988453243439, 123919845855976, 788637610781258}, + }, + }, + { + { + {3297030136943183, 5321806228516302, 2882313002761349, 3923846342683379, 5310803644932932}, + {1364039144731711, 1897497433586190, 2203097701135459, 2397261210496499, 1349844460790698}, + {439961968385997, 386362664488986, 1382706320807688, 309894000125359, 2207801346498567}, + }, + { + {4255565910583278, 4673673686605660, 3392924072653217, 3737219707166220, 3825562634713972}, + {3480804500082836, 3172443782216110, 2375775707596425, 2933223806901024, 1400559197080972}, + {729905708611432, 1270323270673202, 123353058984288, 426460209632942, 2195574535456672}, + }, + { + {4013408251151364, 5086960474897299, 3838506203370739, 4408856413264508, 3422492183371019}, + {1271140255321216, 2044363183174497, 2303925201319937, 3696920060379952, 3194341800024331}, + {871476219910823, 1878769545097794, 2241832391238412, 548957640601001, 690047440233174}, + }, + { + {3251428812313581, 5636436335863895, 4336541488202699, 4972942980386107, 5182382616078529}, + {2548994545820755, 1366347803776819, 3552985325930849, 561849853336293, 1533554921345731}, + {2189427607417022, 699801937082607, 412764402319267, 1478091893643349, 2244675696854460}, + }, + { + {5012160783311108, 5470528103057159, 4488517614835378, 2676343672262544, 4341072770671390}, + {3964091869651792, 2456213404310121, 3657538451018088, 2660781114515010, 3112882032961968}, + {221245220129925, 1156020201681217, 491145634799213, 542422431960839, 828100817819207}, + }, + { + {2810886626483710, 5076777331583206, 6133336711186896, 3651619527147841, 3898754191951285}, + {2405556784925632, 1299874139923976, 2644898978945750, 1058234455773021, 996989038681183}, + {1887963056288059, 228507035730124, 1468368348640282, 930557653420194, 613513962454686}, + }, + { + {5579887344422086, 5618055197913529, 4690896687085975, 4754046511662615, 4136987326235786}, + {1224529808187534, 1577022856702685, 2206946542980843, 625883007765001, 2531730607197406}, + {902497362940219, 76749815795675, 1657927525633846, 1420238379745202, 1340321636548352}, + }, + { + {5132340287409247, 4194838312213087, 4971385975164381, 5596941055673869, 4739013486883497}, + {1129576631190765, 3533793823712575, 996844254743017, 2509676177174497, 3402650555740265}, + {237425418909360, 469614029179605, 1512389769174935, 1241726368345357, 441602891065214}, + }, + { + {5266234055777943, 3166499093963215, 4159587332862448, 3232787848503690, 6261694765772425}, + {2508069708566903, 2982887287210837, 1712829089863354, 1739545432690564, 1853100260794477}, + {4642168584761, 1314096799362798, 1620739012635580, 444075187404753, 76135520441225}, + }, + { + {5167832514805982, 5410004641404511, 3809624149844670, 4773980049888932, 3778278866830004}, + {1717340294466846, 3145810307460687, 1904170181110298, 3950114374260626, 2248427553137502}, + {1356583144121446, 1439603152129038, 880464721166116, 426511648446184, 1044401386572766}, + }, + { + {3827273464157640, 5470853620720833, 4235776821907793, 5432246822532161, 4674460658804935}, + {3682691082267936, 1935676112917301, 3170276622979891, 2876033130676637, 1596266630249199}, + {1484505136430423, 343818915658679, 1066931341976591, 1574952097402529, 895157643469052}, + }, + { + {6636210482709397, 2566644085561849, 4278449441656290, 5708653335234549, 6540605640281063}, + {2193735258244385, 2265742668153213, 2801601661178220, 1573679250261669, 2218164822512395}, + {125908919015544, 908539856510216, 254196493329521, 1841783557943867, 1826956209112337}, + }, + { + {4015848574593688, 5374261932338028, 4759505940569418, 5686761164384680, 3410517186063399}, + {1218465765165754, 1222399589933778, 4149598104194804, 2307999947285970, 2530437726498307}, + {1352017428769842, 1226345478088737, 1834808987089176, 171935268241134, 1252599135760918}, + }, + { + {4391913968320982, 5643346087738336, 3260878495624279, 6345563729780486, 6485738780527396}, + {269241043449612, 1713401415896622, 3060740655644691, 2228155591500882, 2273523243235430}, + {994025955714788, 1395495501299355, 1717525291885154, 64780760930213, 1492125616744822}, + }, + { + {4496571738540020, 6137682561017990, 4165346179942417, 4589212756752962, 5249152453870163}, + {2859457773452122, 2592803086422694, 761249806099561, 4355723617152898, 2688955778843975}, + {686675614020084, 1129369471718576, 1361332769753183, 814390480194826, 1958437091006724}, + }, + }, + { + { + {4212554477605918, 5000640585259457, 4161632664968341, 3523231950682073, 4471580181706187}, + {3988217766743784, 726531315520507, 1833335034432527, 1629442561574747, 2876218732971333}, + {1537037379417136, 1358865369268262, 2130838645654099, 828733687040705, 1999987652890901}, + }, + { + {4063362146350583, 3753681832692920, 4465563314774246, 4863172707090131, 4539970192419610}, + {629042105241795, 1098854999137608, 887281544569320, 3674901833560025, 2259711072636808}, + {218907117361280, 1209298913016966, 1944312619096112, 1130690631451061, 1342327389191701}, + }, + { + {4482501699248035, 5851772807709469, 4424655942309844, 5930138373494266, 4947793108696645}, + {1369976867854685, 1396479602419169, 4017456468084104, 2203659200586298, 3250127649802489}, + {784210426627951, 918204562375674, 1284546780452985, 1324534636134684, 1872449409642708}, + }, + { + {4153660020381144, 4256288935750983, 3877646875253483, 3225329557085126, 4327087498998152}, + {2571438643225542, 2848082470493653, 2037902696412607, 1557219121643918, 341938082688094}, + {1371853944110545, 1042332820512553, 1949855697918254, 1791195775521505, 37487364849293}, + }, + { + {4334516943269102, 4531429052909917, 4649254694042464, 3942327023530758, 6368860137043973}, + {687200189577836, 1082536651125675, 2896024754556794, 2592723009743198, 2595381160432643}, + {1059729620568824, 2163709103470266, 1440302280256872, 1769143160546397, 869830310425069}, + }, + { + {4276621734726805, 4930548302820644, 2846933097770719, 4975460488256465, 2852121493098246}, + {3861316033464273, 777277757338816, 2101121130363987, 550762194946473, 1905542338659364}, + {598474602406721, 1468128276358244, 1191923149557635, 1501376424093216, 1281662691293476}, + }, + { + {2971320059272372, 4896980339002840, 4635950028233875, 3795071084495975, 4071343109483907}, + {1721138489890688, 1264336102277790, 2684864359106535, 1359988423149465, 3813671107094695}, + {396397949784152, 1811354474471839, 1362679985304303, 2117033964846756, 498041172552279}, + }, + { + {5154223559778472, 3389351102095821, 4377023217300786, 3977457826906518, 4386692778803043}, + {1812471844975748, 1856491995543149, 126579494584102, 3288044672967868, 1975108050082549}, + {522584000310195, 1241762481390450, 1743702789495384, 2227404127826575, 1686746002148897}, + }, + { + {4080889153606423, 5116319911316914, 4006591728131774, 4350736921528591, 4198995697088691}, + {3932341308304797, 1612580099028530, 2937385230920440, 1836672506516533, 517164940700103}, + {1413348606155183, 810499206093511, 1138057743946731, 1556315649471799, 993617155135620}, + }, + { + {5656453792030509, 6079591987914126, 5929179648294721, 5230798899043491, 3370342887971873}, + {2735841961308013, 2116601197688202, 2652241807415589, 1945152844924315, 2885012584681659}, + {551620533268687, 1182887684657061, 1043366705332762, 944140538303658, 2240921917214007}, + }, + { + {2427888929082724, 4467682652740956, 5335339067201761, 5550886290485514, 5050956980777821}, + {2247945978763224, 215736457901546, 1047424049356243, 1389596126698944, 816935367913617}, + {1146743855918524, 1418503734887175, 843342293437400, 1502230097098390, 1240491010654824}, + }, + { + {6701933119211633, 5059229274152685, 4982837924778640, 4159052306481152, 4290369756778959}, + {2204538589507457, 3142843240983995, 2451576614290660, 3204217003708084, 2887474477188681}, + {510455031824465, 465163402943305, 2022658124081289, 1881132727821470, 31746160856543}, + }, + { + {5097091659825113, 2826376647382075, 3998920599703675, 3513481695405562, 5076475699131519}, + {1330330618013145, 2313004235002329, 3963525218487729, 2303930585911304, 2755772190474933}, + {944243695677568, 255912283647788, 1855489019383837, 1244636060478392, 1911682985774639}, + }, + { + {5024454158738700, 2514912085825565, 3852574473189297, 4034915921452192, 3904120669219782}, + {3843903221055742, 2416642267747155, 1715729591405051, 1735036083660438, 1182009761997504}, + {1140604273028187, 1352033415206334, 1448886815181311, 941652546197192, 1001542060535421}, + }, + { + {4277058348919964, 5364603224614130, 5366326037527057, 4814184001945705, 5895346951506596}, + {3602696745610322, 2198425366751348, 1768623515003979, 2456584282641319, 3022619356175890}, + {1305849451281975, 726672899606505, 2105928429843370, 246834240873219, 1573506984361288}, + }, + }, + { + { + {4821701574825479, 4751738035366345, 3733704008989173, 4812878081681692, 3510316573903125}, + {427904865186293, 1703211129693455, 1585368107547509, 3688784302429584, 3012988348299225}, + {1275068538599310, 513726919533379, 349926553492294, 688428871968420, 1702400196000666}, + }, + { + {3810616250567627, 4214696146321770, 5841309449432647, 3753213644462184, 4798035793202427}, + {3313663849950481, 3213411074010628, 2573659446386085, 3297400443644764, 1985130202504037}, + {818359826554971, 1862173000996177, 626821592884859, 573655738872376, 1749691246745455}, + }, + { + {4398313517418541, 5088388527765162, 4968565284650452, 4435773453041373, 4741970786827285}, + {1988022651432119, 3333911312271288, 1834020786104820, 3706626690108935, 692929915223121}, + {1129007025494441, 2197883144413266, 265142755578169, 971864464758890, 1983715884903702}, + }, + { + {4948148597287912, 3704086267538602, 4365531255192057, 2896988087581106, 5313917252680007}, + {1291366624493056, 2633256531874362, 1711482489312443, 1815233647702022, 3144079596677715}, + {2242724082797924, 1373354730327868, 1006520110883049, 2147330369940688, 1151816104883620}, + }, + { + {4667323107306775, 4619024517173644, 3407816205266473, 6398541848123859, 4222349233671575}, + {3997520014069025, 4163522956860564, 2056329390702073, 2607026987995097, 3131032608056347}, + {681981452362484, 267208874112496, 1374683991933094, 638600984916117, 646178654558546}, + }, + { + {2512483707152304, 5357659933447732, 5417239179350606, 4508304204210617, 2532054624493958}, + {2265178468539480, 2358037120714814, 1944412051589650, 4093776581610705, 2482502633520820}, + {715374893080287, 1173334812210491, 1806524662079626, 1894596008000979, 398905715033393}, + }, + { + {4348221360643351, 4174322814635610, 5293430650247335, 4930894772059273, 4824523600532224}, + {2751826223412909, 3848231101880618, 1420380351989369, 3237011375206737, 392444930785632}, + {1927770723575450, 1485792977512719, 1850996108474547, 551696031508956, 2126047405475647}, + }, + { + {2635705015322199, 3111746811317117, 5359223495008139, 3268925594263041, 3046050645563056}, + {2112099158080129, 2994370617594963, 2258284371762679, 1951119898618915, 2344890196388664}, + {77571826285752, 999304298101753, 487841111777762, 1038031143212339, 339066367948762}, + }, + { + {5619164208408509, 4079972709845361, 3927824185200012, 3681293890692042, 5452751544406703}, + {2191882696778049, 531264700870777, 3039670365049278, 1359665656266722, 3162072763716517}, + {1570940255668145, 688547574737286, 1632136413236589, 2053774689811525, 676669102580803}, + }, + { + {5183231995448322, 4155796849234556, 4791323788081582, 4471675968988079, 5711715782924180}, + {3207409007530338, 935702897763596, 729948770061474, 1584905172662705, 2425339805308626}, + {288239669792058, 2152796035840109, 162317061559789, 1257054119617939, 421141027109762}, + }, + { + {4958697699223355, 3221953471379609, 2818398572467973, 5875894486831009, 3850357049774603}, + {642422906756119, 3171839279489789, 1695193497886789, 3040583315302385, 3362141503479163}, + {1042979452017909, 1774768735282920, 464726722030945, 1465185933073826, 1382968477576580}, + }, + { + {3858506126065685, 4410239993278318, 3464562222229353, 3841799127123745, 3236074797259687}, + {3342987691574741, 2002872538662690, 3240810091817983, 3479310152893167, 2490884376592639}, + {2139337814897324, 178720275772072, 596052025976159, 666224594355251, 630639510547398}, + }, + { + {2744437082123657, 4441348097375482, 3869182720347428, 4304304367735980, 3086995265547722}, + {2392789380667179, 812658446707360, 1599624958311986, 214741817968452, 1436587626236000}, + {130387450082061, 1779587373012878, 417414670169839, 716150862374041, 154849814949784}, + }, + { + {4442837550688441, 4997631045842130, 5291735080737359, 4549950120656089, 4456650325708853}, + {2746366883922045, 2305345226446032, 2885706560860073, 4092938150156125, 656228807731693}, + {1456049106825164, 137394514200521, 2140871605490631, 1643256698410764, 679389221519059}, + }, + { + {3925184987729414, 3825370065750239, 2928329430708313, 5366989011209685, 4444246216420488}, + {2346187442256272, 1014027377437197, 2069628555505675, 1559427210701775, 1456229816012936}, + {2009324336353948, 1468073297564484, 1969534512584396, 827056802549955, 104599952309039}, + }, + }, + { + { + {5505012288893163, 2599996010752544, 3918414180409193, 3140224808718007, 2832547501486604}, + {2926794589205781, 2517835660016036, 826951213393477, 1405007746162285, 1781791018620876}, + {1939560076207777, 1409892634407635, 552574736069277, 383854338280405, 190706709864139}, + }, + { + {5180561690600497, 4132075350834054, 4298520825287953, 5392062874453498, 5821901179394561}, + {2177087163428741, 1439255351721944, 3459870654068041, 2230616362004768, 1396886392021913}, + {1466980508178206, 617045217998949, 652303580573628, 757303753529064, 207583137376902}, + }, + { + {4105782219090338, 4130463869936394, 6031610648174487, 5523226095524059, 5632038039559529}, + {3762856566592150, 2357202940576524, 2745234706458093, 1091943425335975, 1802717338077427}, + {1963939888391106, 293456433791664, 697897559513649, 985882796904380, 796244541237972}, + }, + { + {3680158110175880, 5530714909790973, 4808440325428831, 4945009801397122, 4071158169963819}, + {2668570812315008, 2641455366112301, 1314476859406755, 1749382513022778, 3413705412424739}, + {204943430200135, 1554861433819175, 216426658514651, 264149070665950, 2047097371738319}, + }, + { + {5165635210954903, 4790335732463592, 5635372627881110, 5322093841581933, 4976543419424973}, + {1934415182909015, 1393285083565062, 2768209145458208, 3409490548679139, 2372839480279515}, + {665784778135882, 1893179629898606, 808313193813106, 276797254706413, 1563426179676396}, + }, + { + {4283233217201481, 4707596242598657, 4674086796207577, 5485113232161884, 3095373778602077}, + {945205108984213, 2778077376644543, 1324180513733565, 1666970227868664, 2405347422974421}, + {1476570093962618, 838514669399805, 1857930577281364, 2017007352225784, 317085545220047}, + }, + { + {3545343323078703, 4395424422887793, 5561961194168003, 4717696754764488, 3198688329157975}, + {1461557121912823, 1600674043318359, 2157134900399597, 1670641601940616, 2379565397488531}, + {357067959932916, 1290876214345711, 521245575443703, 1494975468601005, 800942377643885}, + }, + { + {5120856274973686, 3903907574784685, 4109012860330718, 3337396988900217, 3069232573515769}, + {2817916472785262, 820247422481739, 994464017954148, 2578957425371613, 2344391131796991}, + {771808161440705, 1323510426395069, 680497615846440, 851580615547985, 1320806384849017}, + }, + { + {6662756671601401, 5055771079546289, 4642910898897859, 4274227027260534, 5833718441044794}, + {2335519494956627, 3820365010713627, 1944201046475949, 1640913863967574, 2358631279976586}, + {990528501134234, 1330224017810407, 1573804236508381, 942270438439677, 25201841708767}, + }, + { + {5526427987749634, 4518401023168866, 4921120012283882, 4779318497665973, 4555652731610533}, + {2646721458762538, 1247587116821480, 2586827199616378, 3932021497491885, 969339720975687}, + {1595456591254808, 1919330451560855, 265402806641622, 1560117962587834, 1169927205192232}, + }, + { + {4189409997656536, 4659089518495636, 6000827340603279, 5702161301408170, 5941261317517041}, + {3317917962903276, 1668664191271588, 1899844145838597, 1696011444672828, 2282054748309227}, + {2126527989994119, 1465890683922518, 416427350021352, 1618807264846944, 1588324622180673}, + }, + { + {4009588676432813, 4225252562340771, 5138392626199289, 6147384375179966, 4323738229760897}, + {2550824143198317, 3724772924079255, 2640826097206085, 2805004284285778, 3725892598967957}, + {901870527597111, 1300831444709451, 1795706127510368, 1590464383227069, 60287918150860}, + }, + { + {4260735023331218, 2752239523202930, 4432983289513289, 6073621772440017, 5069964246448815}, + {2411640257311042, 2404639281373100, 935718519552991, 2182928933394409, 3181304181386605}, + {301088722784222, 902977224984285, 1485824849826196, 864674789855395, 2204280040105719}, + }, + { + {5294452585150653, 4378774784126084, 2684611835446325, 6054460125397337, 3113938028918105}, + {1102630701890799, 2202327440719776, 1844385418066207, 1719220574774295, 3022438833862057}, + {1192644591215061, 1951970263153038, 182489349589207, 1072483329544407, 1425993434915257}, + }, + { + {3759682407110969, 4757463391782573, 6126440026160055, 4699689556446215, 5715476431941391}, + {2696424379059465, 2927324693839557, 2595575928464217, 3964369572567959, 2720628440266425}, + {786193544150213, 816842401151828, 2071842707112420, 581055055128968, 310970557266803}, + }, + }, + { + { + {3579768107573076, 3587300666628503, 3653386978219511, 5061736939322935, 6054960176639396}, + {1219260086131896, 2898968820282063, 2331400938444953, 2161724213426747, 2656661710745446}, + {417621685193956, 1429953819744454, 396157358457099, 1940470778873255, 214000046234152}, + }, + { + {3878872728667188, 4463402894965320, 4164169415301751, 3443570249906556, 4439109571211107}, + {1268047918491954, 2172375426948536, 1533916099229249, 1761293575457130, 3842422480712013}, + {1149147819689533, 378692712667677, 828475842424202, 2218619146419342, 70688125792186}, + }, + { + {4292523638342576, 4903155265245570, 5136143002823489, 3124449750693297, 5738994354400728}, + {3551539230764990, 3690416477138006, 3788528892189659, 2053896748919837, 3260220846276494}, + {2211311599327900, 2139787259888175, 938706616835350, 12609661139114, 2081897930719789}, + }, + { + {4097322728303089, 5725797875706037, 4654440700130628, 4178828883626228, 5693513031868506}, + {1324994503390431, 2588782144267879, 1183998925654176, 3343454479598522, 2300527487656566}, + {1079559557592645, 2215338383666441, 1903569501302605, 49033973033940, 305703433934152}, + }, + { + {3683815626821508, 4943964422665864, 3647446876506747, 4228674336449825, 5438052000093847}, + {2346453219102138, 3637921163538246, 3313930291577009, 2288353761164521, 3085469462634093}, + {1296625309219774, 2068273464883862, 1858621048097805, 1492281814208508, 2235868981918946}, + }, + { + {3534262737397977, 5245485311356750, 4279554456512807, 2770789343226274, 4078409823241192}, + {1490330266465551, 1858795661361448, 3688040948655011, 2546373032584894, 3459939824714180}, + {1525827120027511, 723686461809551, 1597702369236987, 244802101764964, 1502833890372311}, + }, + { + {6545268376680796, 4436205135889147, 3885200451296283, 4362482319222146, 6551744017455139}, + {2365421849929742, 3485539881431101, 2925909765963743, 2114345180342964, 2418564326541511}, + {503058759232932, 760293024620937, 2027152777219493, 666858468148475, 1539184379870952}, + }, + { + {2929839349119735, 5074186917559835, 3857102490299366, 4399562376560948, 3957863610776951}, + {1916168475367211, 3167426246226591, 883217071712574, 363427871374304, 1976029821251593}, + {1439489648586438, 2194580753290951, 832380563557396, 561521973970522, 584497280718389}, + }, + { + {4107979200870526, 4899400547785857, 5175087145170849, 5761419237914916, 2674185367684618}, + {1133946710417756, 499737269360777, 1645961935513831, 2259932248870354, 2394185034627430}, + {2211650710341615, 1916525167795392, 2219254718801699, 1123275886572725, 2065912631812720}, + }, + { + {2942743383283030, 4661681143781323, 4853180648224206, 3984362536169634, 3769046963947699}, + {2547466619616960, 1599890997313053, 1767449403100900, 3146589914609346, 2442645855602917}, + {1023269497317835, 1006858415503750, 2159836138753919, 1535892167365222, 826474553854585}, + }, + { + {4044410514205452, 4788613576788997, 4922881390894542, 4505428839963076, 3254381502973105}, + {2881011303685958, 323260022642283, 2392511825935364, 2680218607241472, 2086628284323147}, + {1011041096783712, 1570461284958064, 399516828994561, 1037957371973381, 293292885426852}, + }, + { + {3922699440356983, 4166667378343946, 4637678914861614, 4901406304713256, 5486018227566634}, + {3894750463833161, 836931108663410, 4007195920412586, 1173057924841174, 2662523305285872}, + {2047497366930440, 1249020434696646, 353399299276962, 1824831452522161, 1950016482901783}, + }, + { + {6367491312268994, 5392176809230541, 4683379383522741, 4425977262002237, 5566950871345983}, + {2375227161224824, 2257267128164595, 1056955680380401, 2844088942852363, 1386644755985081}, + {1251794829999036, 1772886866476173, 955066187540246, 1232293719330892, 396636503102089}, + }, + { + {5348918388440793, 5110360065015040, 4585673363095533, 4391593798666572, 4556880644633940}, + {2531431177429893, 1987695830473810, 227622233346307, 1010967397553478, 1341018389661594}, + {83039271672929, 423138535583767, 1183109031328467, 165324254826210, 1340545562288681}, + }, + { + {4651180052187971, 4721139042433965, 4397263424421690, 3818446426246947, 4163799598655846}, + {1971810452973589, 1766684231420693, 299216980507446, 1405770006429853, 3505404036582454}, + {814876839307346, 1973981610718707, 715190907115349, 1240128743335375, 100752655285750}, + }, + }, + { + { + {5917065716904928, 4914443718136124, 5900862973774566, 4911826770493904, 3846361616833057}, + {2439789269177838, 681223515948274, 1933493571072456, 1872921007304880, 2739962177820919}, + {2102170800973153, 719462588665004, 1479649438510153, 1097529543970028, 1302363283777685}, + }, + { + {5650165172926835, 3913771113130458, 4910281332119388, 5068052063776583, 5612709493199633}, + {3193865531532443, 3321113493038208, 2007341951411050, 2322773230131539, 1419433790163705}, + {2214421081775077, 1165671861210569, 1890453018796184, 3556249878661, 442116172656317}, + }, + { + {5118771546583273, 6027449032225062, 3106360274232749, 4318897183975962, 4017125662271289}, + {3005630360306059, 1666955059895018, 1530775289309243, 3371786842789394, 2164156153857579}, + {1094538949313667, 1796592198908825, 870221004284388, 2025558921863561, 1699010892802384}, + }, + { + {3266123011223623, 3120950453625853, 6259609570067094, 3586752371060918, 6048545006453369}, + {1951351290725195, 1916457206844795, 2449824998123274, 1909076887557594, 1938542290318919}, + {764055910920305, 1603590757375439, 146805246592357, 1843313433854297, 954279890114939}, + }, + { + {4578096739917745, 5243693780562643, 3997054445402827, 5231313513873625, 3534834178102174}, + {80113526615731, 764536758732259, 3306939158785481, 2721052465444637, 2869697326116762}, + {525892105991110, 1723776830270342, 1476444848991936, 573789489857760, 133864092632978}, + }, + { + {4567722854714830, 3491727534333040, 3612522797131151, 4726210441025156, 4566029114558485}, + {2794411533877810, 1986812262899320, 1162535242465837, 2733298779828712, 2796400347268869}, + {1793193323953132, 91096687857833, 70945970938921, 2158587638946380, 1537042406482111}, + }, + { + {4644957907857340, 4595035516942998, 5590808199923137, 4081399466208167, 3445106834328894}, + {1895854577604590, 3646695522634664, 1728548428495943, 3392664713925397, 2815445147288308}, + {1611230858525381, 950720175540785, 499589887488610, 2001656988495019, 88977313255908}, + }, + { + {5377566504324214, 5594237977720934, 3960359138874383, 2924144408487157, 5824037597070734}, + {3440880315164906, 2184348804772596, 3292618539427567, 2018318290311833, 1712060030915354}, + {1508590048271766, 1131769479776094, 101550868699323, 428297785557897, 561791648661744}, + }, + { + {4856954879111275, 4243615896786977, 5034997993102829, 5162125577354786, 4490078142041683}, + {432920540217177, 290770592514699, 627484756484379, 3076610223383366, 982836063036305}, + {1857779135539838, 1774848070278290, 1383862392183037, 1948805685118077, 1143607656457264}, + }, + { + {5925968830616980, 5475584226682352, 5076614308992012, 5422447722241084, 4871259074999718}, + {1741735203658460, 2040511596280954, 3245879940788742, 1750904751318660, 1289068422789788}, + {103031326341235, 1843731695283489, 1066974994445109, 1210433521778964, 118970268237578}, + }, + { + {5029675928196841, 3837944199959690, 3856667351331398, 4299101000305422, 4340504849680591}, + {1990983617046169, 3106460878930032, 1275461113767736, 1443049000516840, 1724142301140669}, + {888262946735860, 1859763056800716, 714395964694532, 57820586821189, 354182478325612}, + }, + { + {3800325421725661, 5577357186452733, 3783169523012609, 5425955064608896, 6347571520159237}, + {1658219197861187, 1494360717755939, 1921505970326949, 3049386312266838, 2475279382922093}, + {1290766154788448, 1600589032610209, 784792370088015, 423204440383515, 459184860068298}, + }, + { + {3425205252763663, 5240056527358710, 4140356292677088, 4578393707504979, 5259386798582854}, + {2215101089214073, 1997062079162084, 1249116849924618, 465107085276733, 1293244424458276}, + {880894898454805, 639667973647762, 200272726605326, 297199521205209, 1640420309599773}, + }, + { + {4024399276644653, 4828207338948134, 4459991457755541, 6377452215012324, 4100282940590511}, + {658635179203333, 3717891363165700, 3673816673290121, 2129566854376278, 1443087419989351}, + {1532654097308642, 1958497386525981, 111717506991097, 1708848284574815, 1306115185198907}, + }, + { + {6112399743594082, 4482370964094274, 5295504988778619, 4900443159383520, 4202262340818045}, + {2039429018914652, 3043146685732704, 1364716986897875, 1031303003048000, 1123429638631433}, + {765045651502510, 451621180435426, 15885268584069, 767513226653014, 768056106241896}, + }, + }, + { + { + {4032987623010691, 3949423965177593, 3633193504625235, 4678793759655164, 3734854480100484}, + {3008217384184691, 2489682092917849, 2136263418594015, 1701968045454886, 2955512998822720}, + {2175517777364616, 708781536456029, 955668231122942, 1967557500069555, 2021208005604118}, + }, + { + {3694962906564668, 2643675345331409, 4432646948339879, 4968138170389248, 3845898010522424}, + {3366935780292116, 2476017186636029, 915967306279221, 593866251291540, 2813546907893254}, + {850858855888869, 319436476624586, 327807784938441, 740785849558761, 17128415486016}, + }, + { + {3776976050663564, 5477805104091557, 2545236069347884, 4651869248468534, 4641561625804457}, + {2132756334090048, 2788047633840893, 2300706964962114, 2860273011285942, 3513489358708031}, + {1121075518299410, 2071745529082111, 1265567917414828, 1648196578317805, 496232102750820}, + }, + { + {5158525177930532, 3420610809262104, 2827455773116173, 5409358332231883, 5000374192034028}, + {2374121042985030, 3274721891178932, 2001275453369483, 2017441881607947, 3245005694463250}, + {1954109525779738, 2117022646152485, 338102630417180, 1194140505732026, 107881734943492}, + }, + { + {4610031103869799, 4566082599491057, 6017046282479905, 5310858379140016, 4504138118839608}, + {1714785840001267, 4288299832366837, 1876380234251965, 2056717182974196, 1645855254384642}, + {2002850762893643, 1243624520538135, 1486040410574605, 2184752338181213, 378495998083531}, + }, + { + {4119798625761979, 5219024680951196, 4543568213831910, 4424867828271409, 5157422279171799}, + {922510868424903, 1089502620807680, 402544072617374, 1131446598479839, 1290278588136533}, + {162892278589453, 182585796682149, 75093073137630, 497037941226502, 133871727117371}, + }, + { + {4201115364782060, 3320803158679711, 4190964847185163, 3800027019416103, 4185567469546654}, + {4166396390264918, 1608999621851577, 1987629837704609, 1519655314857977, 1819193753409464}, + {1730519386931635, 1393284965610134, 1597143735726030, 416032382447158, 1429665248828629}, + }, + { + {4551201741097278, 3774114323393256, 2689506075058172, 3065835144123274, 2587730464618792}, + {360275475604546, 2799635544748326, 2467160717872776, 2848446553564254, 2584509464110332}, + {1291597595523886, 1058020588994081, 402837842324045, 1363323695882781, 2105763393033193}, + }, + { + {5895867926878639, 6191714343966274, 3878657686711880, 3772412065246579, 5254560912358513}, + {1828399243003455, 2730967851207580, 2809663501613790, 3291961475373747, 2085819249159773}, + {1604304703501714, 1563946362290690, 2128875205288733, 257625874150601, 2149102916187814}, + }, + { + {5883573429799187, 4805272859062230, 2886195180819460, 4460210052098162, 3528150621150027}, + {1960233741679201, 2996857902780426, 2245274121401778, 4454263006625692, 1110175461750907}, + {1392548583294657, 697289852607029, 746483005053522, 734366559550160, 929768637070953}, + }, + { + {5047299589947009, 4992620901798841, 5716112978503343, 3741839332315327, 4983937719789158}, + {1673816614349955, 3255360796858239, 2753984593405885, 2969035246796379, 2420194805583742}, + {1159863250954626, 1438000622355742, 254045494246044, 1734996482788294, 484539502358623}, + }, + { + {3740619537304301, 4538691700403019, 5325131682689719, 4744914552382795, 3720848390661317}, + {1212935253295623, 2026300849238541, 3447883684227245, 1364910689032303, 3019520894163467}, + {2014517785153097, 1607430272140319, 1855018731367383, 2200629261829065, 987339037980209}, + }, + { + {4426735416351775, 4348191232564971, 5508438055207952, 2420023948055060, 6131298111765032}, + {2763109171958591, 4020627496535071, 3147539030064750, 2177710318971894, 2463269685396658}, + {831460863845953, 1946524324541207, 761958653274011, 1366775091595921, 1187427455457947}, + }, + { + {3125773853625002, 4814913241945202, 4262512130702308, 3321059176595839, 3567623941809388}, + {2822285257464218, 607639870769094, 2857291392676774, 2362021242026611, 3328398883102618}, + {1972329598509655, 34473001166350, 1728817301333588, 1539479676009467, 1694458836743324}, + }, + { + {4805304108915754, 5125985383393506, 5019883131944028, 4580919291870093, 4156575634700942}, + {1575955157633628, 3067048601687650, 2501496271474334, 4193474980184415, 3288209175931426}, + {1442686188453203, 1751694580158105, 824989332883473, 614995267948452, 1497907423783166}, + }, + }, + { + { + {4408790844622027, 4479344310838572, 4120849908116869, 3006675674164362, 4006042157952305}, + {2361321796251793, 3967057562270386, 1112231216891515, 2046641005101484, 2386048970842261}, + {1846089562873800, 98894784984326, 1412430299204844, 171351226625762, 1100604760929008}, + }, + { + {5371908961903233, 6206610140112367, 4204489822423303, 4507924897296559, 4322883368647362}, + {2335972195815721, 2751510784385293, 425749630620777, 1762872794206857, 2864642415813208}, + {523094549451158, 401938899487815, 1407690589076010, 2022387426254453, 158660516411257}, + }, + { + {3975648787468681, 4460622334219928, 3970548136462187, 4226068267807189, 3446012315943388}, + {612867287630009, 2700012425789062, 2823428891104443, 1466796750919375, 1728478129663858}, + {1254114807944608, 977770684047110, 2010756238954993, 1783628927194099, 1525962994408256}, + }, + { + {5270938303411141, 3005889362003651, 3774991859324322, 4939345652492557, 5016292135810879}, + {2484263871921055, 1948628555342433, 1835348780427694, 1031609499437291, 2316271920603621}, + {1255955808701983, 1700487367990941, 1166401238800299, 1175121994891534, 1190934801395380}, + }, + { + {5381119574505877, 4424637839817897, 4775904018594624, 3906943141245230, 5389829033800309}, + {2600943821853521, 1337012557669161, 1475912332999108, 3573418268585706, 2299411105589567}, + {375806028254706, 214463229793940, 572906353144089, 572168269875638, 697556386112979}, + }, + { + {4199915895763317, 4306698118173043, 4456738998669147, 4714126432522633, 3038393400292872}, + {1168827102357825, 823864273033637, 4323338565789945, 788062026895923, 2851378154428610}, + {1915320147894736, 156481169009469, 655050471180417, 592917090415421, 2165897438660879}, + }, + { + {3081796668531198, 4720661405375633, 3938365723488886, 5850548444590341, 6227423178100675}, + {1726336468579724, 1119932070398949, 1929199510967666, 2285718602008207, 1836837863503149}, + {384301494966394, 687038900403062, 2211195391021739, 254684538421383, 1245698430589680}, + }, + { + {3700877198419411, 4541885072828491, 4388337472863078, 4398292814526820, 5228760778493620}, + {1247567493562669, 4229981908141095, 2435671288478202, 806570235643434, 2540261331753164}, + {1201928866368855, 800415690605445, 1703146756828343, 997278587541744, 1858284414104014}, + }, + { + {3752846457602541, 6051774917153047, 3492614771149749, 5278195549012933, 3851678670548516}, + {1251637423994861, 2037585266091733, 1171182249847439, 1503770304884899, 1938920423810268}, + {2232651154426557, 514116965743385, 983369998596377, 1516132019440103, 1692302360068816}, + }, + { + {4860689994687041, 4138464101331517, 4969836424606600, 3370757908330089, 3017690336853320}, + {3753543276036939, 3037198013841237, 3063121586956950, 2967087171212783, 2388800428725970}, + {1485716675407214, 1159619625081800, 197549418633523, 776030397384998, 252064880140599}, + }, + { + {4116450327020509, 4602447751059104, 4624188822504437, 3786392386215792, 4018069243702311}, + {3871066258534097, 182982139320960, 3846997414183091, 1246347657803786, 966334158538299}, + {2049526525941781, 1431983169228179, 3669291297222, 769041933664973, 1760968694339914}, + }, + { + {5411552533375856, 4680723354107633, 5764453140711672, 3663956673248104, 5834177820168369}, + {2029548972200054, 541413050113871, 2564963424993232, 3150712544977872, 2699322542672271}, + {513500031822581, 836561902873502, 82127696349010, 1591221763097659, 725989684331322}, + }, + { + {4424236584915172, 3098952863411429, 2785705377786181, 4107549518995786, 5362683219257666}, + {1071376590195254, 1910139340535847, 1936705400579295, 3523841068963764, 2356086500199738}, + {357287898232758, 1026512116626804, 1875958986125314, 1743551742697910, 1876232951311596}, + }, + { + {4332669232306147, 5882550009365637, 3881970305785489, 6570990168178499, 3489314838073396}, + {294975596735049, 2145292931466411, 3320625656613141, 2284954433570209, 3090254877821144}, + {1234852195927098, 3815763342761, 2085449281682153, 516098044852331, 164426832090235}, + }, + { + {3292223948318582, 4463121371440286, 5163264330075513, 4550237542693388, 4544934760614835}, + {2590122580645644, 1011386629068498, 960875975353535, 3791419723576010, 2273772136048635}, + {1749858954947675, 1561651915395372, 1738700200168191, 397865176422134, 1467025336447738}, + }, + }, + { + { + {3011428551915689, 3264493287961099, 4857379860456993, 4749679688758046, 4282178671364408}, + {2608268623334125, 3034173730618399, 1718002439402869, 3644022065904502, 663171266061950}, + {2040672435071076, 888593182036908, 1298443657189359, 1804780278521327, 354070726137060}, + }, + { + {4711536788361604, 4516566538409613, 5324597415653586, 3262240285890532, 3953172703826057}, + {1894938527423184, 3715012855162525, 2726210319182898, 2499094776718546, 877975941029127}, + {218882774543183, 533427444716285, 1233243976733245, 435054256891319, 1509568989549904}, + }, + { + {4802737216830789, 3846171402668813, 5371658121409568, 4761371218007175, 4056812806828167}, + {4140638349397055, 3303977572025869, 3465353617009382, 2420981822812579, 2715174081801119}, + {1806842755664364, 2098896946025095, 1356630998422878, 1458279806348064, 347755825962072}, + }, + { + {5169106331623846, 4777370102540357, 5302836601573124, 5351928617448052, 4063248596493177}, + {1402334161391744, 3811883484731547, 1008585416617746, 1147797150908892, 1420416683642459}, + {1468412523962641, 771866649897997, 1931766110147832, 799561180078482, 524837559150077}, + }, + { + {5770203524895319, 4659978036228594, 3527448837914025, 4951338033258915, 4756786089433589}, + {2223212657821831, 2882216061048914, 2144451165500327, 3068710944633039, 3276150872095279}, + {2022215964509735, 136144366993649, 1800716593296582, 1193970603800203, 871675847064218}, + }, + { + {5731767721917939, 4837733510733388, 5091167195790575, 4937212217651675, 5106990027743699}, + {1862751661970309, 851596246739884, 1519315554814041, 3794598280232697, 3669775149586767}, + {121893973206505, 1843345804916664, 1703118377384911, 497810164760654, 101150811654673}, + }, + { + {2836122124869624, 4884260866172613, 4618439021898554, 2906882084185319, 4363655839720099}, + {2710146069631716, 2542709749304591, 1452768413850678, 2802722688939463, 1537286854336537}, + {996965581008991, 2148998626477022, 1012273164934654, 1073876063914522, 1688031788934939}, + }, + { + {3949497701489527, 5838943331198768, 5334888242577534, 5453016312620545, 4792359904762516}, + {3175286832534829, 2085106799623354, 2779882615305384, 1606206360876187, 2987706905397772}, + {1419122478109648, 1325574567803701, 602393874111094, 2107893372601700, 1314159682671307}, + }, + { + {4954618339278337, 3422305785425208, 4565328836139485, 3192891441493866, 4836379953614308}, + {855396458506247, 2470294140783466, 4436061492213979, 1754097632720488, 4112391040574456}, + {985511568884890, 583904209238998, 516128993365349, 1235577837475387, 1449904660690748}, + }, + { + {5895940682517746, 4393238442290827, 4244687834629046, 5245476345580864, 4795864303032094}, + {1477173810966796, 3207978347793495, 2656860913951054, 825157489520718, 2782873637674750}, + {12931323257125, 562700432679180, 780577595442459, 440747171628074, 31993258894121}, + }, + { + {5231235667053925, 5090675513104692, 4933657013889560, 5325938777525481, 4583903281916140}, + {2159229926833831, 1114556221271056, 2050697214928106, 2553796628978461, 2874553280901592}, + {1487427059839672, 1966052937474419, 398866894053509, 2040723626090668, 1223074007342359}, + }, + { + {3294796902098517, 3902877656361122, 4227499257540629, 5627711142390550, 5038311124292534}, + {2677874505039557, 678833394869758, 3687464289589147, 1992670845292812, 654778477108270}, + {651854196246431, 2602668557028, 1822678077647200, 2072267608435533, 435243653222236}, + }, + { + {4313218743534013, 3972172746637215, 5399714135650344, 5547659251980199, 4837224811093838}, + {2487053592812311, 2315738098787275, 1210583464083714, 1056644723032111, 781277197910636}, + {864616322745343, 1362699579128647, 1361407419724038, 495664202671974, 662016549521786}, + }, + { + {6154029469581357, 5498138279894180, 3281752713530018, 3501917375982713, 4910547940594210}, + {2672416110637939, 3245298985644332, 1344078619347414, 2037703067415133, 2697812769645364}, + {325041473989085, 842410640177049, 1052993540865892, 2093280369201601, 361408260911216}, + }, + { + {4388597398802075, 4997551911436129, 2851157853262017, 4795345418726848, 4139150667184165}, + {1519253497716003, 3826826078266703, 2262276529333275, 1386373334348474, 3240242941348023}, + {763973845167102, 1151501355459051, 1283654593302800, 584312404348728, 1219116745359281}, + }, + }, + { + { + {5676939182921069, 5322204711648077, 4551121131734783, 5427708347935459, 5239023033125000}, + {2201150872731785, 2180241023425241, 2349463270108411, 1633405770247823, 3100744856129234}, + {830104860549448, 1886653193241086, 1600929509383773, 1475051275443631, 286679780900937}, + }, + { + {4781988283280724, 4990742996470332, 5431361832879221, 4684617167544704, 3868686514426533}, + {3828911108518224, 3282698983453994, 2396700729978777, 4216472406664814, 2820189914640497}, + {1191033906638969, 940823957346562, 1606870843663445, 861684761499847, 658674867251089}, + }, + { + {5126469419668815, 4155719092635613, 4174388435346876, 3772374525285681, 5590700387545135}, + {1875032594195527, 1427106132796197, 2976536204647406, 3153660325729987, 2887068310954007}, + {25465949416618, 1693639527318811, 1526153382657203, 125943137857169, 145276964043999}, + }, + { + {4258045666458167, 5238362362206654, 4758242557133921, 3658013106441212, 2491103563202933}, + {2466539671654587, 920212862967914, 4191701364657517, 3463662605460468, 2336897329405367}, + {1619678837192149, 1919424032779215, 1357391272956794, 1525634040073113, 1310226789796241}, + }, + { + {4248523125120879, 4096142580252307, 5489055327836539, 3417724495086206, 4815108317240624}, + {3292563523447371, 1704449869235351, 2857062884141577, 1998838089036354, 1312142911487502}, + {43173156290518, 2202883069785309, 1137787467085917, 1733636061944606, 1394992037553852}, + }, + { + {4449014387058033, 5297853724611810, 5533789687884231, 2519432329227148, 4292277862887871}, + {670078326344559, 2807454838744604, 2723759199967685, 2141455487356408, 849015953823125}, + {1812516004670529, 1609256702920783, 1706897079364493, 258549904773295, 996051247540686}, + }, + { + {5827060326775227, 5766290385251485, 3123576947163146, 5563678522359472, 3964036703348132}, + {1540374301420565, 1764656898914615, 1810104162020396, 3175608592848336, 2916189887881826}, + {1696163952057966, 1391710137550823, 608793846867416, 1034391509472039, 1780770894075012}, + }, + { + {5101135942842208, 4543974686113080, 4194056217641295, 5689084272866427, 2564466095709391}, + {1367603834210822, 4383788460268472, 890353773628143, 1908908219165595, 2522636708938139}, + {1919411405316294, 1234508526402192, 1066863051997083, 1008444703737597, 1348810787701552}, + }, + { + {4132340278436948, 4005982088010057, 3308609415246807, 3692550296463618, 3956871570338410}, + {1096972188133236, 3816049499915451, 1251976741328773, 1219603529073670, 1078899265206338}, + {950202511700693, 1240039391743494, 1169033682725545, 1423696267961315, 86935143579550}, + }, + { + {4756214981813576, 5522632333569959, 3862983342357100, 4309495274365548, 5713360895956932}, + {2683363149107878, 1470385524874179, 725539084456484, 3271790833618750, 1222340934084308}, + {200587706310533, 896271240996831, 1147839003219597, 673448965331479, 548900916085084}, + }, + { + {3550032568832337, 4838968015489313, 4675889877479625, 3212531632461645, 4765584451232964}, + {1405860849520605, 738725235942165, 399531320766275, 3195580921007755, 1958618144816834}, + {94349687650983, 306368484955948, 1759034073892087, 2030110332880331, 1270749214795711}, + }, + { + {2967631947537871, 4383349957254579, 3922288445505558, 5226885511958431, 3995794596785200}, + {1753118377928377, 3368465588051047, 1755914948419738, 3441455854862245, 647766692547292}, + {2005162920381704, 1507493192705080, 1430523618875617, 131673490468702, 662093487452573}, + }, + { + {2747463689102953, 5007357876041009, 5072033195962826, 4670246809435049, 5673751346141763}, + {2718321167227969, 855141819034537, 1769780985173952, 3439183400564947, 1192259870209089}, + {747964066233340, 2037427400347459, 49693847757217, 2003202980691532, 2230561945728266}, + }, + { + {4747984612298188, 4723422270130357, 4628272886928943, 3839214906514725, 5200339299152060}, + {1424576382204282, 350051250024461, 3895326653518337, 3070821812734749, 3346444741017048}, + {2021002858021100, 839958875652478, 2080082610761570, 1282995787185392, 313106058533657}, + }, + { + {5293324356940491, 3886891387640488, 5386021427475165, 4491415749098830, 3988924707585306}, + {2136145829133251, 713070507515938, 1951333115623761, 3770252317439440, 1824831508473442}, + {2203533335083089, 2130417962449796, 217179607020589, 153498131255469, 1884913426826060}, + }, + }, + { + { + {6357530995067419, 4511707601241201, 4853814131499793, 3027006748267833, 4004117462852039}, + {2102881477513865, 3822074379630609, 1573617900503707, 2270462449417831, 2232324307922097}, + {1417148368003523, 721357181628282, 505725498207811, 373232277872983, 261634707184480}, + }, + { + {3519916180986434, 5063756715513304, 5306226466970938, 4461989750290959, 5633593412950483}, + {2186733281493248, 2250694917008620, 1014829812957440, 2731797975137637, 2335366007561721}, + {615183387352312, 917611676109240, 878893615973325, 978940963313282, 938686890583575}, + }, + { + {4051478965894094, 5415732403270882, 4529567395411473, 4935730075960955, 4778168617632490}, + {522024729211672, 3296859129001056, 1892245413707789, 1907891107684253, 2059998109500714}, + {98698809797682, 2144627600856209, 1907959298569602, 811491302610148, 1262481774981493}, + }, + { + {5721409450692386, 4425747098618406, 6490527463642820, 3639914744810785, 4516285758530664}, + {1791451399743152, 1713538728337276, 2370149810942738, 1882306388849953, 158235232210248}, + {1650875518872272, 1136263858253897, 1732115601395988, 734312880662190, 1252904681142109}, + }, + { + {5306746809205765, 3120741251682392, 2568099116674910, 5447095217001045, 2823024101589818}, + {2624786269799113, 2777230729143418, 2116279931702134, 2753222527273063, 1907002872974924}, + {227742695588364, 1776969298667369, 628602552821802, 457210915378118, 2041906378111140}, + }, + { + {3832015885289562, 4129797318027691, 5360746788631408, 5207122354148972, 4434563787896849}, + {815000523470260, 3164885502413555, 3303859931956420, 1345536665214222, 541623413135555}, + {1870080310923419, 71988220958492, 1783225432016732, 615915287105016, 1035570475990230}, + }, + { + {4881216209018060, 3833780216763759, 5307643745501116, 4286182636729437, 5147443675842680}, + {2982787564515398, 857613889540279, 1083813157271766, 1002817255970169, 1719228484436074}, + {176957326463017, 1573744060478586, 528642225008045, 1816109618372371, 1515140189765006}, + }, + { + {2695191990687280, 4737393024215632, 4451306435997662, 3263658520201184, 3226476650748376}, + {1888911448245718, 3638910709296328, 4176303607751676, 1731539523700948, 2230378382645454}, + {1846351103143623, 1949984838808427, 671247021915253, 1946756846184401, 1929296930380217}, + }, + { + {4257691815043557, 4587099125055339, 4378829326829150, 4530783676112038, 5088169500723328}, + {2633154847819111, 2373317802678415, 4226812651282694, 3531985668346704, 3254298087102270}, + {1896123626988797, 1131351092678624, 1831358114864483, 1263257519094555, 153161823153575}, + }, + { + {5013999188326350, 5342051120597129, 5658875547575315, 4993589587822012, 3418484323529615}, + {2875848054604140, 2609079967536269, 3221396114275243, 1330649045956928, 1828925625187427}, + {85523512650066, 1145743424577874, 270900922559567, 1781500837265517, 1998986005265292}, + }, + { + {4300315009401728, 4620112123771453, 2612760971016545, 3052063778972094, 4706549333122035}, + {2904227921845290, 4267364811643403, 1994336236107343, 2172724361186958, 2854607055726693}, + {2127639189718319, 2205729457048157, 1849555339256920, 1751645797856968, 1883138982486949}, + }, + { + {3989916020510698, 4741941595447558, 5214589701377240, 4351148330446081, 3428672470823222}, + {762600272699964, 2753498328779892, 3316416370655704, 526788695246361, 3062867170941268}, + {1503368613839734, 2009362771486879, 495897391474535, 1905468005297555, 272387388531978}, + }, + { + {5813046901089551, 5050432868964283, 4705275668110217, 4196337029208819, 5257156494192722}, + {1830890930331365, 3828112268992685, 3895633691902557, 3356965264729727, 2386741853982022}, + {995710478389517, 1430833880042694, 1172677663947400, 1545257382741759, 1798260148494462}, + }, + { + {5205850356707429, 4686811868434220, 5616916192509070, 4494846080958018, 5419646380822597}, + {1276458355120913, 2527187906858810, 1130163473530636, 3533175711581762, 2161750040536619}, + {1025062667466023, 43711902086443, 2210112172846377, 233136450830559, 1412931651896051}, + }, + { + {3560341629038503, 4545538003102686, 5283269045082286, 4816839347899222, 4801547130939062}, + {2448047678851139, 599053419172738, 3080495073729726, 1198848441856844, 1359787207816262}, + {555971766815523, 2160228751293088, 266579216919501, 408880354152864, 2184471346102790}, + }, + }, + { + { + {5195617294728737, 5226905206197221, 3889841953548511, 5251818933360801, 4838188827894395}, + {849646212451983, 1410198775302919, 2325567699868943, 1641663456615811, 3014056086137659}, + {22893968530686, 2235758574399251, 1661465835630252, 925707319443452, 1203475116966621}, + }, + { + {3154905071699595, 4930741522303542, 5064786644540271, 4136130058087200, 4165945522107466}, + {3053098849470395, 3985092410411378, 1664508947088595, 2719548934677170, 3899298398220870}, + {1344191060517578, 1960935031767890, 1518838929955259, 1781502350597190, 1564784025565682}, + }, + { + {4168985401048642, 5601942199123232, 4509535428414908, 4252327476037085, 6042239923552064}, + {2925523165433334, 1979969272514922, 3427087126180756, 1187589090978665, 1881897672213940}, + {2495540013192, 678856913479236, 224998292422872, 219635787698590, 1972465269000940}, + }, + { + {4698182657338567, 5017916408838259, 3081477769920918, 3928215500558329, 5313704211766335}, + {271413961212179, 3604851875156899, 2596511104968730, 2014925838520661, 2006221033113941}, + {1980510813313589, 1948645276483975, 152063780665900, 129968026417582, 256984195613935}, + }, + { + {5300264442994823, 3794960652558197, 6004497419208260, 6170915605358895, 5102903504401205}, + {1860190562533083, 1936576191345085, 2712900106391212, 1811043097042829, 3209286562992083}, + {1151480509533204, 2136010406720455, 738796060240027, 319298003765044, 1150614464349587}, + }, + { + {5520821677598445, 4505587343518853, 4486119403320947, 5124882310463887, 4384352945448272}, + {1731069268103131, 2987442261301335, 1364750481334267, 2669032653668119, 3178908082812908}, + {1567828528453324, 1017807205202360, 565295260895298, 829541698429100, 307243822276582}, + }, + { + {4341766796632437, 4105940157601428, 4403780572905254, 4391581105946996, 4661670073235412}, + {249079270936229, 1501514259790706, 3199709537890096, 944551802437486, 2804458577667728}, + {1338766321464554, 1906702607371284, 1519569445519894, 115384726262267, 1393058953390992}, + }, + { + {4136644411018817, 5105079697639574, 5123803130450031, 3331327213803161, 3453876506817262}, + {3616421371950629, 3764188048593604, 1926731583198685, 2041482526432505, 3172200936019022}, + {840922919763324, 727955812569642, 1303406629750194, 522898432152867, 294161410441865}, + }, + { + {5565570118069330, 4591619629413879, 3505524267391659, 5911065393515679, 5626780252302286}, + {2954349327665336, 2875421537282295, 1177907047549607, 2315244756624323, 3303388475971642}, + {1193532613439179, 1341357357703238, 1857522674746129, 587336359047056, 1462817734082691}, + }, + { + {5032608083579310, 5556680383291862, 4639031978972564, 2550751933150061, 4661900946642239}, + {981709001326388, 2228829982452486, 1195252744174570, 1961335123791201, 473922585791741}, + {158547452916311, 1806851940249257, 1888549274109445, 1234535032385844, 755999937979748}, + }, + { + {5099505633219587, 3654947652195304, 4632839805758299, 3516983533390311, 3156502843280841}, + {2235936902666817, 1844821659342916, 4255944160143733, 2705728103151199, 1360010073190141}, + {1966276380904262, 1243659846916250, 1230287549611464, 1790496592504769, 385075881855087}, + }, + { + {5102974111125320, 5352605641984611, 4254853167292498, 4166876022626639, 4692858050734664}, + {808958715657412, 2787760179369277, 2812754371047796, 3109195163271007, 3174221799565416}, + {1970356456788069, 1887106101566224, 2120741856788965, 1887465058487327, 166078852378175}, + }, + { + {5268074145727905, 3102961204581063, 5775739741243707, 6623549226998551, 5355512520264473}, + {1475882426726637, 2923995069592105, 2595116660588037, 2134573872614909, 2857982748479313}, + {957649428811476, 1521919451665798, 1487878569331559, 1715152263604455, 2000934618350472}, + }, + { + {3462276468747197, 4403243110229213, 5274708467449337, 4946143993185919, 6100123938510411}, + {2624197675552195, 2160845895419703, 991891416996825, 2705836223851003, 2307139020684469}, + {231885416467149, 648441606302746, 1371491506634443, 193373311482025, 2106953050161716}, + }, + { + {2408565470230034, 4633147941257550, 4425551739809483, 4183865634168848, 4784444305258783}, + {2307403528152576, 3136574081495182, 3694424861021853, 1950918571001278, 1747697954472435}, + {931185174846608, 872635055344100, 1155298897916392, 1344438153479985, 863698029056587}, + }, + }, + { + { + {2611656183523465, 4684513982859178, 5365326100017121, 4722407564633480, 2827426586917747}, + {2605560604520539, 1598361541848742, 3374705511887547, 4174333403844152, 2670907514351827}, + {755467689082474, 909202735047934, 730078068932500, 936309075711518, 2007798262842972}, + }, + { + {3236138991462016, 3067527600191131, 3896954399398994, 3910874778063800, 3938401465669403}, + {1609384177904054, 2614544999293875, 1335318541768200, 3052765584121496, 2799677792952659}, + {1697863093781930, 599794399429786, 1104556219769607, 830560774794755, 12812858601017}, + }, + { + {4108730476499120, 5181690479373092, 4171978954440413, 3511327647445115, 4559140599266006}, + {1168737550514982, 897832437380552, 463140296333799, 2554364413707795, 2008360505135500}, + {1158643631044921, 476554103621892, 178447851439725, 1305025542653569, 103433927680625}, + }, + { + {3077203098880308, 4396008401246031, 4177351818329890, 6418777467377480, 5519551756318358}, + {2176793111709008, 3828525530035639, 2009350167273522, 2012390194631546, 2125297410909580}, + {1807108316634472, 1534392066433717, 347342975407218, 1153820745616376, 7375003497471}, + }, + { + {4732167545780233, 5368693586150714, 2609883700135802, 4663217517029815, 3612437739977844}, + {3234860815484973, 2683011703586488, 2201903782961092, 3069193724749589, 2214616493042166}, + {234147501399755, 2229469128637390, 2175289352258889, 1397401514549353, 1885288963089922}, + }, + { + {5617390325210756, 5554766767336738, 5549530285921438, 6514965868913137, 3937966638306001}, + {3363562226636810, 2504649386192636, 3300514047508588, 2397910909286693, 1237505378776769}, + {1054097349305049, 1872495070333352, 182121071220717, 1064378906787311, 100273572924182}, + }, + { + {4607833422014698, 3800719604873494, 4476341726952553, 4306709190801725, 3295603202700400}, + {3558210666856834, 1627717417672446, 2302783034773665, 1109249951172249, 3122001602766640}, + {216762189468802, 707284285441622, 190678557969733, 973969342604308, 1403009538434867}, + }, + { + {4847405480488793, 3554016671099447, 2818672356908788, 4302938753224251, 4825028485754775}, + {3530824104723725, 2596576648903557, 2525521909702446, 4086000250496689, 634517197663803}, + {470067171324852, 1618629234173951, 2000092177515639, 7307679772789, 1117521120249968}, + }, + { + {4032307292940140, 4855742012511787, 4007061004220393, 4186026976205829, 5188147460015837}, + {1726290253928048, 2108179153379055, 3599306339052623, 3804322907336713, 740669388116407}, + {1893601910775915, 1893561171028788, 174914675480509, 2073460144115735, 250678301747773}, + }, + { + {5696478198308385, 3135077959467853, 5039986204304988, 5696739636381970, 5163380137461980}, + {1473356281060031, 1850501243620073, 559809451272168, 2164039335364390, 2799937740729438}, + {506406583155327, 1903499899096002, 445887262445598, 866962765497367, 55809365421254}, + }, + { + {5290224396694939, 4705669579710662, 4614921349557141, 5027610124814334, 5088773866023979}, + {2009707214072007, 3490160897828618, 275706542492147, 1283471147003836, 2026672645131195}, + {1123457689056584, 2213608670005209, 1379370540202855, 2074314852377531, 864461310144552}, + }, + { + {5111150460891680, 4275734012505621, 4206718452855061, 3888755110807716, 5005016151412877}, + {2967787444233740, 1413004988964951, 690605351712577, 3813861694171786, 728516486273669}, + {2016155040846069, 1480238949730910, 882386999623863, 1367342654128568, 589184047321896}, + }, + { + {3850772783035735, 4143292076634522, 5556861502206409, 4279143658707597, 3550043180479289}, + {3493927566017921, 3571431901909570, 2627286406743953, 2047641118374561, 1730233493072697}, + {272317805124786, 1812925138663726, 1217316351219782, 1182300795957412, 1252963393607199}, + }, + { + {5371799854215572, 3393967588858477, 5067027508227680, 3852577519740789, 4734905175716170}, + {3515527020405104, 2159318542704715, 1058260913419646, 2981918447395233, 1340478002453928}, + {896362445577855, 1547885531466434, 942263962614365, 1148475609702329, 2122889133222112}, + }, + { + {5312477093520487, 3952229351525915, 5253212242457428, 4756871683292235, 4134773488559657}, + {2735014629385533, 1581591485505255, 1720528958990566, 4161950575359359, 2332085424554487}, + {704970088806441, 1168889861388831, 354811087636935, 1536113135588939, 2212112893107236}, + }, + }, + { + { + {2828809211088312, 6295039889156786, 4429443549656884, 4678145777282455, 5916104705152820}, + {2529951391976704, 1810282338562946, 1771599529530998, 3635459223356879, 2937173228157088}, + {893719721537457, 1201282458018197, 1522349501711173, 58011597740583, 1130406465887139}, + }, + { + {4766083398225008, 5494110682478710, 2778685366456944, 2823464210331405, 4857685817649218}, + {412607348255434, 1280455764199780, 2233277987330768, 2265979894086913, 2583384512102412}, + {1820352417585487, 24495617171480, 1547899057533253, 10041836186225, 480457105094042}, + }, + { + {5647768329980203, 5108044017780681, 3796340935441384, 4177115363811274, 5130001056264497}, + {2023310314989233, 2889705151211129, 2106474638900686, 2809620524769320, 1687858215057825}, + {1922168257351784, 2018674099908659, 1776454117494445, 956539191509034, 36031129147635}, + }, + { + {4561842048916374, 4287612509327089, 4370291679808170, 5695284091186768, 4550521144824593}, + {2796444352433270, 1039872944430373, 3128550222815858, 2962457525011798, 3468752501170219}, + {272268252444639, 1374166457774292, 2230115177009552, 1053149803909880, 1354288411641016}, + }, + { + {5697036697171416, 5404706777075284, 5503272547981905, 4981184452172701, 4867839206068339}, + {1857910905368338, 1754729879288912, 3137745277795125, 1516096106802165, 1602902393369811}, + {886299989548838, 1538292895758047, 1590564179491896, 1944527126709657, 837344427345298}, + }, + { + {3561647617580592, 3713951676498321, 4714970494042065, 3796394966388927, 5531291426324585}, + {3006358179063534, 1712186480903617, 3955456640022779, 3002110732175033, 2770795853936147}, + {803217563745370, 1884799722343599, 1357706345069218, 2244955901722095, 730869460037413}, + }, + { + {5199950995983500, 5997984878609744, 5241636760987426, 5139985135222038, 5431082849981900}, + {2941099284981214, 1831210565161070, 3626987155270686, 3358084791231418, 1893781834054268}, + {1949114198209333, 1104419699537997, 783495707664463, 1747473107602770, 2002634765788641}, + }, + { + {3320700462489453, 4258691810757797, 5637648896716044, 3890560459865337, 4307195898311025}, + {1607325776830197, 2782683755100581, 1451089452727894, 3833490970768671, 496100432831153}, + {2222475519314561, 1870703901472013, 1884051508440561, 1344072275216753, 1318025677799069}, + }, + { + {4037612142179094, 2987286320918074, 5334840876971305, 3892287190264789, 5794263680951471}, + {471926402845486, 2814813543274642, 3620200888572759, 1728489506884653, 3177161343196207}, + {1819395223745913, 594758877920007, 1653753349717506, 242640844960873, 963869472910932}, + }, + { + {2936569169465705, 6049214516933086, 5963733906800640, 4231427100807371, 4853047066834829}, + {2548596925868729, 2662135700065828, 2088163736824992, 2331981460676031, 2771125203890139}, + {780634400476978, 637764048158951, 901014587909154, 1354805333992459, 2018934308296179}, + }, + { + {2797688906622325, 3428210403110380, 5022584852934687, 3295825468273441, 5705393166486691}, + {2111199241475135, 1851629318616336, 1992578166276991, 2095428925801999, 1218266125748465}, + {1810680242312559, 952287178947563, 681241246062059, 1252456339225424, 1959931529139639}, + }, + { + {4919536354167776, 4843044804249283, 4705930511557457, 5262690042745614, 4386984625976838}, + {3747081830160208, 1520760409479969, 1598412209810121, 1654404133831532, 437659257098574}, + {744124236937047, 1544378156616778, 715829909389559, 2120659842894185, 72002654880101}, + }, + { + {4563826663843359, 5185090504058247, 5145727029702249, 5011944329783380, 5313803489832094}, + {244278499662023, 2000287644883357, 3512120660608951, 1998820466139820, 2107051881706162}, + {1061541907539207, 1129143356143074, 459133314948729, 1177985907118634, 1224368687812524}, + }, + { + {3152842550820126, 4081984728409524, 3254259750651619, 4604329179757860, 4471438744025494}, + {2383716445654654, 2845501105364248, 3179274641918483, 2181012191586748, 4055424112922904}, + {1792270341351139, 2065266134997868, 51895527839218, 798734893906822, 992253836606399}, + }, + { + {4950351600164207, 5298895157252043, 5150281689404603, 4544152582549862, 5356669996354042}, + {1927020266981541, 1747143248428675, 1588706088137551, 1077596294054796, 1170976366872068}, + {1001666581039191, 1742276948383877, 1379478310433234, 767654427573973, 2047968425937961}, + }, + }, + { + { + {4511412834337187, 4698043828798044, 4323205223211753, 5569204703546807, 6149086417101785}, + {155711679280637, 681100400509288, 389811735211209, 2135723811340709, 2660533024889373}, + {16625790644959, 1647648827778410, 1579910185572704, 436452271048548, 121070048451050}, + }, + { + {4694164895067901, 2924655519713304, 4842396181739721, 4841286895864398, 5356846476062228}, + {3289062842237779, 2820185594063076, 2549752917829677, 3810384325616458, 2238221839292470}, + {1763863028400139, 766498079432444, 1321118624818005, 69494294452268, 858786744165651}, + }, + { + {4869852729848717, 5029275869879305, 3701410808950684, 3435100659007430, 4689559933862040}, + {3543856582248253, 1456632109855637, 3352431060735432, 1386133165675320, 3484698163879000}, + {28315355815982, 460422265558930, 1799675876678724, 1969256312504498, 1051823843138725}, + }, + { + {4558284163736209, 4461809852221468, 5698584425525803, 5038838655144199, 3768154892986607}, + {2408714813047231, 3857948219405196, 1665208410108429, 2569443092377519, 1383783705665319}, + {1484387703771650, 198537510937949, 2186282186359116, 617687444857508, 647477376402122}, + }, + { + {4662985813836019, 4129426407048187, 5122336824431007, 5530273911701301, 3409921574477931}, + {2147715541830533, 2751832352131065, 2898179830570073, 2604027669016369, 1488268620408051}, + {1744544377739822, 1964054180355661, 1685781755873170, 2169740670377448, 1286112621104591}, + }, + { + {3854053602374273, 4943141672260381, 4472148111349729, 5161477038123364, 4661051199882732}, + {2333777063470241, 3919742931398333, 3920783633320113, 1605016835177614, 1353960708075544}, + {1029287186166717, 65860128430192, 525298368814832, 1491902500801986, 1461064796385400}, + }, + { + {3437283298068479, 3608139386273800, 5088531994686943, 4605732407316964, 6296522248487285}, + {2660016802414475, 2121095722306988, 913562102267595, 1879708920318308, 2492861262121979}, + {1966196870701923, 2230044620318636, 1425982460745905, 261167817826569, 46517743394330}, + }, + { + {6233793835087996, 4935389669690266, 6335114860649961, 3623880366453827, 5578113556752255}, + {2358877405280588, 3136759755857592, 2279106683482647, 2224911448949389, 3216151871930471}, + {1450880638731607, 1019861580989005, 1229729455116861, 1174945729836143, 826083146840706}, + }, + { + {3994140066248694, 3181522224560048, 3364322700715335, 6108496090134019, 4266308196944062}, + {978398934730796, 1804963209584982, 2902083217855803, 2011728779166715, 3070976799182328}, + {494691910923538, 1903565874798025, 2115181773831520, 2000771501496645, 2163753695162256}, + }, + { + {4499039401984510, 2919282610904813, 3371698570925682, 3170519001059914, 5250127479378489}, + {1654039515014884, 2484661430680993, 2620692000541228, 2669599656280070, 2398652280696967}, + {2019971150480802, 2112841493625261, 237154577131804, 1674207955014809, 1389703158284583}, + }, + { + {4706814366157303, 5336609175411517, 4757963599977030, 4060364649415927, 3640669095240911}, + {780624938414169, 3404608320205059, 1982958325444026, 3570514777233615, 984254926012775}, + {1463658959517057, 1983397723547684, 41055560978805, 424638764130418, 491755157953272}, + }, + { + {3257295355011901, 4096776962011503, 4487597369409850, 5876979850901767, 6030505591690325}, + {2935104701953453, 3989681641092319, 3306366339882358, 2374391350196501, 1896075761392399}, + {1262337399368722, 1039133447611747, 917288766852537, 1931663063827599, 386956994697158}, + }, + { + {5865485955051801, 4898975626365390, 5709055439582716, 3072783210395629, 4352817622936409}, + {2724577252043037, 1050316213165918, 2370342271552724, 2792859709284319, 2760145987712013}, + {1677351910521822, 152891770438727, 738510373109788, 1296476386064424, 1219545250565005}, + }, + { + {2955221061271345, 5973180148171190, 3740903689178612, 4255579446112404, 4178816467357894}, + {1908022307626643, 2469819122662084, 1583327987932656, 3442462106139746, 599498145240366}, + {220308000962909, 460573332431611, 732078470162760, 467340602781483, 1127652895548970}, + }, + { + {4256843681823156, 4695170685669586, 4012905106498514, 5492595949894092, 4822219141250098}, + {1289113762003406, 2808167474320130, 1666802361626320, 1051654028271354, 1724653376239634}, + {1695390634076771, 1517610099990508, 1248456812719894, 2178282202616225, 905038523003109}, + }, + }, + { + { + {4388488268525257, 4351308814649541, 3942600308931722, 3469443492260723, 3080520458769465}, + {1899935429242705, 1602068751520477, 940583196550370, 2334230882739107, 1540863155745695}, + {765548025667841, 462473984016099, 998061409979798, 546353034089527, 2212508972466858}, + }, + { + {6305035755313584, 3986236631593136, 5772327717715563, 4670602724441205, 4485397579520202}, + {2298375097456408, 3144370785258318, 1281983193144089, 1491520128287375, 75847005908304}, + {1997562060465113, 1048700225534011, 7615603985628, 1855310849546841, 2242557647635213}, + }, + { + {3608844722049986, 2980930458947685, 6266068700289474, 3617433430563704, 4684882533775436}, + {1161017320376250, 2744424393854291, 2169815802355236, 3228296595417790, 1770879511019628}, + {1080413443139865, 1155205815510486, 1848782073549786, 622566975152580, 124965574467971}, + }, + { + {4272336182688229, 4705861119105631, 3304969482836130, 4308331792957791, 5281765142064806}, + {1184526762066993, 247622751762817, 2943928830891604, 3071818503097743, 2188697339828084}, + {237404399610207, 1308324858405118, 1229680749538400, 720131409105291, 1958958863624906}, + }, + { + {4785126936528543, 2288770346086770, 3118706734562790, 4474082416637981, 5793198356960377}, + {2767383321724075, 2269456792542436, 1717918437373988, 1568052070792483, 2298775616809171}, + {1278207464902042, 494742455008756, 1262082121427081, 1577236621659884, 1888786707293291}, + }, + { + {4316050955753838, 6170021230760201, 3671071179000687, 2720567588588102, 4695134757737078}, + {353042527954210, 1830056151907359, 1111731275799225, 2426760769524072, 404312815582674}, + {1716987058588002, 1859366439773457, 1767194234188234, 64476199777924, 1117233614485261}, + }, + { + {4802445580021739, 5669686216323056, 5683496153608928, 3599612573083939, 3664745203781455}, + {3236091949205521, 2386938060636506, 2220652137473166, 1722843421165029, 2442282371698157}, + {1143239552672925, 906436640714209, 2177000572812152, 2075299936108548, 325186347798433}, + }, + { + {4921698295511420, 2966865811406529, 3723715952061302, 4420370150973604, 5441412310007539}, + {2972824668060020, 2936287674948563, 3625238557779406, 2193186935276994, 1387043709851261}, + {1043584187226485, 2143395746619356, 2209558562919611, 482427979307092, 847556718384018}, + }, + { + {6539978005364395, 5005405360675302, 4390281321854973, 5817765520609028, 2885569505406129}, + {2401607320460403, 912267207660896, 2797776548107885, 1401692837350636, 2770414290856347}, + {904627574235583, 366582160013268, 1919276459982818, 683852563070972, 849013528013132}, + }, + { + {4382884022719489, 3331418080941236, 4472875449005139, 4019500438389598, 4463034067898545}, + {314313360314847, 1556311374160012, 3420403310565817, 1814168775579274, 3865931899404825}, + {2211811396782717, 1987727116500422, 1201194143426517, 1988979712261853, 884086138400803}, + }, + { + {3928195125806252, 4506628847593763, 4871806493038737, 5468133301160088, 4718975813247195}, + {3157237349544610, 2087027997220233, 1635119994381095, 1685873597006198, 3264645977099821}, + {554990822829571, 1043610604169755, 239155874009083, 1207029530220679, 1248980877883503}, + }, + { + {2330609380614712, 5282631639681642, 3679411410269759, 2770673432637308, 3778717181908177}, + {2321085204756486, 3204498878947842, 1897195179818497, 2221896934640248, 2249233024322127}, + {1100828805329651, 38323682820671, 233339076341529, 570439134676859, 373923102906827}, + }, + { + {4822469807205745, 4578534577854527, 3814578293772758, 6210971875752572, 3469875307698085}, + {650556138336187, 1140806781381529, 1319490550148986, 2443218412602398, 2092597895198457}, + {24874372349398, 672413878008022, 2109618619032869, 617580455983017, 643082448965145}, + }, + { + {3702942502950483, 4221261673998955, 4525315300848625, 5031967728773077, 4411934662665867}, + {895116466708821, 2311360532554913, 1331906084934491, 1442649827370867, 985339602059253}, + {1101806460504208, 48906420814555, 455540794156723, 777238833441277, 678815750013174}, + }, + { + {4956217544664282, 4411017504484405, 3654474138314413, 5155000128389593, 4413650344518487}, + {1203258470211606, 2883266356628027, 1508156827359997, 3638270983429361, 1401834110583505}, + {928961391578986, 832907369443124, 468987297840672, 1558723144077997, 1418280592841651}, + }, + }, + { + { + {3309129437554730, 5123933694799617, 4965300486638528, 6516081243872351, 2549068382794184}, + {1248731221520740, 1465200936117687, 2792603306395388, 2304778448366139, 2513234303861356}, + {1055352180870759, 1553151421852298, 1510903185371259, 1470458349428097, 1226259419062731}, + }, + { + {4550600281784187, 3256554237859110, 4119844627242950, 4676836561429904, 5092370827107509}, + {3744788603986897, 3042126439258578, 3441906842094992, 3641194565844440, 3872208010289441}, + {30498470091663, 1082245510489825, 576771653181956, 806509986132686, 1317634017056939}, + }, + { + {5619235959382811, 4106140804649401, 4587392324740009, 4223977265679267, 2709254929742834}, + {2672107869436803, 3745154677001249, 2417006535213335, 4136645508605033, 2065456951573058}, + {1698968457310898, 1435137169051090, 1083661677032510, 938363267483709, 340103887207182}, + }, + { + {4745319008032005, 4813628148687644, 3467681137065440, 3660014790178871, 4392941970152610}, + {1995325341336555, 911500251774648, 2415810569088940, 855378419194761, 3825401211214090}, + {1315157046163473, 727368447885818, 1363466668108618, 1668921439990361, 1398483384337907}, + }, + { + {6557196758364187, 4276231499541578, 4485350770690107, 4264207089194792, 3124346806789687}, + {2326829491984875, 3267188020145720, 1849729037055211, 4191614430138232, 2696204044080201}, + {1217269667678610, 599909351968693, 1390077048548598, 1471879360694802, 739586172317596}, + }, + { + {4384302481090479, 4717978973545909, 3754548127453306, 4211871514743047, 3605771636328385}, + {3970118453066023, 1560510726633957, 3156262694845170, 1418028351780051, 2346204163137185}, + {319394212043702, 2127459436033571, 717646691535162, 663366796076914, 318459064945314}, + }, + { + {3198885719919217, 2575084544179354, 3737578377662447, 5232176448882889, 5405183975072780}, + {2657789238608841, 1960452633787082, 2919148848086913, 3744474074452359, 1451061489880786}, + {1575783124125742, 2126210792434375, 1569430791264065, 1402582372904727, 1891780248341114}, + }, + { + {5242752265626106, 4326735213088803, 5009083294116390, 3863683170199334, 2880454449080125}, + {3090232019245924, 4249503325136911, 3270591693593114, 1662001808174330, 2330127946643001}, + {1822054032121349, 643057948186973, 7306757352712, 577249257962099, 284735863382083}, + }, + { + {3757294655239106, 4149870483813681, 3943074023634421, 5011331412913659, 4204233544524725}, + {765300458944758, 1962420935223063, 1006865922596525, 556125259357651, 517324314261719}, + {947503289917657, 1503416272497360, 836151367440855, 2025240512839119, 1506056841382176}, + }, + { + {3987605469554571, 4216854847559852, 4606485208582710, 4025002076531210, 5771502720173311}, + {789866795586711, 1219783998007690, 3399339961859034, 1430246873258510, 2263938746297911}, + {272907227620417, 585056874977936, 374400386458564, 1047259762290717, 466584497787787}, + }, + { + {4513305810099276, 3713543936920641, 5881885803512264, 4985359422621344, 5854329220017841}, + {2489594831593530, 2868670421452777, 2653264259914146, 778139640543916, 2896054888052141}, + {67965761977879, 1140658137927248, 1433664110101982, 1907417172350895, 1009746387131234}, + }, + { + {4657525718512496, 4017020332264511, 5032007516852528, 4196574218153666, 4558814287479470}, + {3191788312902362, 1662632170533261, 3849731434302862, 816384760006536, 2103376627071646}, + {98516339668203, 1987095201806236, 109825731538912, 249333174781555, 868887613476084}, + }, + { + {4551570896172554, 4811478172541458, 3661911804185849, 2859956435208139, 3775782540863495}, + {4251836217943410, 1527544805122594, 1416199226269029, 2604023934400523, 2761395386595757}, + {1642831683324706, 1693640639567753, 543897185448748, 1014750779914025, 2000933536049400}, + }, + { + {5616692888384001, 4085181778999311, 5359480780192985, 4168165762634953, 3706985665716275}, + {3046363118074651, 1033878254661623, 1432711896868579, 565399048183279, 1486610644259929}, + {1956000744629083, 2124722115672587, 1869890027060221, 1779425010763214, 2251549887150752}, + }, + { + {5403435201118585, 6603374055023538, 4448450050924979, 4204020352279014, 3319690980306662}, + {1147686993699695, 2183664403489392, 3736291649220767, 3475178747642004, 1656820196694734}, + {993108364179144, 45592857828226, 1223718961690034, 1931120528549047, 1402978202475587}, + }, + }, + { + { + {4707745854342560, 3882311012719969, 4467035027860010, 2426465723968789, 5459727301387711}, + {3618358370049178, 1448606567552085, 3730680834630016, 2417602993041145, 1115718458123497}, + {1562934578796716, 1070893489712745, 11324610642270, 958989751581897, 2172552325473805}, + }, + { + {2875482372335866, 3589666323156759, 5493912977577144, 3566036429447715, 3416572787955522}, + {1770564423056008, 2987323445349813, 1326060113795288, 1509650369341127, 2317692235267932}, + {223256821462517, 723690150104139, 1000261663630601, 933280913953265, 254872671543046}, + }, + { + {5739703102637456, 4089685696952464, 5529672212600950, 5529465141325467, 4053764715117380}, + {1969087237026022, 2876595539132372, 1335555107635968, 2069986355593023, 3963899963027150}, + {1115241013365517, 1712251818829143, 2148864332502771, 2096001471438138, 2235017246626125}, + }, + { + {4621952399709001, 5571208339175198, 5938396303563992, 3935039984233637, 4734466397277932}, + {3551068012286861, 2047148477845620, 2165648650132450, 1612539282026145, 2765997725314138}, + {1850689576796636, 1601590730430274, 1139674615958142, 1954384401440257, 76039205311}, + }, + { + {4398511437540326, 5006878555391994, 2877652875936652, 3360921192078354, 5537453437282356}, + {1723387471374172, 3249101280723658, 2785727448808904, 2272728458379212, 1756575222802512}, + {571005965509422, 2005213373292546, 1016697270349626, 56607856974274, 914438579435146}, + }, + { + {4021767746362864, 3947693133441663, 5655463017046415, 4032842598082935, 4903887401788780}, + {1346698876211176, 2076651707527589, 3336561384795453, 2517134292513653, 1068954492309670}, + {1851867764003121, 403841933237558, 820549523771987, 761292590207581, 1743735048551143}, + }, + { + {4789545034251916, 5151774024717947, 3350203576317227, 5870147068473486, 3757676696824463}, + {410915148140008, 2107072311871739, 3256167275561751, 2351484709082008, 1180818713503223}, + {672095903120153, 1675918957959872, 636236529315028, 1569297300327696, 2164144194785875}, + }, + { + {3867157095427632, 4907857238986876, 4412001163466224, 5664547006559450, 3829838433234787}, + {1902708175321798, 3287143344600686, 1178560808893262, 2552895497743394, 1280977479761117}, + {2013087639791217, 822734930507457, 1785668418619014, 1668650702946164, 389450875221715}, + }, + { + {5139170412209073, 4498594321446990, 3403045096731472, 3523999116931205, 4892973820656308}, + {3100339582931283, 3780065035763732, 3107854667684806, 1176538847728659, 2470425204007084}, + {1439699951361262, 2030141811121675, 1327540074439450, 98760879510567, 2124055188161162}, + }, + { + {5069757928527025, 4269771696870248, 3491008216607494, 2929486207919899, 2963259194922213}, + {1719771161855965, 3899474813414394, 1311077187368436, 1710977333891379, 2936225820601205}, + {630007537003875, 1879755431232807, 1841434412649072, 139825159320909, 1444684178970403}, + }, + { + {4165024628959566, 3986473160684857, 4482720357638229, 3477188964410991, 6063532098390286}, + {2735367442263082, 3037388464741161, 708840305892227, 3376016746983163, 2424461132835430}, + {1692345998026512, 1336264953003836, 472200476738834, 443198297543894, 865332172690922}, + }, + { + {3583240374232032, 6672838339902029, 3302719127491245, 4817707424315947, 3846209753841235}, + {1940518928195986, 2204192709398575, 2559878786338619, 1240694154295451, 3150360999940643}, + {978334155462452, 259156758770697, 1998397384612038, 868981902819036, 526720567050341}, + }, + { + {6295419175112392, 5922842429035919, 3280130237310527, 6154864010584464, 4672381744259604}, + {2495384380697450, 2529087473815087, 3152074437283087, 2705660594301054, 3756859018180124}, + {2829664309620, 1216345963700610, 1352213880784545, 1343440385603407, 1678896558555000}, + }, + { + {4462327178876654, 4861692839162759, 4026088282699843, 4559864737475196, 4141921357362458}, + {970323584385428, 1841886145157987, 771455069751873, 2995416444511372, 1381697279273918}, + {833881464516252, 722547189080954, 1385674139934263, 1947516117258013, 237073770273705}, + }, + { + {4933913084823421, 4670123363141682, 4900446203904881, 4055286352327374, 4290448492223496}, + {2942776662601173, 2578009269314716, 544737250664645, 2975699597442162, 2099680134205576}, + {452946908538500, 838029561099231, 448300214621162, 402872419278705, 704999550269611}, + }, + }, + { + { + {5798682425720784, 4343644325181242, 6354948599958312, 4506974667055090, 5293040366083331}, + {2705718263383616, 2358206633614248, 2072540975937134, 308588860670238, 1304394580755385}, + {2083069137186154, 848523102004566, 993982213589257, 1405313299916317, 1532824818698468}, + }, + { + {4034211192773531, 5600324567335276, 4531193018091912, 2794041663976599, 3792137612125120}, + {3747761112537659, 1397203457344778, 4026750030752190, 2391102557240943, 2318403398028034}, + {693543956581437, 171507720360750, 1557908942697227, 1074697073443438, 1104093109037196}, + }, + { + {4735029189573542, 3778090050106418, 6524974691396918, 6024554123028535, 3058137605210362}, + {345288228393400, 3351443383432420, 2386681722088990, 1740551994106739, 2500011992985018}, + {1079623667189886, 872403650198613, 766894200588288, 2163700860774109, 2023464507911816}, + }, + { + {3748938635589832, 3296620064200837, 3994393700108731, 5740803740117332, 5352647078187481}, + {854645372543796, 1936406001954827, 2403260476226501, 3077125552956802, 1554306377287555}, + {667962773375330, 1897271816877105, 1399712621683474, 1143302161683099, 2081798441209593}, + }, + { + {3324209478486170, 4398737310762775, 3760579922605898, 5439367229755348, 5616400060914562}, + {2378947665252234, 1936114012888109, 1704424366552046, 3108474694401560, 2968403435020606}, + {333549023751292, 280219272863308, 2104176666454852, 1036466864875785, 536135186520207}, + }, + { + {5689714689958878, 4503409610653732, 5602544085249448, 3404912574886620, 4043425317102514}, + {2625466093568366, 2398257055215356, 2555916080813104, 2667888562832962, 3510376944868638}, + {1870078460219737, 2129630962183380, 852283639691142, 292865602592851, 401904317342226}, + }, + { + {3798100817109506, 4962694127433334, 3349468332060557, 6283897397500138, 2972563107372854}, + {1361070124828016, 815664541425524, 3278598711049919, 1951790935390646, 2807674705520038}, + {1212405311403990, 1536693382542438, 61028431067459, 1863929423417129, 1223219538638038}, + }, + { + {4842650611581872, 5104986353880267, 4917334859504562, 3217991068822474, 6343075526828654}, + {1294303766540260, 3435357279640341, 3134071170918340, 2315654383110622, 2213283684565086}, + {235605972169408, 2174055643032978, 1538335001838863, 1281866796917192, 1815940222628465}, + }, + { + {6283914285320299, 4538885684827819, 5272821644392905, 4741145486323262, 3695595414404375}, + {2328903345630831, 383243669352281, 873975569357849, 1167517986625404, 1819176154401511}, + {1015569285123052, 366271559910559, 607712860974980, 1151136439806917, 1092279314442070}, + }, + { + {4644837603275095, 4182486257496369, 5680847280055574, 5281364304268108, 4017310458808244}, + {608363524539665, 1518910856395189, 2487752246555640, 1408491254860196, 1242950972146918}, + {724510145626490, 1990648995683735, 1234513756420164, 776971151906420, 1819715569230741}, + }, + { + {4025210576522653, 5037391877366464, 6220723743247171, 4107687904850403, 5536810198272054}, + {1367586897505451, 2009604536185136, 2660752171350541, 2665866783498593, 3368014404783418}, + {1205287993924177, 1639266049462139, 1103796806037893, 1538960177870822, 829889727712499}, + }, + { + {4793558625576028, 3882027570562344, 4207241179173547, 5281023204511977, 6361433483438371}, + {3281892459792280, 1933131048782198, 2351228493867205, 2032809616708977, 2534356983068777}, + {909754464411828, 785219392684958, 1338541457752162, 826789969638535, 2048189131938215}, + }, + { + {5399590275296719, 3849598676683261, 3407829328170797, 4201689601652353, 3895190733841783}, + {1015687460377127, 2173401063127799, 2017987633047477, 748955581941445, 630511527938929}, + {2101074774193018, 2001243087608708, 801641610437734, 1519697986446082, 594845713523709}, + }, + { + {4827244732148509, 4706350784965857, 3625459412499055, 5917778693464512, 5372808769862558}, + {1452942110247071, 1201823364506117, 2330240170803201, 2907618912660148, 2069141053434694}, + {745779946397307, 916664696261756, 1535477642186117, 1334763610638931, 1366843744138046}, + }, + { + {4176014068905464, 4252766041468492, 3589174288259552, 3776062686798003, 4986282119113185}, + {1092579010212274, 1203724605936750, 2270767453066752, 2458071886656347, 2443647576082745}, + {318795329870799, 185430882319687, 1286511919273276, 657817007383756, 40641447918263}, + }, + }, + { + { + {4538870843995520, 3964150480707053, 5487263883039355, 4602170887743532, 5736245235930330}, + {1632352921721536, 1833328609514701, 2092779091951987, 4175756015558474, 2210068022482918}, + {1998172393429622, 1798947921427073, 784387737563581, 1589352214827263, 1589861734168180}, + }, + { + {5350015016975595, 2997963309224426, 3081458566511327, 5095667333327441, 5460842165191887}, + {1733739258725305, 2283515530744786, 2453769758904107, 3243892858242237, 1194308773174555}, + {1758148849754419, 619249044817679, 168089007997045, 1371497636330523, 1867101418880350}, + }, + { + {3965982201013836, 5981456109444663, 5078495317312678, 4410918223912516, 3807332263401822}, + {2578433797894864, 2513559319756263, 1700682323676192, 1577907266349064, 3469447477068264}, + {853828206885131, 998498946036955, 1835887550391235, 207627336608048, 258363815956050}, + }, + { + {3753463041754121, 3606679279252159, 3696232489183494, 3149612277537848, 5358662226124843}, + {2392941288336925, 3488528558590503, 2894901233585134, 1646615130509172, 1208239602291765}, + {714380763546606, 1032824444965790, 1774073483745338, 1063840874947367, 1738680636537158}, + }, + { + {3423450128487239, 6070685071936072, 3705460605693651, 3009714346694508, 6123110970148691}, + {1640635546696233, 2884968766877360, 2212651044092395, 2282390772269100, 2620315074574625}, + {420958967093237, 971103481109486, 2169549185607107, 1301191633558497, 1661514101014240}, + }, + { + {5625132717515116, 5524850964392681, 4614069623317915, 3762859588443640, 4361835721816909}, + {3158923465503550, 1332556122804145, 4075855067109735, 3619414031128206, 1982558335973171}, + {303213233384524, 2061932261128138, 352862124777736, 40828818670255, 249879468482660}, + }, + { + {3697491154222530, 4544214010492622, 4905703930515359, 4988733897248726, 6163038950957920}, + {856559257852200, 2760317478634258, 3629993581580163, 3975258940632376, 1962275756614520}, + {20057458979482, 1183363722525800, 2140003847237215, 2053873950687614, 2112017736174909}, + }, + { + {2961281310713750, 5035281843536219, 4820563396802425, 4066115702139011, 4762159869794599}, + {2228654250927986, 3735391177100515, 1368661293910955, 3328311098862539, 526650682059607}, + {1053447823660455, 1955135194248683, 1010900954918985, 1182614026976701, 1240051576966610}, + }, + { + {3576347446000839, 3504021369715234, 3286921249007623, 6268908633911267, 4898262353027354}, + {2053850994061963, 1755999209417110, 2842496597997123, 1978798188794297, 1107741233360060}, + {1587558591633082, 1224310153016076, 373416710356490, 733639236443698, 365919571874338}, + }, + { + {4922046667787666, 5384603941382862, 3355282705253058, 5052638190916511, 4442324355401649}, + {716350205934888, 1153032590403764, 2797021656648850, 1143194352934997, 4271302979058629}, + {1588274760900072, 933817618340883, 731655082380959, 688238385999711, 637984915480250}, + }, + { + {4217060480329358, 4374528391636951, 5478312030233942, 5051281083802439, 5405881257383323}, + {413138784837996, 173345891427747, 1873100191622562, 899752727618929, 3454430648436331}, + {830072102529414, 1185948406051604, 1521170049452316, 1259798181998483, 735064905966282}, + }, + { + {5515669600102047, 5759134783811579, 4357089500282138, 5244472517255288, 5695631524373921}, + {2842166480737527, 2947367283673209, 2706356593419314, 2971106642583260, 2444234893549177}, + {1396164055858898, 2228551364195726, 611382817170935, 1662418665433346, 1079098567119990}, + }, + { + {3828208352345746, 5742603493540025, 5912515684826959, 5415942702105867, 4409414272784258}, + {2895166868245672, 3153594867376981, 2883799413649215, 1877187137914547, 1124004944737352}, + {1249379796419407, 1201460644559526, 1259226742776869, 583948750717161, 1178519968480157}, + }, + { + {4715510278636375, 4324771002227588, 4218850944267831, 4037187367673896, 4505301806813551}, + {660737143139077, 1635830759165556, 795647058595473, 2117049403264300, 2692853476865573}, + {1654844956375931, 767321709128720, 475080629455448, 116932684758291, 96451917556060}, + }, + { + {5797033177541322, 5021581754974953, 4978830133961786, 5973534325336756, 4105099431310062}, + {1777561190222404, 3757586069945925, 2868096822929350, 1968746982919962, 1089633650980574}, + {833672890421142, 647759906668054, 572517465546269, 402134952667751, 2083275174687780}, + }, + }, + { + { + {6352542060466074, 3833809696215741, 4101092554705390, 3320298136988035, 4253202043484731}, + {1957943897155478, 1788667368028035, 2389492723714354, 2252839333292309, 3078204576998275}, + {1528282417624269, 2142492439828191, 2179662545816034, 362568973150328, 1591374675250271}, + }, + { + {4265077968872559, 2914460285039701, 3045781039391514, 4915306233356239, 5308090560495285}, + {2411826493119617, 2484141002903963, 2149181472355544, 598041771119831, 2435658815595421}, + {2051892037280204, 488391251096321, 2230187337030708, 930221970662692, 679002758255210}, + }, + { + {3713635732994642, 4207056293821675, 4684465815183558, 6055578880035022, 5061343489334444}, + {1530723630438670, 875873929577927, 2593359947955236, 2701702933216000, 1055551308214178}, + {359179641731115, 1324915145732949, 902828372691474, 294254275669987, 1887036027752957}, + }, + { + {4324702538941745, 2563932266428659, 4813530513012704, 5499843939988947, 3842301114037549}, + {4295071423139571, 2038225437857463, 1317528426475850, 1398989128982787, 2027639881006861}, + {1397254305160710, 695734355138021, 2233992044438756, 1776180593969996, 1085588199351115}, + }, + { + {4202522275076530, 6411445226225292, 4074557295320773, 4373367518435491, 4577411558841716}, + {2692366865016258, 2506694600041928, 2745669038615469, 1556322069683365, 3819256354004466}, + {387139307395758, 2058036430315676, 1220915649965325, 1794832055328951, 1230009312169328}, + }, + { + {3379372614866712, 3476543574256943, 5779819517217769, 3781538535387827, 3841619480557100}, + {1765973779329498, 2911143873132225, 2271621715291913, 3553728154996461, 3368065817761132}, + {2181229378964934, 2190885205260020, 1511536077659137, 1246504208580490, 668883326494241}, + }, + { + {4227237865914097, 5575401147370301, 5098251926594813, 4129497466354055, 3741435180672532}, + {2689666469258543, 2920826224880015, 2333696811665585, 523874406393177, 2496851874620484}, + {958592545673770, 233048016518599, 851568750216589, 567703851596087, 1740300006094761}, + }, + { + {3792569420294954, 4400089757531324, 6101403783497940, 5734203344054362, 3067223272494699}, + {2014540178270324, 192672779514432, 2465676996326778, 2194819933853410, 1716422829364835}, + {1738560251245018, 1779576754536888, 1783765347671392, 1880170990446751, 1088225159617541}, + }, + { + {4447695422728303, 2418292515870024, 5595971144063629, 5081870838292807, 5209525481880645}, + {2916521632160477, 2343112140697014, 1601700300762337, 1763148914953177, 2708190975156259}, + {1339021042945816, 1840804708066696, 877961221559635, 1281458842745501, 1950851850845276}, + }, + { + {4786922334540966, 4955024641438784, 2989160972656404, 5186429632708936, 4984389249074409}, + {1020393680308960, 3834711966547082, 2322726956159582, 995949551108034, 3035172379117141}, + {2248087612518599, 173333799263920, 1744928838552182, 957368524885377, 1722980339454003}, + }, + { + {3826226586501329, 4985391470235567, 3706778387862153, 5001039432994919, 3643485069381971}, + {2453664361158331, 3658664111645897, 2133047286876873, 2891246599919261, 1077039773701841}, + {1403674776792037, 176114870970230, 204752269254815, 823265703401663, 973549049711641}, + }, + { + {4428694302478430, 4279516097530892, 4558829707092394, 4506689423374814, 3060727770678082}, + {3511507258617268, 2341694334736402, 3023178443373630, 4119452783133958, 1541883672814480}, + {273175012476053, 353915697751570, 1920076197363975, 2096923665433891, 694182114426694}, + }, + { + {4184692084971979, 4134060280811983, 3170779668973105, 4456307003709940, 4308299286729100}, + {2273158812011175, 3253770145986191, 1455430838863125, 1701216872600126, 1994907074166318}, + {854928709890819, 247698160098706, 1293104197995963, 648230677212306, 784063325867838}, + }, + { + {4504036913969323, 5450574207835078, 6042071388766678, 4918868602774744, 5356088910233627}, + {2995726671480383, 3106924626287182, 2718750693945174, 3268809265740618, 1129470954185503}, + {2104894828289916, 873144584667742, 506537740149646, 646077767532773, 1966868865211605}, + }, + { + {6048446108790732, 5524115631172029, 4165751037432881, 4331639016561072, 5291322591785068}, + {2269347023399866, 1910686315635227, 654955394153571, 2857416503175088, 847850165913280}, + {836953051260559, 1769743545147988, 699239118029628, 825806019782225, 1990070083297713}, + }, + }, + { + { + {3395265304118584, 3783994539881306, 5596876372865192, 4984641333486582, 4373205247246409}, + {2911103727614740, 1956447718227572, 1830568515922666, 3092868863429656, 1669607124206367}, + {1686424298744462, 1451806974487153, 266296068846582, 1834686947542675, 1720762336132256}, + }, + { + {3458195995174227, 4836757775805549, 3654433306506668, 5623690819092521, 4197273928235755}, + {3141016840074207, 3295090436969907, 3107924901237156, 1669272323124635, 1603340330827879}, + {766720088232571, 1512222781191002, 1189719893490790, 2091302129467914, 2141418006894941}, + }, + { + {5441759705376431, 3673576132738420, 4193443048427021, 4683601810691313, 3666180150435792}, + {2671463460991841, 1998875112167986, 3678399683938955, 3406728169064757, 2738338345823434}, + {398001940109652, 1577721237663248, 1012748649830402, 1540516006905144, 1011684812884559}, + }, + { + {3248461355092589, 5959477015323422, 2996112620542523, 4642813523567241, 5503882535918283}, + {1653276489969611, 2257881638852872, 1921777941170835, 1604139841794531, 3113010867325889}, + {1450817495603008, 1476865707053229, 1030490562252053, 620966950353376, 1744760161539058}, + }, + { + {3213965769821056, 5620199287619286, 4685689805377309, 5959205094392245, 4699653216173778}, + {2811528223687828, 2288856475326432, 2038622963352005, 1637244893271723, 3278365165924196}, + {796863823080135, 1897365583584155, 420466939481601, 2165972651724672, 932177357788289}, + }, + { + {4468743695984567, 4898440950560817, 4474456712004917, 5061786181321024, 3329036690710436}, + {877047233620613, 1375632631944375, 2895573425567369, 2911822552533124, 2271153746017078}, + {801118384953213, 1914330175515892, 574541023311511, 1471123787903705, 1526158900256288}, + }, + { + {3726318200450545, 4012593435854444, 5660999417843231, 3874664121744144, 4669027921793287}, + {3201417702772463, 2207116611267330, 3164719852826535, 2752958352884036, 2314162374456719}, + {1961673048027128, 102619413083113, 1051982726768458, 1603657989805485, 1941613251499678}, + }, + { + {3486506407007189, 5586943518586412, 3150073788000181, 3892658932084745, 4661178025941644}, + {1401939116319247, 2587106153588320, 2323846009771033, 862423201496005, 3102318568216632}, + {1143483057726416, 1992614991758919, 674268662140796, 1773370048077526, 674318359920189}, + }, + { + {5249032546684913, 4376477734728695, 5192833668695386, 3879528383130666, 4673544232718438}, + {2001586827113779, 3745189534067065, 1944288247515270, 3801531181100442, 2035001711257644}, + {1821331151892312, 1302058705892077, 1823533497142581, 1477427445977593, 1256884978338733}, + }, + { + {3816568398797501, 4280523703434080, 5575370580457579, 6556193442157265, 5400032142723120}, + {3676887960291627, 2721875544375886, 1949386962401535, 2062484445640651, 1831148391448868}, + {1098621584553762, 479766126028979, 50128556582829, 1793185955386011, 957643491878541}, + }, + { + {5624964178025902, 5881679035334285, 5337334188128135, 3373245272349238, 6030340196395357}, + {1686491261026354, 2930481776329103, 2527067703865047, 1879410757156738, 2416602562794561}, + {1954783342191961, 1776196854323048, 1073865783628317, 126006585556188, 551111053703277}, + }, + { + {5863020639436884, 5014608403303800, 3487461172336056, 4625089084538493, 3002443292699384}, + {1844293295362196, 3776383490821424, 1827935191421176, 1761145652561373, 2654244832682184}, + {2163920127813722, 1809848067831371, 1226486593520438, 6568253441272, 318658165188350}, + }, + { + {5229528028782988, 3740161041125714, 3628427289315213, 5072860979211871, 5962952384148406}, + {1112209403436618, 3603724598892882, 3004743983803641, 1636637612372587, 1910870598142670}, + {1139920697586991, 989775023258908, 1562720488536799, 1457380545841604, 910097567659210}, + }, + { + {3041059796685021, 3926553231646481, 4587262528244901, 5282743084605635, 4777345624727557}, + {2431004626164709, 3854783312160059, 3273298459729433, 3386841277003151, 3777213922766615}, + {295894405919626, 1325594150172422, 673838771367222, 604280180076012, 485577818727658}, + }, + { + {3793091552131313, 4374989255749447, 4298473526457935, 3586546830561382, 4785727997920673}, + {3556189185732659, 4013352737062889, 2854416081619439, 1896415948116520, 654670146226537}, + {139962000945005, 2246840272939065, 40902718655534, 1533074280944617, 1032382655251714}, + }, + }, + { + { + {3758431901841840, 4379281609207426, 5017412546860750, 4644243343298864, 4946076247670812}, + {1835401379538542, 173900035308392, 818247630716732, 4013900225838034, 1021506399448290}, + {2056683376856736, 219094741662735, 2193541883188309, 1841182310235800, 556477468664293}, + }, + { + {4597695873914911, 5426082008537486, 4528117456116057, 4391230322227749, 4348938857916251}, + {3566819241596075, 1049075855992602, 4318372866671791, 2518704280870781, 2040482348591519}, + {537697207950515, 1399352016347350, 1563663552106345, 2148749520888918, 549922092988516}, + }, + { + {4827183563480027, 4225372812262903, 3444018843651805, 4582954431755768, 5877642652930841}, + {1747985413252415, 680511052635695, 1809559829982725, 2846074064615302, 2453472984431229}, + {213277331329947, 416202017849623, 1950535221091783, 1313441578103244, 2171386783823658}, + }, + { + {6124178045615487, 5044634958558963, 4487585538139111, 4406665622773445, 4226427082437073}, + {2440888617915079, 993969372859109, 3147669935222235, 3799101348983503, 1477373024911349}, + {1346805451740245, 1350981335690626, 942744349501813, 2155094562545502, 1012483751693409}, + }, + { + {3326465926121696, 4752879014110088, 3426137740310600, 3810813345691727, 3724087589204368}, + {2107080134091762, 1132567062788208, 1824935377687210, 769194804343737, 1857941799971888}, + {1872620123779532, 1892932666768992, 1921559078394978, 1270573311796160, 1438913646755037}, + }, + { + {3280128640868324, 3962843103655104, 3602632284060180, 4174964503289574, 5999255996217406}, + {3089190001333428, 3264053113908846, 989780015893986, 1351393287739814, 2580427560230798}, + {1900828492104143, 430212361082163, 687437570852799, 832514536673512, 1685641495940794}, + }, + { + {5679936010824454, 3977277108025017, 4516300250042949, 2929815522503454, 4666323705890374}, + {3094432661621646, 605670026766215, 290836444839585, 2415010588577604, 2213815011799644}, + {1448049969043497, 1789411762943521, 385587766217753, 90201620913498, 832999441066823}, + }, + { + {3515424710267724, 5606202029043823, 5029901811084866, 4403815652814045, 3735639122175257}, + {2767886146978542, 2240508292484615, 3603469341851756, 3475055379001735, 3002035638112385}, + {442991718646863, 1599275157036458, 1925389027579192, 899514691371390, 350263251085160}, + }, + { + {5324956849177719, 3429271620480873, 5513927382492506, 4069478768490913, 4487763984887828}, + {1005736577196489, 1703778335600507, 1256787933200658, 1273583601164519, 4154995520392582}, + {1181460621741892, 515102888370257, 660560226785527, 1121970691511835, 1609869229541589}, + }, + { + {5276536763892090, 4684953471965519, 6139261731383556, 3763310979241977, 3999629994843744}, + {3197840386614072, 2673429719431285, 2328666993391622, 1601604658039797, 754388419948612}, + {2189230067083086, 574898679774723, 1093556583385601, 1590603941933467, 1876625616519950}, + }, + { + {3739860822512771, 4605148533211466, 4174048138272099, 4387338734269228, 2880424850917010}, + {2359748764236743, 2750393191088290, 1526008165088803, 1669725971211966, 2233234520219112}, + {42208074517808, 919916618772548, 1864146060012263, 405874007551625, 167276017170589}, + }, + { + {4682022353746882, 6009429539947866, 2947942480787000, 5087407628431820, 4667285753466106}, + {1939674698340922, 2060465757190214, 2418157875657274, 1687699771189262, 236132178171812}, + {674205207435332, 837990472116301, 1170756550883494, 611962296440926, 1446026806940794}, + }, + { + {4797835609201808, 3649645875831679, 5195894411777247, 3424984715982399, 5322304250778016}, + {3454576586408064, 2256192384569215, 2864444376813541, 2134820396191597, 1047034985188490}, + {1582224761030916, 260261512990929, 1131518591198333, 94648525453241, 270083062170054}, + }, + { + {5595107036983877, 4494054900752656, 3263812520261324, 5044525307237686, 3722017695712965}, + {1188525422166779, 3589855283768506, 1782193012394260, 2155228647422980, 3120862178456839}, + {1981581840102891, 142303636665554, 2039535378650111, 1181156234198923, 1967834468546111}, + }, + { + {5706915977082882, 3753081378072469, 2510190141605996, 4045103810631250, 4992176450645285}, + {1947964231400572, 2169451112529873, 2463002605422706, 3228930307152278, 597158871609891}, + {1385883488372791, 1890958046379947, 2126979282588918, 17215697802179, 562809648160246}, + }, + }, + { + { + {6060806645993160, 4844231320170097, 3729525723161433, 2866535765304666, 4285036937432013}, + {1689713572022124, 2845654372939621, 3229894858477217, 1985127338729498, 3927868934032873}, + {968764929340557, 1225534776710944, 662967304013036, 1155521416178595, 791142883466590}, + }, + { + {5626780938473300, 5189175572245936, 2759405279195173, 3664390275802720, 2819817138913873}, + {1487081286167458, 3244839255500182, 1792378982844639, 2950452258685122, 2153908693179753}, + {560258797465417, 2193971151466401, 1824086900849026, 579056363542056, 1690063960036441}, + }, + { + {4383124982462505, 3428436472114155, 6260522268883476, 3642043430861258, 4218124990723630}, + {1918407319222397, 2605567366745211, 1930426334528098, 1564816146005724, 4113142195393344}, + {2063958120364491, 2140267332393533, 699896251574968, 273268351312140, 375580724713232}, + }, + { + {4285699823073660, 3996702683556035, 4442379901602887, 6453074611624616, 4734649381664242}, + {2024297515263178, 2668759143407935, 3330814048702549, 2423412039258430, 1031677520051052}, + {343868674606581, 550155864008088, 1450580864229630, 481603765195050, 896972360018042}, + }, + { + {6032529693711055, 6108603534430070, 3306860895022921, 5961918729318160, 5737795472583636}, + {2151139328380127, 2566545695770176, 2311556639460451, 1676664391494650, 2048348075599360}, + {830430507734812, 1780282976102377, 1425386760709037, 362399353095425, 2168861579799910}, + }, + { + {3935550130401342, 5155878315656623, 3473598574878785, 4149160495161916, 4823257793397838}, + {3407562046415562, 980662895504005, 2053766700883521, 2742766027762854, 2762205690726604}, + {618808732869972, 72755186759744, 2060379135624181, 1730731526741822, 48862757828238}, + }, + { + {4481933078376341, 5067550582461519, 4294715789111644, 5330913983663967, 5175628607523309}, + {3714971784278753, 3394840525452699, 614590986558882, 1409210575145591, 1882816996436803}, + {264204366029760, 1654686424479449, 2185050199932931, 2207056159091748, 506015669043634}, + }, + { + {4317070754263612, 4535076723640848, 4810021506483985, 4685558271307180, 4158905350371329}, + {1784446333136550, 1973746527984364, 334856327359575, 3408569589569858, 3275749938360725}, + {1496516440779464, 1748485652986458, 872778352227340, 818358834654919, 97932669284220}, + }, + { + {3850207796558603, 3727422831028406, 3797434477252654, 4293213262701836, 4516227523843066}, + {2048146359190201, 2164495845485630, 1987127118350888, 3702022928556186, 1248356726771194}, + {1517919028451878, 1390653207300047, 480997424969526, 463880049786815, 1566994328535414}, + }, + { + {4207292859242158, 4439237956877375, 6466630861755493, 6117169411664878, 6203775439423042}, + {2630289459558480, 2051409995957989, 2137890426251559, 2865150520767226, 2183646505352378}, + {250950165450403, 2108575357747549, 1858230594483734, 184468003072844, 1358638013010624}, + }, + { + {4795165927742161, 3556821674590553, 4452234877886028, 4063350508177236, 4357194618603124}, + {1363161060275889, 2019577584627825, 655391965916958, 2833727353647238, 2341948580614770}, + {1778982619924496, 1328609079558951, 1163827266617015, 1019320353990254, 830400209170522}, + }, + { + {3688756718408583, 4561393289356786, 5750092980695080, 4477840229539135, 3932387371938841}, + {891039147350711, 498786796467410, 3025350790192290, 652448826471937, 3394872208963829}, + {913282769158846, 347533899935257, 99606006705773, 1452035970297517, 2212487011762079}, + }, + { + {3066351608928554, 4959266561713426, 3505484480779672, 3313237988086280, 3214107063996871}, + {2440372328053980, 3986555651364494, 2478020726949882, 3029257951861872, 1322928669372349}, + {1259703414196061, 804804682694258, 2147323977049515, 252131006189623, 2246814133555350}, + }, + { + {4603288585029083, 4275494842669350, 4559975392494094, 5326825482142171, 4885471931566349}, + {616470521493849, 390707946935204, 1334622907385598, 2029831529830923, 2813735341554671}, + {1307353080865175, 1065210115652369, 1698012640184922, 2095589265946492, 688919666182564}, + }, + { + {4119409763828209, 5174415249772511, 6589359183715483, 3474134685034925, 3261800548024222}, + {3800663179733707, 1510662538907767, 2305029203181277, 1120480520235783, 2745749397969076}, + {959187641997964, 1919963359331922, 1067802756608566, 851276549968152, 2180947835690309}, + }, + }, + { + { + {5516816602304168, 5042521547053092, 4167576536206804, 6246422068954372, 4138350501601902}, + {2723435829455580, 2924255216478824, 1804995246884102, 1842309243470804, 3753662318666930}, + {2094270000643336, 303971879192276, 40801275554748, 649448917027930, 1818544418535447}, + }, + { + {5719674169295574, 4553720561304003, 3817628817819056, 2973527969819827, 4852805692036683}, + {2241737709499146, 549397817447461, 838180519319392, 1725686958520781, 3957438894582995}, + {948617110470858, 346222547451945, 1126511960599975, 1759386906004538, 493053284802266}, + }, + { + {4357186931049660, 4248263218811680, 5806608241664995, 5355507743318703, 5857341677159129}, + {1454933046815146, 3126495827951610, 1467170975468587, 1432316382418897, 2111710746366763}, + {750300956351719, 1487736556065813, 15158817002104, 1511998221598392, 971739901354129}, + }, + { + {3486884278433110, 3417910960117329, 3997194671566838, 3657316287568287, 4508063131522112}, + {1874648163531674, 2124487685930551, 1810030029384882, 918400043048335, 2838148440985898}, + {1663810156463827, 327797390285791, 1341846161759410, 1964121122800605, 1747470312055380}, + }, + { + {4458441089863460, 3942387623406751, 3851973436510373, 4407895911319668, 3358622222233463}, + {660005247548214, 2071860029952887, 3610548013635355, 911703252219106, 3266179736709079}, + {1344788193552206, 1949552134239140, 1735915881729557, 675891104100469, 1834220014427292}, + }, + { + {5125820669443841, 3461946287724414, 3994046236028930, 5907438988749520, 4920789118266230}, + {1920949492387945, 2410685102072778, 2322108077349280, 2877838278583064, 3719881539786256}, + {22727256592983, 168471543384997, 1324340989803650, 1839310709638189, 504999476432775}, + }, + { + {3589266475777094, 5791244982040267, 6521619274146678, 2903981043059491, 5401611380582210}, + {3565040332441556, 1721896294296941, 2304063388272514, 2065069734239231, 3056710287109878}, + {1969792547910734, 779969968247557, 2011350094423418, 1823964252907487, 1058949448296945}, + }, + { + {5777164948769480, 3890309495649820, 5262835493859430, 5169614751717201, 5401583088313899}, + {2459143550747250, 1118176942430252, 3010694408233412, 806764629546265, 1157700123092949}, + {1717263794012298, 1059601762860786, 1837819172257618, 1054130665797229, 680893204263559}, + }, + { + {2942680342150880, 4278613828995852, 5350213167690156, 2989120782966715, 4123142629949771}, + {2556444502235146, 1613361869622030, 1402717375340694, 2348339985765731, 3489511500408293}, + {1426750262638336, 314863572574246, 1394348337483702, 1967765724676815, 1262927622887481}, + }, + { + {4948972567610721, 4760459340435499, 4508373064131856, 4400791580495755, 3326118030989422}, + {2602109836867459, 1003276938441793, 244450874677932, 2495574856155249, 3110870831093824}, + {1089876164348856, 610853718362589, 290946077126125, 1189633635903067, 238116851513210}, + }, + { + {5818313990376412, 3745131403850386, 4984633161305300, 4588134365279068, 5605706152381173}, + {2574353462387544, 1744531678913296, 2081810750651984, 1255482175291668, 1579377192487289}, + {1077984189936462, 1101581309304165, 229118769946835, 213129071862971, 1105903869282826}, + }, + { + {4244657319305304, 4848112240284328, 4808999745724375, 4645297205085174, 4469873257565411}, + {2568686941901236, 1277107033850968, 2743723193537219, 3580901504461986, 430697021449829}, + {5110283730621, 236925008060043, 590130982419942, 541274580551940, 2155487465178420}, + }, + { + {4504922761302740, 3620992509914934, 3198533798350925, 3770782329534318, 5363163230411568}, + {275387113122210, 3501532982637668, 2704624275342757, 1489585626413894, 3573009822045302}, + {1859877583133149, 1445451213294944, 309288119160981, 1843441717427399, 584114977316234}, + }, + { + {4103673694186728, 6461574165907240, 3718162222127163, 6247603847194471, 5772831446786927}, + {2087653679988656, 2238424089144458, 2130407033226307, 1889280872742259, 2146873922212313}, + {500701236542790, 1839091700792145, 218488889984877, 1301749778593414, 614810966957821}, + }, + { + {4649730463510780, 3151390162038927, 5365410818081747, 5007340477551264, 5551016597277571}, + {2300360039943938, 1529233553127717, 3500096717284879, 3664531564773424, 3173693672061933}, + {882756809520167, 998774482479105, 593908492257531, 1132796830151366, 1780707297956298}, + }, + }, + { + { + {4583071810090063, 6354729884420668, 4077544622618353, 3073467147166315, 5285394920882441}, + {2237039662793603, 2249022333361206, 2058613546633703, 2401253908530527, 2215176649164581}, + {755822026485370, 152464789723500, 1178207602290608, 410307889503239, 156581253571278}, + }, + { + {3747179848085639, 4828649103787668, 4549946522264427, 3805208654040102, 5332579729206178}, + {3669985309815545, 2736319981413860, 3898537095128197, 3653287498355512, 1349185550126960}, + {1280337889310282, 2070832742866672, 1640940617225222, 2098284908289951, 450929509534434}, + }, + { + {5758557848470941, 5656835588370337, 3194707518654080, 2888905217772639, 5652892897517762}, + {2659503167684029, 2378371955168899, 2537839641198868, 1999255076709337, 2030511179441770}, + {894249020470196, 400291701616810, 406878712230981, 1599128793487393, 1145868722604026}, + }, + { + {4956087140669123, 3603920362709815, 3425295697596203, 4250911519607256, 4870927757824721}, + {3749755063888563, 2361916158338507, 1128535642171975, 1900106496009660, 2381592531146157}, + {1717539401269642, 1475188995688487, 891921989653942, 836824441505699, 1885988485608364}, + }, + { + {4274232174887052, 5592415718055546, 4229643212225114, 4106634029575971, 5067838489399852}, + {3493583935107776, 2439136865632830, 3370281625921440, 2680547565621609, 2282158712612572}, + {938868489100585, 1100285072929025, 1017806255688848, 1957262154788833, 152787950560442}, + }, + { + {3546872176125197, 5434827532059909, 3607531246326933, 5425835363204530, 5395826856780703}, + {3119119231364171, 2872271776627789, 2477832016990963, 2593801257642876, 1761675818237335}, + {1680989767906154, 535362787031440, 2136691276706570, 1942228485381244, 1267350086882274}, + }, + { + {2787309244260446, 2798685347422569, 6028275236918294, 4389895566536949, 3512537903582074}, + {2617818047455756, 2684460443440843, 2378209521329782, 1973842949591661, 2897427157127624}, + {1159906385590467, 2198530004321610, 714559485023225, 81880727882151, 1484020820037082}, + }, + { + {4265412029331945, 4082570389605622, 2787935123905079, 2861072139265641, 4774283971865508}, + {1377485731340769, 2046328105512000, 1802058637158797, 2313945950453421, 1356993908853900}, + {1237542585982777, 2228682050256790, 1385281931622824, 593183794882890, 493654978552689}, + }, + { + {4433747840806046, 3721621780348463, 4999137013220096, 4950695012032930, 2963731882329120}, + {3700733741689868, 2019165860436683, 839545028551310, 954045289946680, 2857671609142350}, + {2031235379883797, 946220755552074, 1457648474415011, 1222951728743327, 1610191601040290}, + }, + { + {4162295633314539, 4747504508371898, 5420102803358852, 5241263790326999, 4652112494046944}, + {3713236670706339, 1708249553383010, 1441184960961852, 2138372449656361, 2208801341603864}, + {743176047113998, 1210025633688996, 1298930577649249, 2241929289171655, 319185600078644}, + }, + { + {2463674019917897, 4802840710289795, 3812247475965604, 5281339404908102, 6114735096224475}, + {2361755477281753, 3920079557094249, 1772761852174940, 2188727617473580, 1972330964627961}, + {2224894613062235, 459022333460366, 853633232091964, 42662368548958, 1428459390829900}, + }, + { + {5876939711261840, 5483557082287477, 3340896169956977, 4741202975388493, 3246978129870096}, + {1888400628800904, 3246442970371919, 2048876033526183, 418388094414663, 2174354817875660}, + {1865410028261408, 627467389699032, 146077987303115, 1698467014229834, 2014393109530681}, + }, + { + {3339126822971782, 5967460547143544, 4911389289674917, 4202215034765918, 5578073611339204}, + {2670644791837462, 2651763434193316, 2285020046276825, 2227807589256768, 1464013488829088}, + {1806473647942365, 538787999504182, 512973154409687, 1944932181085518, 1069910541821032}, + }, + { + {2634758329364868, 4859512915801802, 4928387675794414, 4438135586288705, 5912306986153546}, + {2593937978996354, 2409464365976668, 2076140577147016, 4427101675063297, 1879995664155906}, + {407209884855019, 2088464831333939, 2111856537862679, 1631244096914416, 1074707055277992}, + }, + { + {4379690451347501, 4147722372858437, 6043474882489476, 3830885552726038, 5483938823325814}, + {502401202015803, 2110371415921011, 2529666734456328, 2767243204597450, 2341774206366416}, + {1547018311600067, 615783499206767, 485547569767288, 1517514580034299, 457611163959317}, + }, + }, + { + { + {6197629798333913, 2753838380751446, 3942959878910714, 3201428133247434, 4778709814063561}, + {2299141301692989, 1891414891220256, 983894663308928, 2427961581972066, 3378060928864955}, + {1124515748676336, 1661673816593408, 1499640319059718, 1584929449166988, 558148594103306}, + }, + { + {3540740886557976, 3183587715724649, 4694330636229537, 4258659768352436, 5509531109592197}, + {1784525599998356, 1619698033617383, 2097300287550715, 2510065271789004, 1905684794832757}, + {1465551264822703, 152905080555927, 680334307368453, 173227184634745, 666407097159852}, + }, + { + {4674947851286115, 5166365727170883, 4965938571130991, 4970517390710808, 2908711106554361}, + {2111017076203943, 3630560299479595, 1248583954016455, 3604089008549670, 1895180776543895}, + {488623681976577, 866497561541722, 1708105560937768, 1673781214218839, 1506146329818807}, + }, + { + {5492578995360943, 3611529141261548, 3553634070931276, 4797740788199803, 4532947899647969}, + {2412225278142205, 950394373239688, 2682296937026182, 711676555398831, 320964687779005}, + {1434382743317910, 100082049942065, 221102347892623, 186982837860588, 1305765053501834}, + }, + { + {3443537155111802, 4098841848663610, 3634013358734303, 3291752209395695, 5292412486267354}, + {2205916462268190, 2751663643476068, 961960554686615, 2409862576442233, 1841471168298304}, + {1346965964571152, 1291881610839830, 2142916164336056, 786821641205979, 1571709146321039}, + }, + { + {4996047770903428, 2555904966356003, 4013566981986303, 4737382312068285, 4233095136791335}, + {787164375951248, 2454669019058437, 3608390234717387, 1431233331032509, 786341368775957}, + {665807507761866, 1343384868355425, 895831046139653, 439338948736892, 1986828765695105}, + }, + { + {5356490725342733, 4068788685039808, 6047372383097019, 3426510449207690, 4705728718095123}, + {3007896024559801, 1721699973539148, 2510565115413133, 1390588532210644, 1212530909934781}, + {1205281565824323, 22430498399418, 992947814485516, 1392458699738672, 688441466734558}, + }, + { + {3538981275120648, 2874522279215958, 5384551777942367, 2992835507144444, 4815164902360267}, + {3302427242100220, 1955849529137134, 2171162376368357, 2343545681983462, 447733118757825}, + {1003649078149734, 545233927396469, 1849786171789880, 1318943684880434, 280345687170552}, + }, + { + {3979319739304371, 3173810108641712, 3480574285526200, 3800294424979384, 3983333585686372}, + {2754253003222887, 2275532945921888, 3105484814506120, 2795714951112672, 3618146930096140}, + {247596824353536, 285396193673154, 686289557053653, 399468081949262, 249109087231255}, + }, + { + {2723125664053674, 3464927193948491, 5445834280101391, 5612124161635761, 2933099654237696}, + {2672303537844268, 2038791134455123, 3285678115022383, 2900519586434405, 1978453542160588}, + {1705147526637648, 1274613803517124, 1602845665731412, 1064073198174681, 1486788069078519}, + }, + { + {4077390367222227, 3800932136610666, 4160144924974108, 3561238039866711, 5997919559096945}, + {819031393505739, 2088275424107290, 1796234646803442, 1388708737598893, 2937136216710939}, + {944757498200715, 2015594302768299, 813220261760372, 867002775164821, 501734915431717}, + }, + { + {4424498381651951, 4370145165962473, 4303795913232316, 4673352990886468, 3539252307041619}, + {4258052207216187, 3760480385682185, 3206156011228824, 4088908699869294, 3011569459811111}, + {1187304510804619, 1384816718516187, 514455602674227, 392638325371554, 588228521113051}, + }, + { + {4219797873858933, 4958627631706417, 4511020049341415, 3218925652522905, 5097166154822735}, + {2789655568104153, 4038602698967181, 1701909246528643, 2824012136983963, 2400715389506309}, + {1130277769648576, 1946206888578836, 1343266549795147, 2083590873042325, 264064594409097}, + }, + { + {3196954689864360, 3706526534080788, 3004981697061754, 5970179548131185, 5036616655131901}, + {1526130015031824, 3071067159569878, 2312643039801922, 2400491084238785, 2092334718179931}, + {1720808849496600, 410920656934828, 864594478015792, 229141760159822, 2037677155881017}, + }, + { + {5749040666310109, 2431937887261040, 3580364244969437, 4752008191428386, 4786853370158738}, + {1789863266178839, 2202012677135000, 2680121806416879, 1722812656485926, 572531509973556}, + {2175782751601278, 1608407337873936, 816706054544173, 258225706360159, 1478818623198000}, + }, + }, + } + + @(private,rodata) + Gen_Multiply_Table_edwards25519_hi := [32]Basepoint_Multiply_Table { + { + { + {4593529082752461, 4913481494458327, 5105340091484689, 3450213179198615, 5857240422918567}, + {1412482364088803, 4062389850048069, 923779398567547, 2023841154802081, 2607705760638543}, + {1825728698698411, 497946242397168, 105715611816086, 968568072676853, 592999326381074}, + }, + { + {4495184218325789, 5289073944532264, 4218636788579151, 4988461406676953, 4686478434934441}, + {2949190053601679, 1979948019919136, 2471186112468189, 3573963359061221, 2216896082446061}, + {743917567567859, 870447381138646, 392196079309387, 1786878704882853, 1520161635991866}, + }, + { + {4744444857419634, 3144662423000833, 2994206879871174, 4901643262699391, 4923693546628412}, + {3089537977529994, 1888948267748045, 1789290739253972, 2597750135306899, 3142762081370390}, + {1764333363430455, 898309455329908, 1381444383468949, 620561614151766, 158377983927494}, + }, + { + {5941345963042037, 3413323930288462, 5115763723871020, 3248416926384114, 5473315945632476}, + {2269111888817457, 3231588657429924, 3123230781695332, 1299656894822778, 1180051671372258}, + {407953783981, 1647278360877740, 584504284208188, 906066565536232, 1341016264992694}, + }, + { + {2432346762050178, 4412970725632038, 3922648159237080, 3005442494216723, 4442116552336937}, + {2381425302937802, 1387820520945502, 3125986768243210, 2463732477189113, 4185413214185067}, + {286790540720370, 376171092666609, 1535083117539001, 143466475958698, 1595136426572043}, + }, + { + {4277560779811042, 4605632954767560, 4619246140475080, 3484505719110307, 4989421629835765}, + {2829089547178292, 1790256014216198, 1797656649279268, 2562891052522691, 493980515519391}, + {62004126799683, 1668357417723485, 402010966421038, 827662362499868, 620754241677270}, + }, + { + {3919396572999125, 3838658814915336, 3750839246192093, 3726674239012627, 3831212626851778}, + {1227888687423439, 2913177985394946, 2412294236854021, 2805130984485539, 1308360976872086}, + {1643929373822818, 59659873139317, 1165353313134798, 2003225793255085, 1953102130608543}, + }, + { + {4114999970343247, 3274056679568382, 3954123294817179, 3769263204026901, 4245068682986802}, + {898618711827587, 1314215296781160, 1302503840208753, 3496738988099889, 1698289814254750}, + {1392999845620760, 634309693840701, 815492400002072, 340703897996290, 2038693787178716}, + }, + { + {5214250944985254, 5214298257940112, 3933846341585754, 5894386249523842, 5770685254784336}, + {1934541077562988, 2222946897208970, 2251242179056732, 1591285457544104, 2747813687509638}, + {1016675746743198, 874873189324170, 1360411561434916, 1581878592793672, 1548505102984557}, + }, + { + {4769452847684060, 4913417142027999, 4139599914472574, 5727971436547121, 5162246544117082}, + {2615904366263746, 737197398316645, 1602932940462504, 2167985252180769, 2559960808783062}, + {1882565165016312, 1581434850744420, 1900290919378503, 1985953844470085, 2168995994538833}, + }, + { + {4554120491153816, 4069860035617982, 4340413640826432, 3211862620694644, 5818608637282174}, + {1544885394173400, 1572082853154176, 1022098019061266, 2766927411109582, 2094149897716596}, + {1565161503379169, 1009067677698409, 1758464151571027, 1604769367828030, 1207412426608003}, + }, + { + {4015717287484591, 5253478309058146, 4070204443357591, 4445835852409645, 4665111518123177}, + {2854833619490147, 3573568625503236, 536183518454769, 2263990573554737, 4044861757799243}, + {1398840935273285, 790488576331737, 33415624257391, 1637374533896247, 2205752015162110}, + }, + { + {4260625486568009, 4637770924690903, 6480430642402074, 5542751059832424, 5622960391176990}, + {3715812780985479, 1012232238437221, 2466752896497024, 2611001871592954, 2143269004082900}, + {1886046851462393, 702395341735300, 737389004224425, 943477665979721, 723064819201181}, + }, + { + {5226062982149706, 4477280967632100, 3095356746333787, 4567645348066962, 4846495995079660}, + {2444351104229624, 212638631228834, 2148034812459853, 1041500100514044, 3853826660522166}, + {273084620529389, 1358348733025497, 1143735162114047, 1683813303234668, 2163735276562013}, + }, + { + {5320556456798805, 4779694419891170, 4876824494496501, 5903452387913251, 4729985500450036}, + {3477960290395163, 2468183980355970, 2936794001231177, 2308108181814059, 1969019168758558}, + {2160310767797410, 344164523453241, 83129919763985, 1315117733435601, 945559910324390}, + }, + }, + { + { + {4363327446469061, 2701839972520523, 6527685309871122, 4056456213766895, 3880569128224647}, + {423177393665983, 2333545232306939, 2028971153113312, 2728157354019203, 3777730507929771}, + {1435691822393684, 1850026012837208, 2218717487026642, 81859254010196, 244808221751742}, + }, + { + {4151019106002309, 4804743010530635, 3757223421954400, 4766036153424381, 6107544569595961}, + {821837003520359, 4010299059749559, 2863227431802226, 4078726431091997, 2442551264358059}, + {1428688544729295, 109069749881410, 270830364539996, 1755181768867140, 162349670944771}, + }, + { + {4642027397896088, 5510058210884768, 4553756231196669, 5068441159437344, 6370925538331183}, + {2639121586131590, 2408957406336796, 3986248100020063, 2989795052558558, 2164082093074357}, + {309881142350067, 2106019349943259, 816133263871674, 2018031260992166, 1563425406132832}, + }, + { + {4395494918929745, 3011447404605211, 3917145931603942, 2759967153620848, 6379442527779295}, + {1498799085180043, 1744340656397133, 2064851197592072, 2429833814776112, 2145324400616903}, + {614788980313577, 1501513053451003, 1472055221710495, 1920317897819127, 2208964791748263}, + }, + { + {3560784093342680, 4994362478801752, 3255476397621627, 4445556105981925, 4954471675599246}, + {2150595732685700, 3115920468099904, 1640951315905191, 3465930332728019, 2707896919197916}, + {612249867445962, 159208429955777, 563950177277347, 561041393363217, 1270750549218661}, + }, + { + {4520180469529123, 3948074172686157, 4376189225516076, 4643310756673520, 5392469157863016}, + {2055033216205027, 2461832572574425, 2742691255886072, 1052243367900374, 2752099767668600}, + {1827261746419924, 1468053133723229, 425022050209163, 1161272199376693, 589189496874922}, + }, + { + {4438522896195229, 5675329383977909, 4882438618733149, 5825827678555036, 4497535703422370}, + {2005207463235253, 2001528853385595, 1602253387656095, 3101879903751894, 2375325873201006}, + {847469444462207, 318959830531389, 408429171873782, 1661514071773102, 909441091898553}, + }, + { + {4102243665939998, 4215863334856383, 4408378320450327, 4622977479151665, 4039328475229204}, + {2174491994328136, 493557282042709, 3602705188549813, 3249913558677235, 2748481399349512}, + {758760864397232, 1830650226770835, 326981597370189, 1345979301472296, 174985669849506}, + }, + { + {3114038058163888, 4115257910705954, 5304962337604028, 4942520420915651, 4570979005352829}, + {1616868525778916, 2685769941228860, 1500533033491414, 2505164168102999, 2558430770009979}, + {2210398167996316, 2029125611734957, 1527318329127090, 226535237621728, 757747276478551}, + }, + { + {5660830910412470, 4039716640180729, 3468207460119772, 4614076381392168, 2442548670982292}, + {2039774403824382, 3183946537620297, 1982095153858182, 1293586830098836, 2438708503064038}, + {1357360519318812, 2045548381976834, 1766860667272665, 994521972889149, 393185631961961}, + }, + { + {6365035791876788, 3957527440519852, 4079038689927398, 4319831229004816, 3943934873019078}, + {2354388502926730, 2133757859975250, 3747940319461896, 1050624714408746, 3528225787559372}, + {1423510913950154, 1407788039482417, 761922275972375, 1783557942644647, 464730646959110}, + }, + { + {5146524748212414, 5035960985653238, 5028883959266913, 3282581313444735, 3905335483972979}, + {950694750709616, 2909132113066654, 2692353349246129, 2659905077175497, 978201784181073}, + {1078796318026741, 2070782433025097, 1700702188087909, 1447652546515478, 2144027848464236}, + }, + { + {4464099897473286, 3120477039861599, 5276369827125764, 3567131403687606, 4968190256098962}, + {4085811716920468, 2616309657099343, 775638006452370, 3253232221169984, 2587485588949578}, + {1012423034220617, 2045371869775344, 1260737445157584, 1833095526522043, 1066294173319533}, + }, + { + {5773192417487042, 4517701999097386, 4655557572427803, 5616698382540752, 3371552871839388}, + {2877566362774786, 4401330265553408, 3208625757371899, 1399785720487456, 2531340752609210}, + {1640471888126382, 1014801052117284, 1178704129888297, 982929852576812, 981292318502343}, + }, + { + {6476452238344334, 4693003674971858, 5211751500997938, 4121351294551163, 3152533251509898}, + {2011936343019114, 1133486795463590, 2647435457385352, 2628952425675517, 2374701464984626}, + {1245374341789768, 946202302464214, 1370924353088231, 682015131982855, 1275473548530510}, + }, + }, + { + { + {4235275101318885, 4886666925763093, 3781172458925008, 4774837350787537, 4519905633498379}, + {4159636855200485, 3150221611558687, 1363421772307006, 4120947913313657, 252053503603381}, + {45902352975738, 1246446699820833, 173320410042641, 1542230462600972, 692910725375140}, + }, + { + {4486356754653352, 5011982731057698, 2800477110646540, 4053556040992402, 5267180761554575}, + {710084928405448, 2105676789486896, 2420643007484910, 2605134634368896, 3302669631199693}, + {2191680341805656, 1972509245077282, 981795995975654, 852454486043614, 1189735660434765}, + }, + { + {4897930998338676, 4879106310620971, 4682586750207620, 6132197307461033, 4233426591406375}, + {3995777047683048, 3833719910688599, 2444044754441170, 2232313400412571, 1420975603500953}, + {1931343025077052, 1393738210614177, 622857924319466, 1123524882306454, 1963513295012502}, + }, + { + {4596722267439639, 4583990247552416, 3156713638372258, 5382313953040853, 4261038954366871}, + {1850504730697909, 4381679472853618, 2011448898092860, 2090154061858281, 1857166627539261}, + {1509035496076582, 1583601071466027, 421912810565136, 1678479534084506, 2033502297510813}, + }, + { + {5152283091655165, 5421718026722430, 3997156174417042, 5001987993936945, 4470112047504242}, + {2238137325796915, 1165391281982950, 2048774700033766, 1309041739154703, 3204681887791132}, + {520151332809519, 1588829471961614, 2166353389460390, 404024831468766, 1335244071323823}, + }, + { + {4644249663336450, 4507701753581319, 3592182426303562, 3683130545837732, 4598992005732335}, + {2528474489315892, 2071299735249833, 2619224970187272, 3271465188079442, 1519932762444249}, + {1935180256227856, 250757393177447, 1959439731378182, 1297506762666169, 575184640324100}, + }, + { + {3998007896814392, 4789639746579090, 5427007329099910, 5561733860472916, 4408133776555178}, + {3563813919863414, 1486712601904120, 2979081810490774, 1807789883906314, 3546555493967378}, + {1438068615152094, 34949160848567, 1911746456436447, 1412684293826264, 1046374507505090}, + }, + { + {3358198622960838, 3580145032458308, 6285906454262483, 4413045221104222, 5178477068028319}, + {1493476678908308, 3319155065445914, 2088667670293411, 3599225826407670, 3126758502479837}, + {1428599160764785, 602821281250279, 1877258833313507, 333285098655770, 740310036947361}, + }, + { + {4437738381533964, 4511430215080912, 4623800711093479, 3858159170572748, 3792114250503483}, + {2569231089452712, 3770152139328302, 3269539085929031, 2383025095054982, 2248498609425137}, + {375535123602711, 924645774628115, 2045840727994073, 766250909414083, 1069698092749769}, + }, + { + {4435294130703604, 4934879817377642, 3598080452693711, 4396369088299832, 6194434176750643}, + {3899859044211942, 3058237431324156, 1669265990252613, 3808823766704698, 1861135005644935}, + {1352954153117419, 632457759471481, 85028188501619, 1852310027888311, 1569233778435479}, + }, + { + {4994607739226691, 3549890051462689, 4602469939135293, 5262974664864567, 5829540047772287}, + {1177033227220429, 1414982090591775, 1722841418062421, 3232176376002923, 1625133154241833}, + {478074309368979, 623121553345246, 885068774570210, 117698677138481, 109006840646140}, + }, + { + {3228583777446740, 3685494966163883, 3859895584510878, 4132565491795209, 3602518465644145}, + {1476961150268616, 2321154243603617, 737795879830106, 3409730959236147, 2062873179003703}, + {1329749333731727, 46254713998516, 373767480531871, 1933047124368118, 430092326122748}, + }, + { + {4068619402415723, 3955796447715502, 3724578346370833, 4337532310052478, 4252452058492903}, + {2483442550312325, 3615812911108800, 2858427288312835, 2135393495237610, 596254727540093}, + {8959488931169, 1768025271694380, 2157573235225770, 292082063715064, 330646837880843}, + }, + { + {5129020796146722, 5575913156701592, 4643684154507286, 5052753294034768, 4627882199658166}, + {1682783588724042, 2651474877391040, 965357158907406, 1910483514645702, 1644451034905796}, + {976078747227308, 1952905065031031, 949292862704054, 1492592732072346, 1010921457352162}, + }, + { + {4006410514827696, 4367363852356865, 3108174070644550, 3399842446392251, 3651405461962036}, + {2963842949036336, 1110443523197923, 2370466150687958, 2051405852060769, 1998735788124574}, + {629291283140720, 1484410172308977, 1230690465849055, 1563468011476927, 1425159147311735}, + }, + }, + { + { + {5585239563455525, 4610636723895044, 5486382712767880, 5982393863492935, 4225244847092674}, + {2874785617528993, 1037465406252872, 3296887051144680, 2286839599744315, 786748793374778}, + {1152063960223905, 1495207756023516, 403624329924470, 288757773501508, 634701074033280}, + }, + { + {4288607522123402, 4846896146524989, 4707359298406332, 5135207568875886, 3789334229842457}, + {2917883701302634, 2925085599109681, 4014710226846848, 912132719741982, 2714081319314151}, + {204576686258175, 1916354881141604, 2182213405559566, 836541881049164, 1393662576855498}, + }, + { + {5759444997810940, 4193440837630205, 2993247029494710, 4574723038696780, 5462384317223070}, + {1429326167011008, 3849536799125309, 2267296904452424, 3653618160132546, 2008400870233860}, + {1583200791922713, 581155064879634, 776749520692821, 82151283071376, 1733847968592305}, + }, + { + {5824219020582313, 4082583579489045, 5236716515955319, 4695754388607834, 4087929633004663}, + {2723457493421297, 2288104271131495, 1889807602666693, 571526543144584, 2151183507738315}, + {216379584390389, 359329711860756, 2220840445637019, 1935487238453911, 314381139238943}, + }, + { + {6324432942393073, 3866303010803999, 3020114267775140, 4943018510078408, 2696166744880915}, + {2134908988986295, 2962507202980067, 1681144354786142, 1678261855220080, 2165079891714277}, + {839191618399610, 151822034158330, 65272611705697, 938153274860627, 14360318777459}, + }, + { + {3118414549517527, 4750668024533744, 4389573074356623, 3687569756425714, 5338903547055573}, + {1473478682616257, 3633382583874766, 1909784146543313, 3349986706799106, 993668408613515}, + {364270308207016, 667227739516977, 122427551474936, 957177061876827, 1110258403339423}, + }, + { + {4256211953323020, 5655880769308112, 5147711084133693, 3515346496193909, 3997285326966523}, + {3727619641010474, 1181551732606964, 2600588673325403, 2469054944509579, 3385365618247725}, + {858909692206820, 61057235030988, 1105898533486092, 2202030785898301, 1422234761465688}, + }, + { + {4566369519147140, 3936942479708331, 4946651352770194, 5597737572220025, 4038789996699983}, + {1354120322856538, 3567014996875285, 3125649205892726, 3221576024570935, 3804405204938131}, + {758252632702114, 914226082256766, 434171717412081, 779505540917105, 51590353584795}, + }, + { + {4416135541622855, 4651530410104026, 3833614791957416, 6714310821280595, 6038964345007539}, + {3122819969959355, 1154192626573742, 3197914057178582, 2213609121110881, 2415518693959367}, + {1900133378602138, 577297894556411, 1975904780443420, 367702995667978, 971695605371773}, + }, + { + {5691739211507754, 3947360890016266, 6002902486092077, 2925962297163746, 4016189592321792}, + {1294948213915982, 1859247234048810, 2826079115120605, 2717796469093276, 1254328736376524}, + {1309911522909577, 1419436642934017, 1066858837800204, 1932820656369018, 1183788306261091}, + }, + { + {4373293771099146, 6029412334349101, 4603988300239160, 2779063318785645, 3538182001391078}, + {354784062716014, 2960996156215287, 737478213901140, 2448765213738437, 2443710778345986}, + {37327849111839, 283459044945755, 353933224898901, 1645288254358965, 1295375429334450}, + }, + { + {3677292170794769, 3117650463171591, 4719239493455234, 4362161261080430, 5717636534074846}, + {2663608264759869, 2105855808111831, 3795920549032608, 3588992239888494, 2806554331792318}, + {2036310356419974, 1862941437683537, 2122628002305950, 427826430955887, 291402007632220}, + }, + { + {3100956993836596, 4149163064979557, 5785693523916593, 4751072583726928, 3316412298207139}, + {2400585099524078, 845178406557315, 1712123121349035, 1518690883002826, 2049951197688491}, + {1805653877101595, 2041224626272278, 851063029095866, 1497753468187708, 1406228898239886}, + }, + { + {5260996583106547, 4838608075273405, 5366327117123850, 4982440029922063, 5698050109664171}, + {3676073115087797, 2883668558141193, 2503071760256012, 1640618939206309, 3001604944016599}, + {463897193543924, 852129647033757, 2185610432355774, 914719594057928, 342067349817283}, + }, + { + {3765905247379871, 6338723143452534, 4484328730824797, 5536719681008311, 2764639921823257}, + {1030797243840613, 2110720517661432, 1415230398470209, 2977956931886379, 1982287306571007}, + {2180738906930659, 1806951067450075, 36005005692651, 303238055099928, 190139573853343}, + }, + }, + { + { + {4025496086329564, 5028184343166740, 4304607245262868, 5977861543210978, 5975943712754890}, + {1773953341907106, 1826809791300708, 924874532383668, 2964289914628984, 3000051694532148}, + {1048828262296911, 626018299495748, 1536855937015065, 557005099579827, 205000143299648}, + }, + { + {3686649646834702, 3431735540864864, 3540678075266127, 4755119958422340, 4426577953698517}, + {941815577996700, 1930911276112812, 3001621068228165, 1967675522206374, 892948220720651}, + {39364207708032, 54077643340559, 47072300438335, 484490203728205, 330170579231628}, + }, + { + {4702834568738627, 3291678731018536, 5642230899808367, 3758646432111623, 5155137589229851}, + {1020447780607279, 2803044870250806, 1618835409581889, 2925650123847541, 2605959132875331}, + {1190283817822151, 29815862110548, 1401771831527381, 1814017508050437, 751331585591881}, + }, + { + {5109595606310342, 4551817631663576, 4964640045962167, 2568185324125768, 6484076393091613}, + {2159866514586362, 1758376548473728, 1635569740383557, 2443910752037966, 2023235829583533}, + {535848012622913, 543536404720769, 149076814975879, 1567757637416350, 1002851193383852}, + }, + { + {3815561875504886, 4987304354260221, 4882489851059671, 5118054256243381, 4641807084989976}, + {850247344591352, 3894610597706487, 1974409276090169, 1605973976114297, 3601811238228268}, + {66796032196982, 83108349878636, 1058512765854606, 355785880766958, 2173660513649027}, + }, + { + {5137434473036957, 5769675136285847, 5436511544403722, 4264839407576387, 4266175067727596}, + {1941123290917747, 2316977311376991, 2913763383192580, 1172954226263395, 1951085968954154}, + {1331723279107642, 360406964548232, 602431788387748, 1292398959539176, 347247628588850}, + }, + { + {5432516922132898, 3078886318864995, 4583513191179486, 5867019372106709, 3411264839291911}, + {2170226002806030, 1739335733478471, 4017472424997012, 2918660155665329, 2793865679796361}, + {245885669910192, 255454579697350, 869246923980317, 823008017430135, 2047987637517532}, + }, + { + {4988197221931747, 4124266159815332, 4025663002514467, 4403069876409057, 2825978174946111}, + {3615548446949869, 2386240595324376, 1969460953567929, 2939417927358269, 1831662708850445}, + {1325588019367749, 1763566216507756, 445592400440775, 1009027711126237, 1471076108623188}, + }, + { + {3535455324868691, 4187842716980314, 6000482158112321, 3740505414106560, 5271856051582847}, + {1181816564414671, 1156678021972118, 2682384137206273, 2260248858296388, 1100324256765571}, + {1487590095774723, 277659353917859, 1381509894936782, 1061130669028904, 1364761503808628}, + }, + { + {4778189969823672, 4001451898457449, 6113563635354943, 3279804336055010, 3551539211588960}, + {3358253142401746, 2070882729090991, 2076758122179069, 2612730216279296, 2875157527961954}, + {1082784010061460, 1534894036268453, 1852407202514802, 2109696474131863, 1530718911157644}, + }, + { + {4923904010378051, 4401333064112293, 4345896142363128, 4462036896398403, 4199434117360330}, + {3404425764066199, 790431937118435, 2117892820897492, 1747418170252123, 2322149428381644}, + {1548552607325007, 2020524571521392, 198565314654983, 490668591018400, 531050967405176}, + }, + { + {5145969570912646, 3496492300608685, 4069590843971303, 4335556955800239, 3325377629546533}, + {2623126033999932, 3437252355580701, 1673392257908819, 1954440682865467, 2560737733895255}, + {516406018439380, 1624367135427190, 1319745729116992, 1076628515910554, 819495581575694}, + }, + { + {4005978810673255, 3160053273427578, 4474659303213566, 4173935427495701, 5201857712754300}, + {843136030895887, 1929944939303616, 884551308418834, 1356687291240061, 2259204804361506}, + {1461715846997541, 2038281458208083, 2119767535863762, 636224052565171, 1712721429371389}, + }, + { + {4975731433879692, 3888553624589664, 5228917373823987, 5038386998880250, 4707655682255612}, + {3409114563124612, 1820064381354618, 2421007346773091, 3239920960596314, 3726969650504610}, + {475869807928836, 887669112822100, 481835223948027, 1468799954696850, 1370247723645687}, + }, + { + {5954383345631578, 3742995524386402, 3611065523713845, 4447231480190211, 4725820376570018}, + {1943063487159002, 2890245371286974, 2837035330843453, 1080549927676027, 867285909606140}, + {1413582027032622, 1273926892909999, 726179076119442, 699229594605794, 406422835715518}, + }, + }, + { + { + {4513888950241631, 3212738446973608, 4558390526464820, 4859080230791315, 5273416148656656}, + {1326059070986753, 1683859889439034, 3052200172327874, 3805600625804475, 3687690452819464}, + {1081752225631401, 201284952113932, 1619339403526661, 1533363030164674, 1727571790703503}, + }, + { + {4206177554516483, 5468031785191800, 5978090949319557, 4899439545685678, 3929672195094815}, + {3151535789445747, 1741766716299828, 1742063303545331, 2027626928190420, 2245203856982753}, + {868012933261061, 1472665613225898, 1744063644616181, 1350305502884983, 2227467074628670}, + }, + { + {4669057309967741, 5650515638764201, 3042033906165361, 4078124455841206, 5666341739515191}, + {3587030559572189, 2850528363281919, 2974216851298661, 3227895056003248, 1349661756105253}, + {1313383948772993, 1074655824143287, 20040386640896, 305794891855170, 2123092901229151}, + }, + { + {4199945629383318, 3594320984526977, 4229880092041671, 6384664478996443, 4732837782434517}, + {2744443256254860, 1013874505344583, 1972732629285783, 1936827407065469, 1830481951704579}, + {634737804354539, 422989080575800, 1774993942417585, 688011718282303, 581542014403477}, + }, + { + {2816888940207091, 3903781507184007, 3616069829367681, 5525450216549915, 3780846206608878}, + {2517199667227667, 856367096857961, 2630571629218547, 1768604592283813, 3688963458794126}, + {1683677903016217, 2036167240589310, 262287609979509, 977873833112269, 433284640623898}, + }, + { + {5477402921384451, 3117269161199628, 6049837891653338, 6034999812243824, 5356551064760510}, + {1755760392036121, 2130115351478138, 2694425247498002, 2043622709923142, 2338295058055586}, + {1425112218383847, 329346717672590, 378517748485393, 1806152114945447, 1211275024279312}, + }, + { + {3594715588472482, 3844045487620198, 4484578538777484, 3113667148844230, 4337495224693479}, + {1968587687914188, 2881021730370090, 1429009633828432, 2770076641127580, 2012343565772575}, + {1629969809602186, 1106234784906336, 863587490378700, 1792807263239898, 1429043938024750}, + }, + { + {5737804770941067, 5078013196347608, 3898224610791405, 4804530531188967, 3180800540121608}, + {1973106012015851, 2593923400059844, 833516958919695, 2182197879897069, 1721403407106648}, + {1591076166555979, 849361769125080, 1443799738863429, 166584794343739, 1861773413238536}, + }, + { + {5730227718465208, 5596273386383722, 4195854427433762, 4069266668520101, 4524280540784068}, + {1968981310480276, 1950975116204498, 2592307802896060, 3813918534870745, 2620661073133464}, + {936764653391291, 1452448249608980, 1312847510424692, 1846051928374105, 531372961271999}, + }, + { + {5549943196407418, 3432818760073271, 3449244033859606, 5283577488399029, 4864604608008479}, + {1733819728686816, 2936024966547233, 1590816041651632, 3163811004299109, 2676757470677367}, + {1319097278964637, 787422552977413, 1599496421811883, 1959379193761008, 1506646670818903}, + }, + { + {4227254412838170, 4548570321204425, 4285644009760393, 3751016940211786, 4098838617641914}, + {1732471582908700, 1866076266304485, 2819215151172481, 3074745073420508, 2774887501545996}, + {717261628309176, 1858796230699344, 551077134877547, 149402535309098, 2105648961714394}, + }, + { + {3871916223505114, 4749816457502813, 5358561311326743, 4112663885073414, 4137415642080692}, + {1127279535151728, 1199265744257977, 1248562495202825, 1868357952639788, 917052103965266}, + {25664888255034, 1628004430886188, 1439984389498414, 1961957176184883, 182596205772698}, + }, + { + {4179077756813138, 5647690538147405, 3274850245594335, 4319226212135161, 3864148139899748}, + {1739387701061410, 3112148637704823, 3028846916651989, 3700388643798173, 2412185850016002}, + {975143220058337, 825243809988211, 515186464897625, 1179464291552333, 2112614471328036}, + }, + { + {4947873049161087, 4901033700427489, 6675583808729484, 4941667050946228, 3120269525234559}, + {2996598747660015, 449189546044795, 2197501482114022, 3158206489499126, 2705800926920583}, + {96737353895103, 1534044505139178, 563303281603459, 407703386650348, 1821870774469537}, + }, + { + {5049500432849751, 6040441932911013, 5618655093441099, 5061587505104794, 3837175101097290}, + {2654088892951999, 2871006956063187, 1742690076584393, 921899537851044, 1870021525725886}, + {1637444308641066, 1472124432669136, 741811397216072, 1252880060061292, 423564866101658}, + }, + }, + { + { + {4796818337004571, 6222611117014093, 3083419469630983, 3862822099971652, 6509664209117283}, + {1171837083014025, 2516532715963947, 1770010974323603, 2517908022038722, 2020794083615321}, + {762321251771152, 1460210191529427, 2248797163104578, 217468651569622, 63003536153574}, + }, + { + {4259858178043342, 5554955317979561, 3911791110113593, 5525892988208900, 5545696994818748}, + {391588043113892, 2202456919563943, 3869688632614537, 2945959779196464, 2143606811138354}, + {719793864170869, 1411477466905009, 1515019021063010, 1483421690183889, 1704042941619334}, + }, + { + {3034963268199750, 5870224135513779, 4115305817554936, 5421579290342892, 3835694901998808}, + {2769635787032504, 2958323523618463, 1537480429839772, 1483278086593314, 1378968978067758}, + {1315034452637574, 1172434640681242, 1135533609020364, 253349230877293, 161211572823476}, + }, + { + {3942650253210285, 3918824117103583, 4001647299508483, 5240554545879312, 5035373070605317}, + {2659408003097885, 2049444491227493, 2594690944032877, 3421228755254048, 848234126951057}, + {437225545901468, 888271756229202, 903344393515123, 162913205438885, 1475178706291532}, + }, + { + {4287921885063088, 5041248821201299, 5585484729625036, 5534367719396511, 4532272822475758}, + {3707293450173872, 751219268219695, 1525065253586106, 2054680090861517, 1393874745922970}, + {1910711495320594, 321017884248758, 1651671690842787, 527123817162741, 847944616444202}, + }, + { + {3415231495445846, 4190597015532201, 4905073239386883, 4940927269911495, 5980840029199164}, + {1474221667712446, 3068688770339565, 1358088375247373, 1853329794010803, 2931295009606082}, + {70084211861389, 1248863300280704, 1009402227613886, 1445171656255193, 728732085908498}, + }, + { + {3340501878764401, 5410923356778271, 6030788584012822, 5594611759355304, 5267577702264329}, + {2869750492870027, 1153392601340917, 2754776472841130, 1100510641818700, 2870221151280913}, + {1481950048975238, 97096668186528, 429204027887699, 1510003697018425, 2114825823462494}, + }, + { + {5159850395392603, 5067743945456882, 4551909910661973, 4393814096795878, 6145580658249508}, + {1440929316705129, 1633730452330828, 3657204567294737, 3657918436987822, 2561724546723194}, + {809017030155597, 1831934834657405, 58189812416765, 1517873507099267, 889681994437792}, + }, + { + {4153444167566628, 4372997703941365, 4839161526733376, 2653398635504610, 5324373835991045}, + {4007354401668216, 1201450641763461, 1526795422335006, 2273741230894754, 2130356372280991}, + {1057020591512462, 1324094020999413, 655956927766596, 659874727272243, 2024954110083652}, + }, + { + {5839605326568475, 3831434019746100, 4883240784156331, 3880003889048305, 4841910074653809}, + {2844236939823231, 3043783621566488, 3890227240890757, 3800769469380331, 3175183419371011}, + {863608592350445, 1111828464904337, 322487356734403, 60843367779474, 775147863897458}, + }, + { + {4129677439236364, 4363616958764152, 3255333433286932, 4071265658640216, 5527560633207578}, + {3501906805856088, 2995655036831742, 1989943322549290, 3334534687075832, 3371315397704424}, + {471893887981193, 1459834432249674, 229072407724256, 1165980516905022, 1036865507138076}, + }, + { + {5587927329012785, 4196019533185475, 3488244055775669, 4788679066807545, 3936797203887245}, + {2334971095120001, 1054095219722721, 1729452124624259, 3446754994849569, 3835890504040419}, + {883720982539262, 2126174835830047, 1858128110066030, 1402309396930944, 1358212283922371}, + }, + { + {5437236132245684, 2619202868264644, 4266616048403094, 3779544081061673, 3472381895789909}, + {1158559475833858, 2227035258871772, 2170552210791850, 1087363571520417, 2867304161007231}, + {116357390237056, 38114324586368, 853586347213800, 1638943134635811, 1882124412005945}, + }, + { + {2871025108215057, 3893039278529517, 3878244260089116, 3893554424872522, 4708186328386966}, + {1760242418163439, 3855738944127473, 2877581036561996, 3253911846338252, 671018190326366}, + {1641735698439468, 1630160111859414, 1920036824528970, 346120100914920, 385076471695398}, + }, + { + {3934974918427731, 3807320560303621, 5860456491598573, 5199210868384009, 5781319959443384}, + {819456425532597, 2215390016559513, 2301197053109143, 771274648900875, 1303516882225152}, + {1530178090161037, 1646502716614548, 1058228190532635, 1522572712238470, 991147078780643}, + }, + }, + { + { + {3763364100157977, 4436158450653533, 3664705850096563, 4592883978910063, 4855668048892712}, + {3431442042489897, 3670457457720097, 2927483669898581, 2847896260114069, 3422237175305894}, + {1907217462504765, 679044428705663, 1371479879514675, 1420793148384765, 190685345044087}, + }, + { + {5140896563326095, 4954544354938625, 5148671791011404, 4813313238272129, 4814788700593711}, + {3528505813008031, 3913030166310689, 3457534787545946, 784019563379975, 1449546143149561}, + {2213525665395526, 146358659614731, 1573034916169973, 1131167148341295, 1194403623212224}, + }, + { + {3034590507214084, 3771531416844161, 4279939895181473, 5778619660734332, 4308244183318381}, + {2105305689409168, 1932040296635725, 2559301608776867, 1653053081843050, 3498476220207615}, + {1916484225176, 1896106466807315, 1279953155660650, 1725386140841619, 757101416534772}, + }, + { + {6555214085737347, 2980588876755702, 4785845115539682, 4430693817238987, 4107141749770380}, + {2133488547373079, 2884934342093682, 1652284377802152, 4287340267215791, 2741073463083472}, + {655928016394658, 1087485647128905, 1281789693328119, 2088439151211398, 1863153332596984}, + }, + { + {5220143354789533, 4303392603719785, 3697665521216293, 5367115036779017, 3354674257103145}, + {2461817469666051, 4062983661511151, 1323101412046937, 1360571080713195, 1716626899554003}, + {1790273650925445, 2180187262630477, 28219260774301, 1951582862584504, 1059160821201578}, + }, + { + {3706860118974125, 6182298149062642, 3206841902738667, 4986080379139384, 3223876357324169}, + {3108934357344473, 2823383892309930, 2709776767813967, 2732378265738840, 1695118712507849}, + {95538772778706, 1914880923031197, 417513632407841, 1767845086605839, 832379724270193}, + }, + { + {5132941124964776, 4798553016886828, 4052101096460607, 4475816634870178, 3176602159556433}, + {1456443406045738, 4161184975160682, 816382632051403, 3678387736600146, 2166890266198131}, + {393110820654303, 662371396172458, 1370237312917823, 2034119121136113, 904928937827}, + }, + { + {5075422185081409, 4699433492834214, 5948286955155472, 5933498265459676, 6441657203628461}, + {1257344135899307, 2776494249972420, 1637109398723534, 1801319038042246, 2082644998926031}, + {189274223123103, 2188109173279445, 1461570511269332, 151886143484743, 1557837550414982}, + }, + { + {4365365818590957, 5180206223815189, 5035374537630803, 5955216889373899, 4177347431591518}, + {4105224954841159, 3814048291702159, 1805828417935849, 1548444252518409, 3761242775865814}, + {966697507230426, 1689614203301123, 867370120071235, 563108996765880, 1552869095947518}, + }, + { + {6190612622769392, 5262116783421509, 5770823033954832, 4892678801476142, 3789326136184388}, + {2680510164419078, 3125272296703659, 2480535210869218, 464721098622880, 1141684153257222}, + {1871952745325912, 144470913279784, 434631777342778, 552837449330893, 642852750438644}, + }, + { + {4755508755993467, 3653868693631672, 5880862524139354, 3244860344044728, 4481011039901531}, + {1809358219650823, 2339660560948574, 2410584439137912, 1286742564054194, 3633419878206029}, + {64765075641768, 68764899017819, 1968408548264810, 2037002115471749, 211556643344747}, + }, + { + {5543625841706618, 4560629261024327, 4731751483103768, 6307249547601622, 5012757099435702}, + {3301009531661216, 2677459079264873, 2707326467220240, 2261655438430016, 2962646350850358}, + {1579401584164790, 1951017356653076, 1801209077919862, 1153368800641031, 1775772413220140}, + }, + { + {3556317598507403, 5934251293404526, 4176527831714322, 5239968931380200, 4506603999756496}, + {2798836099557035, 2002468979873228, 1132424890166086, 2388404451698808, 664387721246094}, + {1947208168676528, 1750536949518976, 835780038339521, 1802624114603814, 1867663782159356}, + }, + { + {5351331441108046, 4901733280572801, 5434846723443585, 4372148225205494, 4376250516119689}, + {2519667781375866, 1132412577764719, 2322930879998983, 1660817657158452, 2806576583179867}, + {1273923691469553, 1862566872300733, 2236121435313308, 274949363314112, 477088969758259}, + }, + { + {3358480296518006, 3814827118577810, 5033804317047304, 4803399909431456, 4940637069622359}, + {1965761504739774, 3200209926214852, 3722168784530754, 3464219522306102, 1953662369491229}, + {1946412430894973, 2031215026716789, 1150845535883051, 749273986980949, 1433091314912259}, + }, + }, + { + { + {4565135018699993, 4952235844716789, 4332776238462736, 3944983589420527, 3534528668424353}, + {875483311206731, 1070293195031859, 1281389774974538, 2234860500431395, 3030484939064537}, + {2191861413872447, 1998107865473216, 135161483760725, 1133778951112075, 2177808149908975}, + }, + { + {4472607877838387, 4680291079417999, 5266381476904463, 5448529984859500, 6037873358663623}, + {1355285592679599, 3216332013847453, 2858567121370219, 2432376038574376, 2734263724238645}, + {449706520184472, 2214233011551797, 684523848529734, 431843026966950, 1758835924810462}, + }, + { + {3413242279346498, 4524603375434282, 2637627437993422, 4373910262118552, 5420094068912965}, + {1617166089281188, 448710947316786, 2017034644293574, 1886691422085664, 2375442150405559}, + {1239614751060180, 254449956067847, 1915952567259905, 391989559805324, 853553448301328}, + }, + { + {4142542119790983, 4675453183245373, 3888287250251838, 5522078723840086, 5552692716915124}, + {1381495390544381, 584763141985101, 3131504846670548, 2565162572339012, 2037973653370614}, + {762375715838646, 553562190209386, 1146347552263484, 824188464596685, 1830942666102590}, + }, + { + {5823375217862555, 4240127004291848, 4611065015006224, 3518908128296096, 4915429068500234}, + {1348374701112873, 3953700554194482, 3402331094627540, 2804779645909956, 2204826476892034}, + {2119092558617159, 1045482671389213, 690197889240825, 471826136635342, 1637923217880356}, + }, + { + {4059066650158007, 5141565698162354, 3733026015817812, 4875063676054927, 2832005231346927}, + {2181081937454965, 1121830291087960, 2832579231299976, 3124836269482413, 2225668708158199}, + {1193994157146400, 1628108083694642, 1021885296427132, 816068909639879, 2088480068848711}, + }, + { + {3180618525607636, 5342429333917474, 5008239417572170, 3506064373977331, 4538653079573275}, + {1673050054377632, 1765054067091528, 2962973405879830, 2339273872052899, 3950931503569149}, + {2229241184614921, 2107352800266199, 77312115078922, 2151892262530718, 947910914861383}, + }, + { + {5320544374459840, 4141095319362425, 3313360370605015, 5185507100540960, 3283266576250376}, + {1528297312537716, 2187935649407647, 2967731417391411, 3155021192657576, 1577434241618944}, + {1385713524190245, 153942078459639, 747467190641094, 1446053675113471, 429215290527338}, + }, + { + {4130033413775598, 5253437474448919, 5186743122906330, 3072446418934431, 4486276088811881}, + {3865635552262096, 2111934227084997, 1803460783795098, 2595364764305293, 4294038033412459}, + {1939054538963024, 1515892461529143, 2145315228101212, 206131396483318, 1207808442703235}, + }, + { + {4285235833599064, 5004869505494285, 5398338412388895, 5145057161859867, 6219558308357834}, + {2122251221692966, 1686529461497383, 3592144721245791, 946103181235971, 2261774551055452}, + {1519512635495115, 1879830706415200, 631994832099345, 90552542491442, 1074938948794598}, + }, + { + {4349405123860786, 3135193611243628, 4214940643324649, 5373877724549797, 3499285433136967}, + {699708361184464, 2781323063917462, 1664177773796467, 2129061781951253, 2929310224293355}, + {881819301152893, 1404208553713523, 1706641996539966, 685345252606027, 879987031868371}, + }, + { + {2629920833708073, 3077736686198199, 6153945246604194, 5109883364128321, 4007866927409167}, + {2201062670972485, 2517508956278887, 2681660437016124, 2026769404043331, 1562746334284849}, + {2029537774099989, 798336123274982, 962765795717174, 1441375461370721, 595792417755859}, + }, + { + {6147148440188849, 3255264873123981, 3737719663259093, 4820083084252873, 5252844759112604}, + {2825984342500049, 2739886905391569, 1677188826435105, 1932192000687991, 3155126576093338}, + {75347910850483, 59335245365512, 2051925237105745, 2044824231668461, 970303688628601}, + }, + { + {5763564504160432, 5421442243725773, 3588496091914407, 5369436266097375, 3995085142922692}, + {2488955180168268, 1799719498283103, 3012193868704087, 3191119683274303, 1313407450591024}, + {1669605168509235, 1046380333598262, 8317204728147, 1002144485955824, 1980712166998785}, + }, + { + {5208877095968696, 4101472145123500, 4547654469901586, 4596473001183302, 5108183921345691}, + {1614319198851918, 1592777501272444, 2078178842786638, 1134074463419502, 3406886179792273}, + {46520703266015, 1463053727782106, 1641431035629451, 1167993397224604, 1860200763335910}, + }, + }, + { + { + {3011332796830409, 3293305844851756, 4350706657635174, 6528175041183782, 5633500660447495}, + {1684548552982151, 2512680297050328, 2151565475089600, 2240257948464080, 2357334086387757}, + {2245889758290233, 1304556815701186, 1427348922813143, 221464961710041, 2149077757654506}, + }, + { + {5021889171679330, 4462128123863397, 5496067810219064, 3884382915013647, 4592260500935750}, + {1200977971745538, 679604753110803, 2370440117588934, 2264961098110051, 1017048311556208}, + {1190992926530423, 1046016291129455, 1934369009614752, 958221374199446, 762751542850234}, + }, + { + {3460977055305417, 5402529018730102, 3060601098222640, 3497142554641379, 4775614304897016}, + {1196600994744545, 1547369290503378, 2035231477477616, 1257032246257935, 2729013549752394}, + {1316355169784636, 2159471323343549, 195437001734225, 1784725127680235, 23628188515854}, + }, + { + {4414887133757738, 4702915728776787, 4098231006823107, 4707645820548353, 4031420634244190}, + {4034197670769956, 2299895540249251, 3720313013014369, 1169924369129605, 1452708652401532}, + {246845927125542, 475207520380026, 1495857355234583, 1332907410765356, 1137190823002655}, + }, + { + {4619638086363716, 5112231939480403, 3430351651754637, 4072797244384643, 5452815353333736}, + {402770419372162, 3130948749709529, 2422951975073025, 1521258543891683, 3268450338566556}, + {122249525311324, 1126352422834922, 929325077009082, 782368628240853, 94217591211022}, + }, + { + {4962635153104108, 5274135403834507, 4755774461820061, 4383546262262835, 5457666487690905}, + {2990995606289826, 3021922427972001, 302802129599791, 1502244105829111, 1773114045409669}, + {156241863414061, 496518516536107, 402847929676013, 1139792271454333, 1977247161507402}, + }, + { + {5032814130431534, 4760678921877281, 4442869438253961, 5565429687944605, 4317400766530169}, + {2463323770855702, 3896470221755473, 756431515781897, 3201672938286523, 2288460277235041}, + {1855056967762827, 1495181328549832, 966278130514841, 758391654071223, 467588501531856}, + }, + { + {4817034814919500, 4208076967893683, 5868839484739037, 5852497340094076, 4630054499608831}, + {2436900424213206, 1954148435588967, 1712385658617173, 2723793304425402, 681838917243489}, + {1439947543028469, 885225692302481, 1285222886469976, 1588398795428018, 1298691185892088}, + }, + { + {3166915207030205, 4221727132556131, 5745276646060520, 5830694990900872, 4237998343894079}, + {1368851636374513, 585540725726993, 2239345036245042, 3124363364569248, 2914970196697053}, + {1206666555409985, 1789371104267935, 1925466428785716, 378678703847709, 378978574609534}, + }, + { + {3049990186077834, 4282707068721497, 4031467457902549, 5045270642251952, 5619239366726696}, + {2247218341382540, 3733105160936895, 1542123681165149, 3690639696246556, 2686757663719606}, + {1131525507915411, 151967851358587, 1334045685598637, 1807594577522576, 1666949318203671}, + }, + { + {5317642436905001, 4262905497079623, 3806587609027544, 3162214737577195, 4598325819108034}, + {2322709256244499, 3364701239080335, 1085438519194966, 2211341194954781, 2734280485747362}, + {547075051672667, 1927631982974242, 603999740914722, 1974345687792190, 310412755046628}, + }, + { + {3092260334664458, 6358353190373839, 4150234089958180, 4141601803005412, 4164851538431420}, + {2480565549840732, 2510439995547619, 2534702111260990, 2561344597955166, 619102460354386}, + {1996829248620682, 1059563669319507, 2240440638640706, 1599145288747177, 407659118560947}, + }, + { + {3115383537041122, 4344887992692310, 5501863024972572, 3993241570720752, 3416751871823654}, + {1717619697579090, 3621794853637170, 2666986311609642, 3029150476191498, 2414353362640396}, + {2142003785026841, 2167906365984504, 1742773278204754, 812925480008831, 429368090247755}, + }, + { + {4184856094603567, 5404235283771230, 3764176438258862, 4280121628742729, 3445790640140600}, + {2656068733977443, 2976637537776442, 1238993222325972, 1554795161393303, 2131523863405492}, + {1574345185045103, 2079161140310195, 2092484433153763, 1408980124437971, 44981420431371}, + }, + { + {6193742471986890, 3621814037880206, 5498721010846514, 4536848636334539, 4762288817182267}, + {2703599140394458, 1961129680427764, 3192043467883058, 4259887504588631, 2455375021790255}, + {1758602597767485, 709830862658938, 931608374711636, 2198476269423406, 69272189710304}, + }, + }, + { + { + {3960691793618422, 4697205665896081, 4233023106925560, 3551947497905370, 3667490775726784}, + {2716251404526112, 1631117916585969, 4014857913931082, 2213037729836094, 1396521499150134}, + {296206175452724, 658879322369119, 97943562265366, 1761747874053347, 665498744562262}, + }, + { + {4542146017866057, 2313615921887147, 4181202139006694, 4414799599657545, 5341405847272363}, + {1200760264207189, 2304738880112015, 1927960174691144, 1569518880089323, 1152309979337507}, + {2038947849479643, 237162323211423, 2065816839891168, 419806183479203, 384865548997533}, + }, + { + {4632532202820720, 6679838284939842, 5003934316625137, 4209971835933588, 5519581415427037}, + {1152764853239608, 2282089860477202, 1601380253073465, 898105377854964, 1583948862629235}, + {1558193059260245, 1778073808602536, 402624851529717, 66752783641769, 824353727713740}, + }, + { + {4121947878564012, 3974762513146561, 4400688676047089, 3750758292493538, 5582121141429898}, + {1987770197713484, 751549594590657, 4130774294058181, 2772087960475462, 2398377455469772}, + {1021194340773145, 2214506742467645, 1946787888944335, 2047968106648641, 1821857137920583}, + }, + { + {4817011285691457, 3821500381976103, 5867746283021767, 5892999478528259, 3614975724251316}, + {520345345283715, 993525428347841, 3082505540027545, 1401316007351695, 2524441889115400}, + {540709883326476, 664748033877723, 77460650157458, 1882229467398241, 1217186023704288}, + }, + { + {3888704843022071, 3022592939512474, 5839771089230787, 4705593175556810, 4617871784452989}, + {1148904473568401, 2292434344833748, 2860017655924869, 896886146116790, 1793557015614071}, + {738867948290551, 1113067062951318, 2239418068162676, 2235388618772922, 321946428440080}, + }, + { + {5186369799189058, 3697173555759488, 4262727107695046, 3185380591286776, 4149807772745719}, + {2507278187062390, 1965300287234722, 1455241861966706, 2358026574953040, 2356583034323921}, + {1141974899967420, 1197500508248512, 1725264994009043, 1639228663875285, 1766256613674282}, + }, + { + {4859130511022316, 3438619274603782, 4274393918753007, 4542539306472407, 5021829178357491}, + {1473307785816396, 2183888493524504, 3592230148429221, 2872086545946123, 718894511556159}, + {200438687964996, 1579389594103736, 1144999901302662, 1292188560016150, 1342060233269448}, + }, + { + {5322785092917218, 3564464821553428, 2465159528975281, 5838118438127962, 4862308511365583}, + {2206232904105334, 2908798660147806, 2169658158959269, 2724132358944628, 392390928972895}, + {883459081700629, 1602090588151437, 768552508263143, 1181944834979084, 1796139787109480}, + }, + { + {5591293901585158, 5161437494483979, 4307878889760969, 4546298250229339, 4189604893397730}, + {2182554744233356, 926666458178889, 2790825304990041, 2529147957716171, 951582391464256}, + {187571578269437, 1207365261045700, 1671287753495621, 128062601272884, 1097620007687094}, + }, + { + {5979255840859055, 5170212343908976, 6251571908864416, 4044340797680332, 5873982661311143}, + {1856097540852989, 989253754708050, 2232404724159712, 538127825012338, 2301974812680125}, + {875553341339604, 2202671771469035, 1916683928798488, 1628926854796717, 2104927509529811}, + }, + { + {4738081053584946, 2875665464097852, 4082354471082712, 3079977082389326, 4643006842643895}, + {4085499965974240, 2403823491084742, 3352533311494316, 2981802103584372, 2409154352569497}, + {822917758900752, 1019777701975664, 1564136027018780, 1218107309963297, 1014127758290355}, + }, + { + {4211670720265322, 5260586114139374, 4117778612287885, 5761523698172883, 4942445429900242}, + {2233928901439648, 3249090656816698, 2685023842449397, 2515328324903077, 2780554742949852}, + {1119507853423473, 902873322434013, 1683813506511239, 99271672214794, 1043609318229518}, + }, + { + {4881172173279202, 3599812968457896, 5389450859587312, 4590538673755018, 5926347639505399}, + {2643454724039014, 1385194776028482, 3573341970152704, 2554149121763820, 2626184303949707}, + {1041863798926969, 1989079677249410, 910600041636905, 172639986070412, 958797345271109}, + }, + { + {4102514793801097, 3799057862785664, 3089506143944932, 2968464716766741, 4933382932746089}, + {2671084000631505, 3069928136724336, 1615118202102194, 2860128525830493, 1072943882334681}, + {2239551548278550, 1569208624262185, 270318489599140, 666224807173956, 272660472277513}, + }, + }, + { + { + {3788400011322929, 5238791757709216, 4201438471307196, 5718998504437804, 4699660978114753}, + {831848399557275, 2203944328508070, 1205773492199750, 2947899883606056, 1258775953756159}, + {801855642469056, 1726062700700587, 1064722548099106, 1128997468587175, 1368420390253860}, + }, + { + {5220756346668707, 4207778951928942, 4451591079714714, 5561602467108901, 3701332347939515}, + {1095027470911861, 1309452919940954, 2417363745862806, 3417231569067727, 1895316643922203}, + {2142749866659158, 1962490102531981, 1691447155265793, 1827079035266074, 3803331638058}, + }, + { + {4981668826515757, 5644770367578110, 5443857182354756, 3149391452129516, 4066238206100559}, + {3356282538281353, 2251921811216688, 2887149285344786, 1384857237573084, 4057072468959031}, + {399619403797256, 1517816986720610, 1503473770785461, 1650204761619743, 2016574488970872}, + }, + { + {4082671840470154, 3874834197714005, 4437883298126266, 4222220664757293, 2316031680718393}, + {1452497321657782, 1539338328736177, 4156757905713634, 1587402592924883, 2189645592400953}, + {481460971838645, 495603062939192, 2081146895236470, 971761350637757, 742727604094484}, + }, + { + {5515673501962670, 4546389793895825, 5000269413610660, 4603828815474748, 3900836987569214}, + {2460924811417180, 3521984551624439, 1511404974611240, 375249799211988, 3782407540620780}, + {2048665788177445, 1408893800498572, 1918636993246022, 317961445367427, 656800592778138}, + }, + { + {2426976075633155, 3651600221015543, 3234264849290625, 2473309309095632, 4407296503206636}, + {2422350949934017, 943103623278343, 1291301021890213, 2346315203451818, 4112725099426082}, + {269878912827170, 1290670313639785, 2170448731381563, 1730590899024060, 665688666929019}, + }, + { + {5000413361992888, 3347912965056552, 5787242209541388, 3819792442922756, 4847625000360540}, + {1580177441875156, 2506058297611016, 2934789696579346, 1061310370544480, 596660656376680}, + {1957905575869340, 963138800079095, 1346185076450932, 33814819376238, 1624717058267694}, + }, + { + {2861980301667765, 3354887551296141, 3948074513800240, 4019265998902801, 4754514631586968}, + {1661216359883315, 1198665005326425, 3475476495296842, 881743418686047, 635325796191538}, + {1196599610725063, 2100294611545468, 412113633351820, 925880965367657, 519930913383517}, + }, + { + {5571468672275863, 5188072583684019, 4251873319339365, 2576514881889354, 4045293404267572}, + {2133507738629437, 1327217318093765, 1889369311142453, 2479101608310052, 4045149986308216}, + {703846410484025, 1348842341032186, 1685275777321460, 1615795108904065, 1475415532006380}, + }, + { + {5398949984609248, 3762655856514160, 2412712349948059, 5169973908847336, 4334869322214508}, + {2999632416625302, 3110726069588902, 2228895586394623, 2800522251491198, 2224895404394358}, + {1399061587160944, 1205421803029276, 519683572464804, 340023786200115, 2172700699519595}, + }, + { + {3574689489677767, 5335925023065998, 5369256661040087, 3129592424352108, 5388737531811449}, + {2700892402458353, 2743476698281872, 1953844576554527, 1836651043988628, 2962536972306493}, + {1357694877428531, 1765161852606993, 1167042823088862, 1400958578522448, 1847208195529391}, + }, + { + {3867728253589687, 3773111053869328, 4368860594965835, 6133882052967679, 2533060702765705}, + {2290736769578191, 3757556884488538, 782075793204873, 1953945334364505, 2306213589322841}, + {1820300206186415, 335405661683482, 1092574996911739, 2062461927997493, 39506950020151}, + }, + { + {5534612992751919, 3746157517504511, 4108089392798474, 5131771932089590, 5617809945843001}, + {1342645331878441, 2000053418116353, 2168383944146424, 681027567941522, 1213562615764099}, + {379321638440622, 996302411355145, 1880571763884906, 1004856333759537, 501836588196832}, + }, + { + {4231662813561705, 4640318983129989, 3064518357303150, 5343343094006261, 6450142130522077}, + {1145892199839501, 1078673486712789, 3022417549910920, 1612895247211701, 2324179764588241}, + {1972676776834949, 44492199500322, 1456097929669866, 211262343295697, 1045510624803264}, + }, + { + {5968931973016112, 6019428128447854, 5757013441564652, 4431402751536781, 3192943415309330}, + {1480229165025206, 2054505377286776, 3099784048655970, 3055900157449953, 1375885673210420}, + {1812738520892942, 2084676765238369, 510773948276259, 934572202757904, 537600238103234}, + }, + }, + { + { + {3613080834135665, 5774088788979550, 4480966629462376, 4981692702949983, 5531898286124606}, + {1941100238292769, 1530763972357988, 2941717574786124, 517834246099701, 3268301290369396}, + {402477551873128, 1206353712079331, 1931900782149571, 353151698548753, 227661813611943}, + }, + { + {5770945118915754, 5544555209532203, 5448202195803091, 2841016429831070, 4428081881985983}, + {3042160696267866, 1193039775906917, 2708874250955853, 1880772252763310, 1647664574467171}, + {1801318854301087, 529217444026518, 41439150499132, 1819497139150034, 1914318279506430}, + }, + { + {4617843866085510, 3963473780045850, 4530695843220841, 5152831422757274, 6255165884461126}, + {3653392334037390, 2119290268348412, 1662789932544495, 3712853444146946, 1761023449047586}, + {1892648843913435, 1079776332626104, 1111039290977790, 1827479485396386, 859677304170245}, + }, + { + {6135115193251795, 4578420287793605, 3485955900327480, 5405600312155654, 4983545824887909}, + {1955745180210457, 1703319703537271, 2019166049085294, 3363246542620192, 3873119138750761}, + {1700391063795585, 361747633083750, 1216968456947850, 1993842710713264, 601267006969711}, + }, + { + {4925286822096059, 5955810075280268, 4224518592023607, 4497079033823924, 4700697585549198}, + {1335348453199749, 2692696552964594, 3243268312448681, 1958567111536422, 1194502970771976}, + {1656217138482787, 491628805607466, 1679451179466805, 970181505842258, 1534105889461948}, + }, + { + {4204969625278834, 2839735694548476, 5311815348914771, 3424730456556302, 5437312551033891}, + {1051919605857270, 2689758516764280, 3195630903391853, 2321619474659180, 1445811115388039}, + {1160289603260459, 1956223108351205, 1733312353955470, 208731931777063, 2163609865075088}, + }, + { + {6171922307530267, 3416689909413961, 4398780048782414, 3348704297294309, 4794281577167533}, + {2605760676899691, 2518935989171471, 1655039766011588, 2352706753121153, 1606429966007503}, + {1142834714776341, 85770505106288, 713866520631433, 440023537352050, 178697006218663}, + }, + { + {5369775152479351, 2976619105904851, 4320166487861154, 4349283416973378, 5052617030572584}, + {1815823837273367, 2562753791013569, 1539789395052836, 3647749880076906, 1631063017998020}, + {534961844628464, 1393583055120721, 1748351260324708, 1375538226727024, 2193309623120304}, + }, + { + {4362511965756519, 3334861441534551, 3560279110881819, 4504033277345817, 3695270180099552}, + {872424258749169, 3269419467389617, 2236476348626173, 2024356220545311, 2898783963621386}, + {1239822839121281, 1734625037061034, 1644113104753887, 838912630061655, 2165081997489666}, + }, + { + {4719668160615989, 4954232553381592, 3407504093515639, 6056696583065019, 4080126483053229}, + {2648578609770085, 3690844259333424, 2082598280716609, 2564691042641275, 1346520144951773}, + {1979149515238517, 717801405945362, 2104011649567412, 1561125545440573, 2157118688047562}, + }, + { + {4177174713439601, 5431484182531219, 4912403072956818, 3423215719262779, 6067629588380508}, + {1808742790957793, 2747803311617739, 3845306078978452, 1924084822718509, 2264852519642740}, + {1767189866398838, 835676264200014, 201596448765126, 1979907908451931, 1442810524651041}, + }, + { + {4409296057792696, 4346067875211154, 3459237364299404, 4853798679576266, 4468808308660588}, + {128841748532646, 4150186054273698, 3256924437045680, 4019614742906956, 337338633748078}, + {1077226425497346, 607378044682866, 1485491791574172, 1074180848747199, 1023053128705595}, + }, + { + {5804603278915694, 2796027819585631, 5011026665884139, 5833743165576011, 5103566912764066}, + {2493359374165148, 2464080592904187, 1933101226851633, 1880342534882667, 2417917477223840}, + {1284426144747169, 2005093245564178, 229493920382094, 1642769566056222, 1596652614163344}, + }, + { + {4478501502615841, 5105996638711000, 4307245809257853, 2912192821294412, 4442483575340114}, + {3490678780709549, 2722972627744756, 4141726367382933, 2626667232874306, 3706338015195278}, + {978951056774557, 1610590016630807, 2160020521521822, 2222969528403014, 1290838415735858}, + }, + { + {4233395101645091, 4760048839668621, 3419853204404814, 3555462417010423, 4295491197124032}, + {3136023326660957, 3195581484142287, 2364500047372050, 978391045278571, 2088093684065312}, + {319754006496675, 2078141843592369, 1381704035073408, 2135424637477137, 1217419566529670}, + }, + }, + { + { + {5290773769928918, 4793813444262905, 4720763845546248, 4081316225438835, 4093406366409350}, + {2219813055094868, 3751054103166673, 764148091645988, 3042364539660805, 2174498914560536}, + {1346839273131020, 1947175237418499, 2130499171815608, 841760904333801, 793011313347544}, + }, + { + {3890099439122631, 5436725454634839, 3526358179473960, 4130205528836253, 4143183670329231}, + {2705685430041151, 1931337763813343, 1867986078235466, 963301853857219, 3203544659615889}, + {548016394257586, 1770170736821935, 883041007523403, 1244492123782548, 1874837894534970}, + }, + { + {6107029440448048, 3899130796270571, 5350832732145407, 5288086135111572, 5016688224136320}, + {2322745137203416, 3712079434453421, 1656136902347805, 1063047643279494, 2347290530652372}, + {1585044732618145, 79674660750176, 2047172033863331, 558016866726219, 1811700039750197}, + }, + { + {2903508896190354, 3572836747669154, 5671992452104047, 3145254132994495, 4870698970274559}, + {1980868732324310, 2459850087283418, 1500353534094477, 1977074025846907, 686785408890947}, + {1977199595236300, 927859862391871, 2045825765550850, 1189431662969386, 451125616133550}, + }, + { + {4264958907260919, 4637613300323186, 4723189721727247, 6439587034668993, 4270210266819895}, + {1981177153373343, 1776706813610008, 2956634306768875, 2113399644330229, 364175990188877}, + {1473984112024647, 2212143402178000, 1913009700964560, 489799262080055, 1390546130501803}, + }, + { + {4617432771154388, 2768922884406316, 3194759053322417, 3846588214005790, 4684848439540931}, + {3696338004009516, 2296500736839486, 1483385825107721, 732704435299560, 4093200809844903}, + {781495195344331, 819872919567170, 2058369589741763, 131552040816437, 1143952030551876}, + }, + { + {6045398880892501, 3274164683120730, 3537206235588588, 4953070760072151, 4494335279262109}, + {1632591054957791, 1584029964350608, 1679919371947982, 3412378076716233, 2572356071530817}, + {118276417181988, 2048136038162801, 1736078553924029, 677257986431580, 711847529279284}, + }, + { + {3634115225339518, 3407128374975375, 2997970212274081, 3493862836273928, 3535607408159120}, + {3574732327388664, 2600283522407089, 2877235052318169, 1647316986471086, 1495874784707614}, + {889518489432828, 1216748566987677, 2027061052060458, 268044074097160, 1539610510772867}, + }, + { + {4611501240201625, 4770963666624495, 4338415201879424, 4860883825935208, 4028006785359735}, + {259543849715615, 3116307281996357, 1555340861337048, 2140193697629416, 1035789313751911}, + {1026218773492650, 930245039288082, 1822875264087643, 479782375672284, 1931812455503119}, + }, + { + {4148807861057856, 5812728864755237, 4601316267327746, 6043565150382029, 4199151665681887}, + {3394871127325058, 3191785534223821, 2085795470524552, 2385926585602461, 399655200529949}, + {1057229833653287, 1828041669558530, 1006577782987596, 2162474092618005, 1568476132284973}, + }, + { + {5547684346917888, 4989218016843942, 4586613652979209, 4863124308009928, 6207570019680129}, + {2566237642336854, 3970491812994094, 2598212316441047, 2240782240471054, 2552742376593093}, + {716486226259134, 773421749453144, 1784612269854183, 1741938572500414, 1834164482186148}, + }, + { + {3117421109623856, 3461685839753353, 4955306417606165, 4558294861196235, 5602064404959934}, + {2273224772261066, 1223111129900149, 1584682650834635, 2022200125401455, 1373728084078920}, + {913182622593832, 2001872744868184, 882970207556847, 299806317329996, 1726046908726060}, + }, + { + {6249588231739606, 3368998262120903, 5239047789721372, 3406210943086424, 4754518606052966}, + {2248618336554706, 1339184282498129, 769038678141320, 3217160515726744, 1715873134108166}, + {1976228100247818, 1272400462149307, 1572190226615598, 852044049472028, 1055275428347366}, + }, + { + {5284373775928701, 3618431820022764, 4020557586503952, 4433032839002146, 4171326821228907}, + {2417108732168755, 2170003784635000, 3518440054867754, 3152772966589030, 704341378948759}, + {1290493724571150, 2122276831263561, 1747969631590180, 1399718798480988, 139803941068636}, + }, + { + {4427994415528072, 5149611644022833, 5193849655888518, 3398788549762908, 6113634201730634}, + {216319500947386, 1455486684654953, 828483179169328, 2183296040357724, 2625210482982860}, + {478303205586551, 304131100485205, 248369703081454, 371320991720787, 1635813582756365}, + }, + }, + { + { + {5252346966668309, 5639208782676701, 4075417215389880, 4364690112290244, 3384680235809138}, + {2429491642409009, 1283094434250487, 3316839113847160, 4229629869361324, 2675780619596520}, + {2176454779743876, 931093459142961, 2244697379845986, 723779257225747, 962795008037376}, + }, + { + {4164637625281563, 5566305816206016, 4655415916130208, 4180775155367792, 5707768410211632}, + {1861517597691605, 1772481620932890, 2629476438960640, 2705827759458320, 2107910124630170}, + {683279446283480, 2167544438614321, 1975855992985379, 780955320484514, 780910621778643}, + }, + { + {3955544259328322, 4458238333874171, 5864190420414532, 4345033257929994, 2857162289792042}, + {2686358254975148, 4179751356732233, 2499687248272490, 1241163995738960, 2778131269016956}, + {1074884828909420, 432905047961772, 1185537826254838, 52144045776742, 1826277929133963}, + }, + { + {5684453359674447, 4877177488298427, 2422407833284604, 4605478777171110, 4729984701613103}, + {2156715047802967, 1276772803921323, 2380233522537438, 1960794365816568, 2680384519257273}, + {1862177374063425, 1873700738552432, 308885709393483, 2100622082080360, 1104535253282502}, + }, + { + {3931149063775879, 4254429699498962, 6662929352488607, 4079587572542558, 4855364761755442}, + {3711640686247983, 421582154826228, 2220646689506683, 1208894292386914, 2152820272048462}, + {1565335522994081, 54406341126738, 599331788389250, 1486039135212823, 940991227185565}, + }, + { + {4398457498029638, 4929754658751446, 3952574300737926, 4493043596943885, 5305461811863411}, + {3849064215739384, 4001520908708098, 3463231867051918, 3642198741522237, 1030072339730421}, + {225800753248600, 1001289196776939, 1570695157447337, 474142387326152, 1860241406570283}, + }, + { + {4817367953033495, 5599987240264127, 4736311445242884, 5430531336232182, 4460173530026570}, + {1052973111938531, 2823516883980375, 662638871434014, 2738994056625648, 563864123356550}, + {823857549390635, 2207592640971793, 1855512257490888, 1911413747439725, 1853809846918105}, + }, + { + {6194718989753531, 3626032976625365, 3751630707315810, 4477700840286220, 5452904257109698}, + {2036109024667887, 3040585821349743, 2780985384011476, 1970818175728284, 2968438634461420}, + {695616701038646, 20368455765111, 619664083096696, 723635083382804, 1023760209767255}, + }, + { + {5008707213573776, 2859949901187285, 4290065003741713, 5151870738966180, 3127611889915462}, + {574462324973718, 2125329428751385, 570545018291281, 1476031513731508, 2680835412613570}, + {1517596182333361, 1429983941782802, 1900615890395770, 1911469027059364, 1851356681596334}, + }, + { + {4891662727757105, 6078189791872620, 4341252688115798, 4009612276132060, 4158882628774497}, + {2178830616846417, 2794898270987790, 2339865206643716, 2923242275980220, 1745466521002355}, + {841969861771844, 1234567333486718, 2104638753106763, 1445233761721300, 2209267998342752}, + }, + { + {6440345201923204, 5723637287574387, 5903930483115066, 5778502423080164, 5079904071191760}, + {2035275243828198, 2745418930619871, 2632830605513978, 2519743098631716, 707209224772602}, + {2049800384050253, 382336843047910, 1465264697408643, 242728978654073, 1821420259893325}, + }, + { + {3385848358825911, 2850931104925851, 3458310588278305, 4579597908985563, 4607881337942919}, + {1816700573507985, 2213627388818419, 2637198541463171, 3087473887817081, 2837589033715179}, + {1073720617318924, 1636814037227948, 1227321319951543, 598345156599653, 544027576937438}, + }, + { + {3741365114761762, 3465142572701024, 4346453033629668, 3800732328304411, 5207004929940855}, + {3530134215235346, 1497788707695478, 3538247705814828, 1425334926184197, 3292646832985731}, + {368165631658486, 1427424960871770, 667823977725231, 123986789130850, 789476314816796}, + }, + { + {5183377371949700, 4172584964939172, 4687335701106073, 2534986101578472, 4297053492878574}, + {2375597255557748, 846038920993436, 1398943082722053, 2179038637021886, 325133433602556}, + {1814357252172511, 1812991482130874, 1545461112716185, 2228739665628687, 1030416912136148}, + }, + { + {4102150726478441, 5089888860858732, 3167069131929673, 3336166645247640, 4708635432875520}, + {1325239906989203, 2989936170895398, 2414201768248283, 1851733918704382, 3428546124237928}, + {296568059020374, 1937661788490502, 1994712548479216, 1341415580517821, 919259617560208}, + }, + }, + { + { + {6274182990169406, 4386048988056353, 4097025350643424, 5127499815238002, 5572164902186574}, + {1895408474337392, 1335954976788533, 3236941534902540, 2378721630147940, 1461766309882914}, + {1291953286798969, 2102679466898679, 1596002078575263, 1387588817990761, 2143444637427225}, + }, + { + {5996694561997207, 5683227612437284, 4899213524992592, 4856689735436656, 6404791836913969}, + {2772496102790967, 2917238652453944, 1731727230740742, 2247887220248582, 2143609474706149}, + {923819152192005, 1415712944791087, 1125410698033067, 788009900900011, 869993295869018}, + }, + { + {4786795669239288, 3398808358640920, 4513626939909643, 5985598090247291, 2945790096837940}, + {2456756643078196, 3060894189290238, 3759434421535873, 2442805763764489, 2819028797217160}, + {1757819380032415, 1458259160758992, 404747119062789, 1242483165113555, 1521264843142355}, + }, + { + {4457446227801342, 6427880138295914, 6656730008666805, 3937171933580687, 5754864538579708}, + {1177246463904108, 2488433613267172, 2328478208484747, 3802230570654315, 2344609059443716}, + {1519155588261854, 483899768651806, 1235345257217886, 467640517750393, 1224438957323827}, + }, + { + {5102603430061893, 3128470923287158, 5801341356388264, 4525678559978591, 4718363529583899}, + {1246208485680505, 2848653521425806, 2416405253631000, 3077610602170527, 831805919056409}, + {2045656886162419, 2245569838876242, 1361334406977685, 1370170063372453, 1784586163491838}, + }, + { + {4556063502635342, 5531207665521536, 4057497943029825, 4507014901377590, 3148382369498868}, + {737891874041388, 2451689755512888, 2972729929575783, 1153163677723624, 2631153364835664}, + {1021578499394252, 2003506226907156, 1906928204664703, 617432881327189, 487770381544088}, + }, + { + {2772215428108171, 4464024296635705, 4854458470465137, 4051326172605262, 4041843916653002}, + {1808240492311657, 683215352347115, 2786075502512133, 2784661866757750, 3917451132840122}, + {956648481954026, 2096247164218896, 1027480742584033, 928233599700570, 2122240338574709}, + }, + { + {4629946233006760, 5291553581528148, 3270843847622640, 6572477208034336, 6154625523788459}, + {629205712253428, 2948018954745502, 2240941577462354, 2419373201820060, 2682153541398885}, + {948811544154236, 95827271348811, 971972540788513, 1752656910961976, 1577613288465037}, + }, + { + {5687495579915904, 5920739705585144, 3623686905482864, 4279799360588693, 4937051703985742}, + {2733819029729102, 2941383700719094, 2344126789319304, 272099344396033, 3469931440006564}, + {1155109808876838, 498663775049656, 2009409241380161, 1654861553852237, 2195711930770443}, + }, + { + {4562514450276878, 3610360397280214, 3754786033717112, 6274151337271952, 4102082344471456}, + {3779237395015718, 2531855739502292, 1076300728317328, 2341702386635930, 2037036009072308}, + {357187236460800, 1343207422743391, 1557831743447331, 138875622916216, 2073308474766668}, + }, + { + {4318248447888802, 5457191060945059, 3575720381879889, 5537122891348075, 4658291618481620}, + {1058927027601226, 2097000197595935, 3018484019405255, 1294660112618737, 2932877913314978}, + {216145844764492, 1876995804123388, 1188737931982599, 1588244200049402, 1850009625550870}, + }, + { + {3352537291082093, 5839102984451201, 2319458858510810, 5312519694669356, 2539572161961088}, + {1971880260906249, 2590822963635857, 2283171542295386, 888730652847270, 2069077006720618}, + {986114249350619, 899447833294837, 753796294360457, 1686315816498457, 1484432111173806}, + }, + { + {5781412563046772, 2829048727661187, 4098529237644982, 5146692071916491, 4319033371720950}, + {2231959129524362, 2353147866489543, 1361542642038984, 3436571318049649, 613122764422636}, + {1553151906564201, 42706246613546, 1656634422023210, 337580524133816, 1382068281260380}, + }, + { + {4318188098974879, 4190975253205867, 5053353859489555, 3624409471895100, 5734877817656224}, + {339244995001665, 1760160432424305, 2510143032086917, 900873257630652, 1381243383153778}, + {1027887039599863, 645983151773049, 940633405940384, 791297293294468, 113951612418342}, + }, + { + {4421127861301280, 3227473132618256, 3897823766346675, 4531675054348192, 2597262173415879}, + {497984229256388, 1528193624284798, 3083402776323261, 2834076054300848, 2004534517066737}, + {707308783184531, 1723910086807466, 791458836921758, 441590831592448, 1945299136569002}, + }, + }, + { + { + {5139590791061503, 5074296034161507, 3861111523264964, 4286794753368429, 4613589462411916}, + {1370912655100557, 2279879075953359, 1535348789227130, 2242808749632369, 3061442465980918}, + {2128769772677977, 2142654242576520, 2016094652496998, 2132031230853467, 725434888027655}, + }, + { + {4677803618766960, 5273930469290190, 4617970826042730, 4133081282480847, 4583310983505940}, + {2135073895739904, 3472442449797848, 1493509767807810, 3843639135014989, 1420071562059334}, + {1420603492551010, 679640550295814, 1617533903828801, 780154362635607, 1319780020899258}, + }, + { + {3937068127551315, 5594824685351819, 4538337787238312, 3523378410763828, 5437114214061846}, + {3695575212053185, 2594449599707103, 2742930959436192, 1161286236132678, 2345020968733648}, + {194815921686333, 1256736762545940, 1408742447743650, 304562218341097, 2021464306176092}, + }, + { + {3212222966285493, 3266851872779616, 4336733687401440, 4794872810759007, 4424169619295461}, + {2759763070229743, 2724175318859802, 3031057691838938, 3431189823632909, 2961517144339711}, + {440075250919582, 694825884103652, 2159700403414911, 116894270435230, 1425927073727904}, + }, + { + {4841955313295828, 3461757100553382, 4305435906781420, 3691116875116057, 5298851817605162}, + {1064910415642974, 3095607189587094, 3908971853500052, 2189460887246833, 1354043476687700}, + {1262675707031055, 1219816744922490, 519257628155087, 1497570437960201, 1372594887264798}, + }, + { + {5466094472208141, 5012579346250577, 4661027376097750, 4434802656317810, 3968075278352583}, + {3315525263287981, 943900907578117, 1225723797770692, 4182671057889152, 2697481958411475}, + {1933555860608921, 1275569655188916, 234812135397482, 96042287368239, 386392083574324}, + }, + { + {3319477981428303, 4681888525996228, 6591617607940267, 2604452186053658, 2972488992219816}, + {2831773176554005, 3864996001314642, 2395563170308483, 2090271503443448, 1893990359510416}, + {1681588555670186, 980191207008201, 2154581399538671, 540872424183046, 1943954489289499}, + }, + { + {5977124761029192, 4538331973533215, 5533519881915667, 3479901172100047, 4656405250637608}, + {2363082790805374, 4242757803000485, 2669759818118169, 3333816374844969, 1325118659202748}, + {183359648873960, 382111728086623, 1969766109298473, 2071169946252387, 242935538497060}, + }, + { + {5188738692165469, 2664732629276594, 4968279324223179, 4960443399326301, 4436427572176893}, + {3490990196257229, 2560345203268680, 794851537166791, 1532423795715657, 621302931359813}, + {440189527159075, 2095498912423497, 1575373142262611, 744594360742511, 1157079567398109}, + }, + { + {4869958177792820, 3889970905101269, 4570550615789326, 4496205440964732, 3848931098885666}, + {3870071548603662, 3041096274835181, 2350925463456272, 1091637746528482, 1355815234248438}, + {927792763323382, 1304575354366273, 612939300770904, 1630367810979451, 174107168815644}, + }, + { + {6136927367908702, 5203222247970547, 4888252310796559, 4897189790028520, 4586519387439588}, + {2831448685067634, 1668205588574421, 3161976938852725, 1027424964992432, 2026369259616642}, + {1735694076750726, 1266349638286480, 1493849675863588, 296961022463490, 1483126610434799}, + }, + { + {4654087895073878, 3931119431920957, 3810992402627745, 4571904269427127, 4481981159091504}, + {2466558329032204, 2314404658847041, 2524639581935109, 805442192808499, 1270294344302086}, + {750996510156456, 401855193068398, 58073276915611, 87767580153872, 241880537805683}, + }, + { + {6336062814229381, 5495468976405173, 3085611334327622, 3929566749867368, 4056705138744772}, + {2170745323194467, 1059898966987983, 1821678094574528, 3224522071822304, 3177794562815748}, + {697769608468752, 1369430004061620, 1388586673198089, 909114275708814, 1146450457999407}, + }, + { + {4238043779316857, 3868604149115822, 3602737573195351, 4491948926777684, 2593111277688382}, + {1942420724187743, 1230266918978492, 2950156777850293, 1491177343837674, 2151732388834046}, + {1552628609460396, 385059438618066, 1935679554618991, 1586643703562239, 274738755241324}, + }, + { + {3708634080771636, 3376471647619972, 4144079859874091, 5260099970974267, 5044960426451952}, + {1260464362728368, 2320200151112594, 3280988120127265, 1454370155862373, 3222503455600234}, + {1286187906300863, 286639393218233, 960541512944676, 756511343610150, 732619979206969}, + }, + }, + { + { + {5720776037989329, 3408557855252881, 2836745411300455, 4905300285896935, 2440518813003965}, + {2216608521812979, 1133671267609171, 1886801270451833, 693723450681229, 2177664326279079}, + {2233307833752057, 720411965215730, 1519169695491573, 1249545629073374, 42274079495163}, + }, + { + {5289248568149457, 3817875509053716, 4457685664702894, 4876101051290378, 4294494794724040}, + {3280020244834293, 1318628129209810, 3119398368735896, 391516159010622, 618793687544686}, + {354305362086679, 1512134460741612, 359672307646707, 182487842123724, 70434142068276}, + }, + { + {3945557653570869, 3088092003227000, 5454351386185562, 3234451172420338, 4724702104276340}, + {3276624651778803, 2433844765263326, 2790865929084436, 1963658167580138, 3140414260467690}, + {46706548238824, 1986500518838735, 2027136585204085, 1143580830274421, 237034819567290}, + }, + { + {3929429576586958, 2793383744028645, 5887317021163886, 3203394573309402, 4670385004087593}, + {3462257554153900, 2215903401275259, 1545855048122212, 1560256833448838, 235678314205821}, + {1032532177573683, 1507169914894481, 893954872249259, 1464210961075811, 2248024514969267}, + }, + { + {2517873563818259, 5567259846017152, 4253295986752699, 5558170137710973, 4039120007239859}, + {2215196432839229, 1453988298479780, 3162959582154309, 1417180860727485, 1916001465630095}, + {1593076635649167, 613414152324278, 1398118686752976, 1550186634066418, 2024312475795755}, + }, + { + {4524027900175525, 4847878416694692, 3091409665235077, 4862578993236379, 5350599804185218}, + {1611115816843085, 1564686497935112, 2631443498765253, 2543391790063645, 1070282314438176}, + {1370619542022553, 13593976629245, 670888839522668, 29909561835083, 1113994299778657}, + }, + { + {2995680265327027, 5241715165954044, 3953258701883675, 3989602332635833, 3953848187775337}, + {2462467670415027, 3084380814586442, 979195344857407, 761623507948939, 2354116769190033}, + {1653806661942935, 798938977173667, 1204504651898865, 2012775328403335, 959133953735021}, + }, + { + {4988340255562522, 6250762111649497, 4210027774413747, 4281026073914171, 4124289570254779}, + {3308091097868222, 2438171792492677, 666572176305849, 2221533064225315, 1302577527793701}, + {2246982488380161, 704048527252770, 449031029656446, 2000971659049725, 1830758195793359}, + }, + { + {3190675561821798, 6722820056714491, 5018399111078811, 5991624407670525, 4249280343842061}, + {3052270247598664, 2252472217742059, 2434081171992329, 2672797197928279, 2602890651310523}, + {2144671346446832, 542864631780587, 1155108742000404, 1404732713614448, 240293866423412}, + }, + { + {5121381423145567, 4833873167604293, 4028173334112257, 5524034306881884, 6230562353876706}, + {1307308592059221, 784383479594685, 1720750519626457, 1912081034355222, 2024784929774716}, + {22174994285057, 375276401373336, 1210941030392323, 1903374444438123, 1011323371888298}, + }, + { + {4798470629258750, 3939993567755513, 3967862752630070, 3290332526819821, 3061464921693387}, + {2998794565294986, 2057935584763381, 2899577223808862, 1519188817940759, 1842063844888831}, + {892208073348264, 1880270486117637, 1866139692669281, 577642276098528, 159304923876906}, + }, + { + {4601033632870689, 5799253896657058, 5779104046600604, 4218473381777077, 5066296163965867}, + {3118817410699903, 1416293682313136, 1358642285736990, 4016697695252823, 3785048363131621}, + {841452637470330, 509851329084465, 315943768852800, 745051417948746, 1317978823624451}, + }, + { + {2960724265045759, 3581409910547792, 4757575913235420, 6009932939538924, 4725476498610383}, + {2216474880678649, 1883045416719140, 3557095587267860, 2414252121862082, 3019618269128831}, + {1790146986408439, 1266311794146205, 923857310756466, 2043374401317120, 726369229085659}, + }, + { + {4878312571596775, 4222794967531206, 3321677379160160, 3406594510676891, 4743132105473153}, + {1047639500605479, 3268483579465284, 2206428670313250, 1688287562131353, 1668007864663417}, + {1777656298881359, 367886496899263, 1134571758927624, 161297709883194, 864111924164392}, + }, + { + {4770637647109604, 5356580318440110, 6456410085143486, 5251963198009528, 4612863117603799}, + {3459496839496426, 1172866796116672, 2087657719164010, 3611579473502448, 2226199443508323}, + {179962092093812, 1434865358203901, 1509301171184812, 465007053005824, 1606826267425619}, + }, + }, + { + { + {4321570421086801, 5728967329483361, 3790752945733902, 4440201295898093, 4632192800649486}, + {477207916553285, 1488064260202941, 1661453866463954, 1141228074051855, 672072650786576}, + {916404312971536, 1000014350915647, 1498754584389763, 67530592482209, 1667646385756724}, + }, + { + {3838511633005352, 3067059108181153, 5859654687359949, 4517853996250692, 5491933645129578}, + {810369747020164, 2237618141036509, 2282241440976077, 396142955464532, 2314156456627292}, + {498205650210982, 2029447832739442, 1287708517665602, 2063154761502015, 592549403529808}, + }, + { + {4850172605519114, 4864656344540316, 4532814144934823, 3437824613452670, 4812474608554159}, + {1466752538541840, 2035538193320560, 138132610685025, 1256421706559322, 2431850955679681}, + {1297525937307453, 1360474818962172, 1057976529132470, 481516036122456, 1284896343639676}, + }, + { + {5776741280656995, 5103737594811281, 3360081478971068, 6111393754727746, 4779680024426854}, + {2645933668955707, 3274005597891379, 2656619141981518, 1746214054851430, 3053032647501696}, + {1625278703177771, 652272403287866, 1130860155562117, 1467718191751280, 170296377586353}, + }, + { + {5094219073783849, 5735075135248235, 5606322495206271, 3754059419692243, 4180105537366398}, + {1002349488419261, 3232903243006485, 1398184721429427, 3601262477434907, 4062926820203090}, + {1577778325058339, 2215369962281551, 1331723269758849, 1939632256423674, 52886968354553}, + }, + { + {4933187999581607, 5092493367263378, 3356435735616918, 5217407324510779, 5497406740649621}, + {2729077630033003, 1888615867921888, 2296393402013134, 839924021249031, 1005736290727363}, + {1035587952296453, 772571610990610, 1703146381743864, 447715678256778, 1714287687955168}, + }, + { + {3002761637349276, 4331640081948673, 3834120280377754, 5089609293083651, 3261373019366335}, + {2386307482062396, 240967146617557, 971317535064000, 2019271157069067, 1502539203059821}, + {1328811798417377, 1232170334974369, 1723370191641238, 2166559558468187, 1898556240276951}, + }, + { + {3941047590826269, 4239692035015583, 4490403838767533, 6564872456977192, 4670461766802655}, + {1386180360119611, 3273074614881159, 1729880193705623, 2228606406348098, 1592392117444361}, + {419731549689034, 1989626747750813, 1591278351630992, 1092786235861584, 177178675215960}, + }, + { + {3436683241673758, 3662206674778039, 4373967447323555, 4097363846812803, 4031597646782708}, + {2639672814451512, 3326947991249179, 1680625793199947, 2034248047548953, 721741001003862}, + {1591050698007192, 1091674239474205, 394086386458446, 652864259466208, 252826649880832}, + }, + { + {6202959881484310, 3301137131128391, 3338332791366416, 4386834101046813, 4586134902683138}, + {1761951583445986, 1682354370625515, 1311814077921538, 2232552485157187, 352715570060390}, + {1983847550347734, 1877133028995354, 991701922936357, 942306684083689, 199141297262892}, + }, + { + {4356558984118475, 5693420396107718, 2518386381195401, 4410955637518553, 6067546162903212}, + {748677842691767, 2802469894128656, 2167458034960803, 3580904381157207, 1663021749531972}, + {672345752527423, 987721649439917, 75559353638139, 1202381658061142, 2218885179346238}, + }, + { + {4510531718276206, 5025970311617705, 4298550255570023, 4702464919238073, 3154067300975759}, + {874026063340854, 581394977884979, 2805876061084699, 3945101577343195, 1873084195329207}, + {262642087469467, 394043452244726, 1877384193205089, 135064540003798, 932774458922892}, + }, + { + {3677176615657209, 5004677940509387, 5802006239792640, 4988806137854665, 3142553109499622}, + {2906530412387425, 538942497799423, 3006485045211118, 2701192894331127, 1774793046411044}, + {2163097510860120, 1657639324428092, 324536800194710, 2127826550215010, 1492179302504548}, + }, + { + {4271383757866077, 5161359851331481, 4409665194889791, 3535427764785290, 4743868535366280}, + {2870306695118697, 854883599481521, 1175220622088095, 2190379234235038, 2693308800279672}, + {1469265779048270, 1543845332050728, 2202017995300452, 1928013995331013, 1762032763505452}, + }, + { + {4636656908840010, 5500309513430418, 4897834655713547, 3941193903783821, 4553608952670061}, + {4333916659134460, 1850388591545996, 3627944035206357, 918659547384777, 3374247281351833}, + {2000039510485295, 1183834045401091, 1338556774925931, 1549179790309018, 394428288927656}, + }, + }, + { + { + {3733446780128548, 4970314905751830, 6278139198254466, 4792154002496454, 5723581693713173}, + {1185838263017942, 1658025814770644, 2664414501602854, 2015508295646822, 2967017530049915}, + {1569664128884381, 407663338845983, 2002256010544711, 671085899312035, 984282527793076}, + }, + { + {6341328981945826, 6310526850187699, 3023871274454732, 5578860681574207, 4775900505114104}, + {2574316560560394, 2331223963461233, 2542672004494602, 3174853647927431, 3104624426621216}, + {946711433665760, 2239987349934557, 803861660898522, 2156551410386926, 1502787654920122}, + }, + { + {5437578969471140, 5951179206758851, 5248530961634439, 6426502251854756, 4209704034918088}, + {1002763931894790, 2216555692070697, 3344391891538061, 2095372815347836, 831620519830306}, + {2050669866355306, 2190774465449013, 2058969733807763, 270320273862327, 1870514939355617}, + }, + { + {5155857617776227, 4397988213497465, 3243709928117524, 5944645730694783, 4773063750957235}, + {1975814150439887, 3149875793027583, 1261444197722906, 2760429640974761, 1552966352555279}, + {1633514016507671, 758793436105214, 1666766843388618, 1223902548045585, 233185566290059}, + }, + { + {6335824036525539, 5936753389140468, 4473577463180534, 4906816011267918, 4087654058111774}, + {2368975804221909, 2457041955704880, 3876216785098924, 563819279426048, 3675362390258876}, + {2039348563488973, 248927546652694, 729506739622176, 397171022735714, 1644628056647629}, + }, + { + {5425812761915260, 3810529789490661, 5049333453822998, 4123755530302819, 5615639585264776}, + {2534643198043490, 3071062759450233, 3687767943508924, 594097030236781, 2123224284522922}, + {1869384197190792, 1569592234203114, 2196362163965849, 1717386471659459, 39685498183014}, + }, + { + {4635535175474129, 4605530976221652, 3458801108619450, 4871255059096226, 3508659268324931}, + {1421109370612225, 2276342051030278, 1620731107586926, 2516053916114754, 1357365806509465}, + {985026127753438, 120648499984234, 3776067837201, 1121956503069595, 1317952564469757}, + }, + { + {4522971017836409, 4687828520937668, 5703673191623277, 2940799383081666, 2787006346014769}, + {339460334667999, 3256039500082500, 1203428024902643, 1634973881827916, 2329743371713673}, + {1781496335107774, 734939096367772, 1979958937781877, 860043149833798, 2198713547814584}, + }, + { + {4721820132212972, 5501981664895244, 5264058468541187, 3740873078980979, 5716647821232484}, + {4072332661836284, 1169250173411574, 2007338871529421, 2541018716077961, 3008200101154560}, + {1725071616252177, 449990873352396, 128827658985361, 673241280853224, 751856515144447}, + }, + { + {3453037913720095, 3978754968490530, 3848210473954340, 4246376002566406, 5322220851863886}, + {2584349971388389, 535927716206948, 1961578137923504, 2896060138321356, 2010651373680674}, + {1156080784099315, 481555143811545, 967562545637573, 1677675896966263, 907265960192535}, + }, + { + {4332897500521172, 5216833051048471, 3346087018588415, 4384949392542339, 3375716091409272}, + {3883496497463828, 2136509343818925, 2434189290622529, 429179343434029, 2077816145810058}, + {1658461349569569, 1605536581882396, 1366404149694713, 1196969327840593, 1143971682907018}, + }, + { + {5400721311066691, 4902133966014442, 5147618958116264, 4262202967114947, 5920636443351740}, + {3544460334984043, 1818177095892812, 1745908205006280, 4216608321683323, 1892854460405668}, + {665225119661694, 619309150141627, 1122802004923883, 2010090924812740, 381608939276442}, + }, + { + {3196661699712892, 3684791960878407, 5290400087132528, 4583612441617304, 4269495094598113}, + {1614570977912342, 1623735166790269, 2524803999133080, 2496475358487958, 1935280705616725}, + {1092465046248360, 2063398303783148, 1002343547076250, 391684155494682, 1710560533943348}, + }, + { + {4070608883224340, 3070202986942604, 4904606928783937, 3666937738681094, 5479190180948687}, + {535566969681230, 1737993760203276, 701172348317595, 1733855888978568, 2134615712849277}, + {606893040022944, 2129386574985473, 1699765919891957, 528478848080626, 79217852843510}, + }, + { + {2896556608610982, 6055695907875122, 3732440132349395, 5309166170174244, 2721831575240156}, + {2885737548308128, 2508747900193688, 3606366888469287, 2465312058009042, 1828731582217566}, + {1349811289350391, 1890659682051631, 851360755267261, 2227128394068535, 1024384097528052}, + }, + }, + { + { + {4787547620178774, 3158654330243465, 4256768153665325, 5186246574371168, 4755687815664005}, + {997854281022512, 2623211910140591, 385221936050651, 1659016544729114, 609442868038809}, + {1619428378651736, 1579845830028655, 3625310117685, 170605089295866, 1149673757755609}, + }, + { + {3771360214195724, 3008816652878868, 5465610693671022, 3583291267492728, 4869891036079898}, + {1431189333362726, 2522236815322768, 1841157954619916, 2384464325206820, 2357706544622962}, + {437646608465794, 2094793895484999, 1468162389698058, 248477625893392, 1999708435919408}, + }, + { + {3334695520371433, 3812203917821368, 4517495595943886, 3819008971940261, 3192333158392848}, + {2403562525071701, 3731091650393632, 28706304084430, 2945476990326655, 1695373042660190}, + {11430723322929, 1391830113841252, 1337273140327877, 418617211527096, 2156223821909844}, + }, + { + {3474862062180912, 3882457043015231, 4997421855422554, 3623087331366693, 3980925476191710}, + {2057796043232644, 2263408613360807, 3848582899143280, 1729533403820747, 3162991736601526}, + {43999776827657, 989331901442862, 147120313740048, 495021300047603, 2007031690017476}, + }, + { + {4569310600539567, 3932567990833912, 3385323568255113, 4454797311017655, 5850805500278008}, + {166834800897807, 3648978260893606, 1512008134852981, 3519745367019255, 2891621521405984}, + {1308871835809784, 2116706717414875, 56029465436904, 467188187972025, 1826981082270550}, + }, + { + {4470097619807732, 4636615835029003, 5384758368025606, 3313145881106330, 4330528852662105}, + {1956939819397260, 3815569263781231, 1153022458216286, 2428547349977954, 223633771534995}, + {277297371046776, 1016671322777094, 1912173712739697, 1941234701885292, 1286651577841525}, + }, + { + {5516226444917799, 3864412772019280, 3317545876897683, 3844965839466476, 3985391436490214}, + {2680601238774939, 761018381922150, 3233893633186507, 710728397015564, 1856525231801054}, + {634704084825404, 2129536576841980, 1242863233687290, 1573321106629022, 128474589505663}, + }, + { + {4461600283819019, 5688762331492453, 3571771069068464, 3623234953171514, 5735065250408243}, + {129496500081781, 1790297098324227, 1302842166366374, 1122296729486616, 3168849968185895}, + {627678063257079, 716314893721428, 1223825394014331, 504272345435927, 1599415310067837}, + }, + { + {4497146074973338, 4258524581640411, 3327175345569250, 2988994176227077, 5267912111147682}, + {1802641032705090, 1392499306540523, 1496089620367494, 2312128812044035, 3539470476015736}, + {1352081061607517, 1142882484908029, 664622054563474, 278618602320570, 1557574337895879}, + }, + { + {6186532378029907, 2657902210141327, 3418543318248038, 4786173749208350, 3954647920849896}, + {2160964425547565, 2522131549551103, 2469825005211132, 304256310615628, 1406273379451890}, + {66232156124863, 1741674194899368, 1229742843930407, 260078220485178, 2065725536502563}, + }, + { + {4851046938453980, 3469458552849808, 4088972952218884, 2434262635154865, 5173422452060032}, + {2864583883600790, 1179256560411448, 605392730024768, 2131319985409857, 1797303368136290}, + {1658701641668087, 42705500105455, 1620862321227524, 1064411845535234, 1929505696020986}, + }, + { + {4163795150867629, 5312083389544253, 5442631052553893, 4817195733891862, 3463190319377281}, + {1759675286353623, 1663207329829539, 2312695704742071, 376287419379108, 3196993252356633}, + {1986557906737275, 810826505070108, 96017120328357, 1696299441261906, 1606104856145766}, + }, + { + {3549586047215341, 4636877962062236, 3055155796794642, 2987219577785020, 3528907845687172}, + {3376650841822935, 1032192126856158, 2069071282143034, 2845533170222998, 2607538492640606}, + {1660552858343061, 1231765925349274, 796446050473330, 1786065193241069, 1494189638115097}, + }, + { + {4395801598993052, 5237162742484602, 4130001086185514, 4318996219007855, 6361901289989183}, + {2175013070553356, 3320762044970614, 1143129099999600, 1532959129324381, 2553098860474181}, + {745372522040276, 1748456103797955, 2181743850112213, 796241938657904, 1942989014453742}, + }, + { + {4940563260328687, 3680309631021837, 5780417720128217, 4290252794057113, 4860748118629541}, + {1446945700457117, 3425847613673611, 1973622627786407, 1807324498582473, 848150045623407}, + {1097351026844646, 982517101132756, 149747537095472, 442788546176214, 1331800448358921}, + }, + }, + { + { + {3048999410076971, 3892379313272499, 4501182485180276, 6013415726786911, 3538900302869245}, + {1912748982362695, 3472588964406961, 2955977531735648, 2975418449611955, 1539793845278547}, + {2120957025321772, 1416788979770990, 1248163529640000, 1057479098339217, 1345904049070916}, + }, + { + {4595431001667912, 3778027149812221, 3607566563474045, 5108294493186449, 4683353521871733}, + {1020723204932740, 3177502390904871, 993238884888759, 1734688533140183, 2122148469059677}, + {1672839208916523, 1716495024680343, 1707076061183264, 765180466790910, 2017432747304428}, + }, + { + {4097011095397840, 4818396343707634, 3336533547899513, 4282281512848069, 4911825398741721}, + {2414052521429936, 1593372837632108, 2670905511225157, 3908207528779377, 2363908827003723}, + {192171151121229, 1275967732855104, 1864584199775891, 1693406950762857, 451756333138903}, + }, + { + {4727218507536765, 6731370918172898, 4514881522289443, 4346751476412392, 5345399511692591}, + {1612422054090625, 2236845889213344, 2363747608937251, 1594023725720586, 2961152477238633}, + {1485832258557624, 680071864680695, 1288498699771584, 258483455916573, 1782424270254224}, + }, + { + {4145911876469356, 3824464555215015, 4696287494265278, 5681915693477289, 3460241462730997}, + {2899290323536300, 2148582833270035, 4306072922611340, 2565743726502417, 1518458853723029}, + {1953522143805027, 882595907666496, 958109305864079, 1523427692628869, 1741273556819203}, + }, + { + {6076430972133454, 5015736489916628, 3553768171633221, 4610709058364067, 5082978176345714}, + {2177453523879316, 3719629127010202, 1578609310805205, 3246652757763105, 1948868370865272}, + {2160967413246114, 497546389595616, 235866284515227, 1209326819476215, 385381334474653}, + }, + { + {3922495052587829, 4494539022460083, 4247467603322628, 4394626550110741, 4540112411631648}, + {2794088217731505, 3925821314042297, 3967932263264306, 599992304591101, 3777014795396442}, + {2143663924692386, 1851559468934078, 1845266597269129, 477022990956902, 2179267609261901}, + }, + { + {2757964045702557, 3562399862100370, 5308617563064155, 3110477941637017, 5056214367828129}, + {1958983221377553, 2178877734404748, 1849996731612977, 1835657059247969, 2041180109654311}, + {724524272708234, 661221141789934, 1298795839460575, 1322772218421097, 837427426454482}, + }, + { + {4223608019735549, 5288655260236562, 4785575153888318, 4056483408937593, 3471372655277242}, + {2219315301228611, 1125545597629890, 951081168531596, 568553052705851, 1412860720276020}, + {1137419035579219, 1404302123897914, 70650994795979, 286534554383837, 1248950723208565}, + }, + { + {4430704978424231, 4715040112563554, 3462858870799989, 3675716202870984, 4333024567010524}, + {142500909440961, 3483510976010918, 1633124654372333, 2818821059903848, 1198913332019644}, + {752727997883595, 729011045815856, 344467882917129, 1083479075474047, 1987011026378575}, + }, + { + {4459355955251918, 4177516598428064, 5081135773938774, 3284517801964245, 5485650974376915}, + {928716952855914, 4109673353080708, 989163284951296, 2771681491221325, 1739599539253359}, + {884564007355359, 1882230710793852, 1848620432404050, 211924733371920, 1690861583639863}, + }, + { + {3370568370567081, 5191721693684414, 4210754480734108, 6164440545771688, 5649472005268314}, + {1901455587402533, 813369714566932, 4131962295906966, 1890594180896940, 2481388378410460}, + {226931392632329, 1641783547024066, 245880824976242, 244030597682497, 308840717750219}, + }, + { + {4699529728790440, 3682875431198511, 3687823620487174, 2935047689154352, 3634282712140374}, + {3094491104014232, 1130377028133465, 857472228100160, 2846610482750732, 1997728196650988}, + {832395901935430, 2063621809284227, 195191804737031, 1295260648818684, 140470149874586}, + }, + { + {3598626358333843, 5555876347138442, 3551001516031801, 5418563562930746, 3796685043861386}, + {1119383319424479, 3370445532080284, 2202737095147899, 2643552313073446, 2526474007824020}, + {436475423231066, 206987015606375, 214066996087725, 524361410769522, 1866248992304042}, + }, + { + {5215692725695751, 3669441050652411, 4674665916750844, 5316221279699436, 6443632653069401}, + {1081002530185607, 2909820960350251, 3592240835659126, 2824950488355670, 2408518769691813}, + {2202470261312694, 1511198785606944, 1434711629178163, 1742102768767586, 1282697956395292}, + }, + }, + { + { + {5324690866715337, 5533327845613105, 4036930034597607, 4638490931056674, 5650412235017737}, + {1638260469631915, 1786040878698661, 3158389239420729, 3835314628196980, 2413700758553481}, + {960395712488566, 1090263312831733, 1493488072165035, 718337273853885, 140550395520083}, + }, + { + {4569832948050874, 4985100205291785, 3844846206585447, 3819690642434847, 2746468303866686}, + {2833809135953840, 3714738963129863, 1699035707213511, 1260336843200283, 2274544359656356}, + {447501697246828, 643764017641830, 598739660833153, 477276555234445, 722964385617133}, + }, + { + {5743873914285031, 3319094314541157, 4059899116934908, 4330486197588569, 3357811959011823}, + {1468688697571051, 2930932730830707, 2981359468083280, 2467829883996923, 1572642054261959}, + {601523810297856, 895074627148937, 773977692709653, 1905383167427875, 1540507530397039}, + }, + { + {2901461178567113, 4994292130181829, 3331309663039004, 5793381747506001, 5040143301404956}, + {2651347872114579, 1239727848347325, 3161955024122276, 2712053429837225, 3725184595174532}, + {1148448246837183, 1915539016170074, 727268432049334, 838952046766961, 1100979659516489}, + }, + { + {4313788896597005, 3731391587318928, 5481675874227619, 5342116794928851, 4858074158134343}, + {2801484252789311, 1308243333207398, 3101163188310017, 2902551501956635, 1782136170508091}, + {1354449553272043, 1085110494903468, 2224048655022783, 1932600057639272, 200912869737304}, + }, + { + {3988802802744946, 3054267513827163, 5506469409446024, 5207893419318903, 6705457585999423}, + {768379161979176, 2950328772092937, 1384131174334606, 2825110025249585, 2256845801064479}, + {1328818899805024, 1356396048253838, 60665341223248, 1567700157316511, 290562887661571}, + }, + { + {4789838652012215, 4990599721334973, 5868836171113556, 5456092296292492, 4808665632941719}, + {2083771618977947, 3859777942731437, 1586868936731178, 2520556279463752, 2196980677006699}, + {1179288489475667, 394266093483806, 2023843107238627, 906600297586329, 1987935808498095}, + }, + { + {4852377011852760, 4268226436451965, 5725799343439052, 4170083215192005, 4497273560337215}, + {2190648163527070, 1182302286459911, 1698709705179966, 2858053760026903, 512030280417031}, + {1766029976663583, 578113072554872, 1407762358462124, 1251410333318914, 1519685697291309}, + }, + { + {2425211004658582, 3219329122771349, 4160786304284559, 4915538208049169, 4859858046454066}, + {2165465146173096, 1900611060212209, 1042730545588351, 2014093929109019, 1810920073473014}, + {2188210814895132, 862494540176239, 429026747909695, 420692388686242, 398456856483386}, + }, + { + {5384113697440972, 4249326538414056, 3736088109548391, 4776181701890428, 4340637335144904}, + {2182481135659358, 1214620204337280, 1322637461359405, 3608648111407434, 919105498759084}, + {825616994407031, 220978982016139, 419943662189285, 2047052177976116, 183513451940769}, + }, + { + {4383853436467396, 5616868348446865, 2380427384672103, 4007620388627955, 4745758889436972}, + {3034925520134716, 2558549339328923, 2273570634299175, 2355590727329921, 1721435535499274}, + {397259122369220, 1632965024772390, 1358524229763907, 634652123170537, 1300732316858513}, + }, + { + {4537722552642641, 4406953311574034, 4747655843802439, 4621074214609984, 4656289262373784}, + {3211235434961971, 649442782529810, 632841582251763, 3220605671079152, 3939184634719634}, + {596504540509310, 1411595783429460, 320205765945468, 1703829528897671, 791135694264620}, + }, + { + {3935303504608645, 5231587761610764, 4492307054736833, 4099267906214233, 3895141043651931}, + {2905973217158121, 3180461607923868, 3881652820548741, 1616810006326533, 2007934577851039}, + {1723586093910128, 42167711405468, 711328489930847, 1802621686437750, 138939056743574}, + }, + { + {3535285454280039, 4143874578497438, 4378537178006869, 5183808895312002, 4029558557190188}, + {2822051371235755, 1171790929970038, 2832133858385125, 3449345178331124, 1343246277400448}, + {201514708798683, 714458960438240, 193526864900221, 289856941669808, 677692044183495}, + }, + { + {3390373253525299, 5571978408447513, 3881939102950573, 5664584550774172, 3541416731496846}, + {3067220342787603, 1318716141230895, 859940092247599, 2796965663112684, 1325031219234520}, + {520206601828502, 827736556609109, 1548115289807569, 226762337353952, 901425653289102}, + }, + }, + { + { + {3876784047658153, 3427402741453803, 4260413043643610, 5364266100628625, 4512454692213601}, + {3846988412720927, 1464526558278043, 4150028797303466, 3612037356861449, 561355623244019}, + {427225699371050, 88989906931284, 374954954790275, 1891881595245671, 72849256625193}, + }, + { + {3916811195383628, 3630554563432754, 4990637953666720, 3851134441999325, 2556181869064802}, + {2335839984116276, 1931214780001052, 3695690881878730, 1666635094108941, 2394874384507690}, + {487618024041635, 1610635862259296, 1930277174961405, 2060246530132043, 471988063294585}, + }, + { + {5204676678666455, 6002573394041257, 5469218649554576, 5103810246282644, 5450232393144287}, + {2223680929791699, 2255695602856973, 2223372744379624, 2581758136991750, 1157672051964719}, + {1191620799152162, 584262428445493, 1654487633336816, 80589900150873, 1778885798645876}, + }, + { + {3804876885771689, 3030718867413702, 5084806164730577, 4351829583495248, 4696365675416595}, + {3277232365416075, 1648743746278574, 2268484584766767, 347896520603034, 3388269197255745}, + {437947250844137, 170970937295705, 294909197597269, 2210849722009323, 1802271999575202}, + }, + { + {6229784974313861, 4445187233108198, 4141897661886957, 4112739300676286, 4973450766687119}, + {2452873695124259, 3183518466635188, 3225011157480339, 1530254508436786, 2236389510678133}, + {1718640585909930, 289464657861405, 256448940553760, 1840710967168708, 1367355358576031}, + }, + { + {4418094237484866, 3862166158397851, 6312584233293658, 4170168684472692, 3205101920356659}, + {845231506816104, 3749601727822635, 2431461776355856, 2145415545771870, 1633953832787249}, + {1855071951306216, 234835319416374, 608676288546844, 311106921331784, 1424607004261872}, + }, + { + {5534887235292980, 4955913319898744, 4436282654044178, 5157071574798331, 5799145956361697}, + {3127590738217404, 2607909890139434, 625984861031328, 898713331800149, 1867577233264451}, + {865238419718368, 2167660602098967, 849033435333870, 1879862001988212, 2194604163295964}, + }, + { + {5028901701646599, 4744711118820448, 3470202116031185, 5070974802044518, 5029459282472967}, + {2597573876967117, 3500480183251406, 3245567533116125, 2884144221342044, 2745802723161587}, + {1262037831799441, 1761445988918060, 1818282615037362, 643977010061831, 1670449776207217}, + }, + { + {3900064283125076, 2932367474353790, 3722342375883231, 3973709010425436, 4168589452466075}, + {1182011269637170, 1702301475425876, 1754593023447641, 1069325582888970, 3665084705482905}, + {1389152123534754, 679131622889370, 1335753122628610, 2193861582528949, 1750442867995809}, + }, + { + {5195225631658915, 4626594891714746, 5530846200979591, 5835469573794033, 6108601962615813}, + {2118803625617181, 1938389959549060, 3158628651247723, 2603939933464505, 1887075807282899}, + {1094771758119662, 1784696951595960, 1586111086846247, 1024621381632866, 1336860396265070}, + }, + { + {4962714218495987, 4686221014092595, 2854843506884281, 5460710344297905, 3609844163230280}, + {3350136365379549, 514082045997139, 1809601258343901, 1359082981819817, 2325132321451910}, + {816435505147956, 959029754172122, 1905562189095432, 809602990954940, 205405869295}, + }, + { + {4658319919071161, 5037557822453179, 3052863244608605, 4920651274442715, 4594868309263967}, + {2357418342397899, 1599797957446167, 1723240952262061, 1521319741808023, 1244021174200017}, + {1682663787527018, 508342182938395, 1334960042435994, 788285033210835, 1620852797020940}, + }, + { + {4468831118271270, 5037652592706325, 3842859113890724, 5119527774959881, 6070895395223645}, + {2858969631689118, 3774837200669161, 3030920205974308, 3569621881524763, 2272136016309579}, + {1457792005629762, 1504843532852533, 117754270187566, 1653728802150419, 956441650806976}, + }, + { + {3858799123389730, 4813864196253754, 3424673118223091, 3586667532616773, 4976228037682591}, + {1240797555104590, 3504953395544138, 2270523358088921, 1192446004554973, 1265977430218831}, + {209033356623489, 521030133202188, 2210759687093959, 1391735568682749, 2066024683275958}, + }, + { + {4447381514683745, 3805818101586919, 5048484781457783, 3805764540626535, 4979430662961349}, + {4372830229780273, 3385211896687553, 1322477629921689, 1744994285972241, 2453525332947167}, + {469280089327132, 1530255390484981, 1847838662987617, 2225747405410001, 1682362262024675}, + }, + }, + { + { + {4202827224002136, 3028138102214431, 3666469969152450, 2607795400549083, 3461406593763699}, + {2143318224651032, 2985185441001099, 2506505238926850, 2498470302228395, 1442295963272081}, + {2200224066087308, 1167051805827953, 161446888552827, 1516422365939770, 1942535836845300}, + }, + { + {5171889208942910, 4780829163437052, 5016462198638337, 6470156341077032, 3046275441821918}, + {3482226206224520, 997104644926830, 3305574633418067, 2147764348670690, 1676514761128454}, + {1628314393858778, 1997743320994668, 1561201521750924, 1869590045554733, 1810714681142288}, + }, + { + {4681454419314826, 3433609902051237, 2919531098016978, 4380876633130549, 3072926890864646}, + {1675422916543594, 2672408744787477, 2759217149054666, 640362125760161, 2799605921604096}, + {1484872832783728, 72255685107270, 1098972476164964, 1732914770170238, 145186792002379}, + }, + { + {3935383441158753, 4973709539651372, 4161806475746733, 2598419220788322, 4556716999515219}, + {1372652207334635, 2531888280983978, 3771287204988285, 2258792327010408, 640671581341507}, + {156581553787681, 307978851206907, 1451582278870485, 442722234791876, 662472042575165}, + }, + { + {2866740058396235, 3493635817947651, 2400937210085123, 3122677618181344, 4447500274280321}, + {2082652078388943, 2745645971502049, 2295760696601975, 2362848920638954, 2370414183207021}, + {1712668510139487, 784271226274642, 827073136956465, 1001465329762964, 1662630974562798}, + }, + { + {5156175574821430, 4359502037960358, 5222120068062442, 4645531980214215, 4676244221442153}, + {818080711416948, 3611895686544640, 2535691662679364, 3086441935441805, 787978368976315}, + {1509857525874286, 1496970584948645, 399828714647739, 1863753979948441, 2149707660031809}, + }, + { + {4144865997618639, 5339859640465925, 4438288719418715, 4715011715150674, 3610459694506906}, + {2952195132229463, 3345568150314393, 1768906295222689, 2025477905414216, 2995593107979034}, + {1951144383031056, 1085048452592587, 499199223423315, 2055889411465929, 698006601614245}, + }, + { + {4183964222033211, 4817865139479783, 6220809882369837, 3643181163556103, 5929569705519063}, + {700816495675241, 1165569165048171, 2172597164236109, 1071655796287173, 2392628493878193}, + {1862104717906915, 1752261107932084, 1874923294613947, 1008681858018398, 628821150989939}, + }, + { + {4161348428018682, 4510282473079517, 4817307873546246, 3901464805798077, 5820970885668019}, + {2393760120508366, 2923675062487769, 3447512431195440, 3853675368087017, 2900110716170471}, + {271735680629051, 645447398246691, 1438808971583999, 792432482423730, 947645802664175}, + }, + { + {5548911597254848, 4313111803014757, 4159094458160020, 3906456530516599, 4703406736341543}, + {2468698810952212, 4159587806133767, 3895277333299798, 2370621230252749, 366242246574179}, + {1891237336529861, 2200322075990278, 1389309370267760, 1284260243869154, 2019396638376055}, + }, + { + {6612681523843925, 4270864305450289, 3731318918021201, 3544862780769488, 5178202040634906}, + {2135755065262843, 1122607271257525, 923542923082409, 2860818598984322, 1922554972749380}, + {242471180181642, 559887731579688, 2072408437063313, 1092425853708654, 1508919031894623}, + }, + { + {5872377157668488, 4408911728296550, 4215455815151923, 4350437538061339, 4304102307657902}, + {3016579539029836, 3430456847285690, 2439572409111001, 3210834728649259, 3775979784664836}, + {681181014012506, 1995504690201206, 1747715035603252, 100305442172708, 1898381133318416}, + }, + { + {3131841243480282, 5236372530773376, 5021877536268058, 4866190361541948, 3290429298804025}, + {1471590353308208, 967056793878588, 3802522075784380, 4004598771731972, 2024618065937019}, + {1109658864423422, 2103734444560570, 2073023657041166, 369769649281723, 817132219307245}, + }, + { + {5632635968843701, 4247258704551623, 6265280169576672, 4815811703628991, 4268679712320579}, + {2186780367255445, 4183850462668485, 2677999934662660, 2880987810780319, 4113828005081983}, + {1441842413844030, 161967823757178, 143843657267759, 468984586211790, 1403635869302761}, + }, + { + {4465016058776751, 5317359619864273, 5237005983845137, 3609875861871372, 3464614715951065}, + {2238448064725901, 3110619177809235, 2162294075762619, 2319911679772150, 2285011619226311}, + {19804365830533, 1686591959644968, 641957734952114, 1534607041731245, 2021106986001419}, + }, + }, + { + { + {4685063337509321, 4828498939602920, 5252037453775058, 5946493173698145, 5385655016202805}, + {944214205150673, 2365379166371694, 3557291173836860, 2962349586178017, 1508433893219247}, + {99837384801727, 2128746966172064, 1728087272474317, 1660968164341303, 2094478837305487}, + }, + { + {5059816654277047, 4494318859907208, 5234935703112714, 5064000806734505, 4673368238982494}, + {1045092786794937, 922156857253434, 2823065772236182, 3280047208436923, 400144133024674}, + {1350540322092981, 428507123444697, 863081413402232, 950089447398951, 118865435494230}, + }, + { + {4685872193140817, 2986094649249487, 3994164430284207, 4339988837278092, 5456344527489565}, + {1863120758931529, 2615255562194237, 2546630581550601, 3581241606812888, 3495878108380709}, + {317239144147936, 1378693805440304, 1613995646839215, 1790616997152168, 1664744641804674}, + }, + { + {5168378766438094, 5613439416641824, 4644053531787994, 3823661418550054, 4036137961950509}, + {3162078769819650, 3145982897294820, 830213734772942, 1343060696486484, 611721765217825}, + {220994375354681, 1633125608855915, 2233079832150828, 144297568151940, 217868145580028}, + }, + { + {6394803792754188, 6132368335021053, 5067197744306631, 5563640033331609, 3502674887523375}, + {2185253522527390, 1722061079589371, 929518249744037, 2473172243807197, 3427214482375105}, + {579681536856473, 1962714631533051, 518559321779053, 971489356480100, 509262501560864}, + }, + { + {3925113491817113, 2597442932750426, 4547336592857079, 3567634098715516, 4305879739481027}, + {3780232691597615, 2387499794027268, 780855157188913, 1744928736206446, 1837149863417515}, + {1612827416827303, 1149821613065205, 1844912308905994, 429769677786205, 1866058244678788}, + }, + { + {5323969415910835, 5007501896425241, 4051100888248418, 6293526281093731, 4819708586854638}, + {1087967203355487, 1504313118437159, 1271975234407042, 2125305808015759, 1278369242007838}, + {2109491846902798, 1459244188614787, 1145316246074802, 537401043713173, 2076110035136585}, + }, + { + {5420343519672736, 5167540178478133, 5227270808193702, 3857502656954627, 5090553389549522}, + {2543056198437618, 3682981507069573, 1492922137755706, 2553269698918225, 3362719634517442}, + {641798503068060, 129975789967638, 2167736719761015, 31631641435626, 350785183214734}, + }, + { + {5066057417347081, 4106102383764030, 4636402204189217, 3166449457097492, 6512612113974837}, + {2326671091720579, 1608331768972414, 2153369779460415, 2214666295188594, 2144539481917009}, + {467300109694399, 1693264194394125, 270333528447105, 650109201517682, 1183509432017698}, + }, + { + {4980219730800404, 4347683389360629, 3797217994168414, 3968193844610984, 5065496827863311}, + {1399648064845078, 1606346276621799, 2881852436764688, 2553259795593478, 3428187511626105}, + {301865991723133, 208252052427984, 51972802328726, 2021710333754506, 1378508945174500}, + }, + { + {3184436513057976, 3574184872992923, 3980701068825082, 5420309832432621, 4126883464345483}, + {1378603098333140, 3238698568766207, 2846856431574260, 3096436218915115, 3811649319155499}, + {847831302663356, 1506598425567944, 1109350264779453, 1031639907526886, 1887329321191319}, + }, + { + {2729102328832984, 5496148280158443, 4624803589574900, 4730709608222510, 6347472137270048}, + {2243355286660512, 3259846408864417, 1913072889496856, 753019988978676, 2074854260894060}, + {1050426720469833, 301805153257576, 1393268630450121, 1286505995795045, 1587323866723540}, + }, + { + {5177553689561919, 4133777550475335, 3692495435897478, 3458719135916346, 4458613993531757}, + {2247714139881915, 2782180885900161, 2312112468846576, 1680267679651832, 1590058688526667}, + {714977855392027, 2020332496651261, 1788558438911234, 1873232632822523, 503071332489421}, + }, + { + {3928537419758315, 4962617917721336, 5009684278125795, 5080330424879792, 4736452659996568}, + {1885791717393579, 3608519904666432, 3804656767054515, 3734399316619142, 280860879781734}, + {222453425419780, 1881231455372494, 356159674087381, 2031436073565603, 1587722788974501}, + }, + { + {5557830146603019, 3189235339941465, 4073380612031396, 4406171020530468, 3729384279482635}, + {1262604590990019, 2611597233679237, 1167025725287256, 4282778604598424, 782190165854895}, + {2186405536221393, 1904322539012708, 152608078674767, 560457311616919, 22952815837658}, + }, + }, + { + { + {5410522905087843, 3457067311541871, 3734790664132962, 5317892036251255, 5789103873795877}, + {1051236049852089, 3090035912523931, 3653329677163146, 3071361720175865, 1695547314615009}, + {342012360452061, 1887029215668228, 1155449753977691, 310762800506541, 1868750527042639}, + }, + { + {6005811139638228, 5026414264668887, 4377100252408278, 4270582517957803, 3422272486715601}, + {2698577143176842, 1182111476573107, 2613378546611642, 3220851371976805, 2803670963190147}, + {883746203814773, 276737323512287, 2229390196673160, 2155663378443822, 635390057802745}, + }, + { + {4097156896954595, 4786624081470779, 3512858804636033, 4586748051134289, 3866073874774231}, + {840689961188261, 2918655679606741, 2236632145763387, 553161305644429, 3021893411965909}, + {1649953183870355, 2176771717569818, 1233096109604549, 1152511702037810, 560573824644263}, + }, + { + {3626792084314328, 3138501138424139, 5501515071454841, 3948607545905590, 5453543250308683}, + {3279453112825750, 2682669747401601, 2291239772155005, 3644653666115630, 3532224357711467}, + {380965098906693, 835788132761480, 2232989119976139, 2205277179143298, 1175904351372329}, + }, + { + {5088419201363648, 3175894686165450, 5299797135086175, 2983523363221301, 4220825923293130}, + {1276840412816828, 2771169526519092, 2136012615148103, 2431893903507465, 1217611106137226}, + {2073239372536943, 30649016949678, 644492521678981, 305840627193069, 109901429265295}, + }, + { + {5139707358045825, 4688671704193624, 4352852502302345, 6384641621021538, 3836551482242832}, + {1192657509706017, 2505894684845872, 2556098156240875, 2309411544504528, 1820864150951982}, + {1002466072624564, 1231676492638173, 1795061881446222, 564780581799518, 2025621015597595}, + }, + { + {4858692159454824, 3985618384769197, 4768611969748369, 3070997304216167, 4648245907091308}, + {3367644801750200, 3754604094141859, 1751381457602879, 2418709533236081, 3882122160708146}, + {374714050779396, 405289438859672, 1963133877676048, 2112584561135192, 1143185401022561}, + }, + { + {3846711807981435, 4505402219442327, 5146862869313170, 4623705187751987, 5565609289355471}, + {1926650836092769, 1141267952622767, 3387976667434360, 2038056869767013, 1320936551384977}, + {283489509389185, 614480115735096, 278795579529276, 1166609138076060, 1715497286463476}, + }, + { + {4275758633577087, 3861278996194559, 4466252217383748, 3665496078445880, 4058888268167473}, + {3871692294074427, 1764539273907035, 2887939385751194, 2243961968498350, 871865948439469}, + {2109468136302879, 794757759853720, 236685909745726, 1503678842333224, 2147818470882973}, + }, + { + {6104878619412512, 3485890441294438, 4220586739682332, 4017322426737508, 6001128289990864}, + {2677372099733352, 3437936829126546, 1424452207982980, 3507913002098314, 1735468130831162}, + {1938075620777682, 1762081466410536, 1564991344244054, 1376297777594771, 248036172502508}, + }, + { + {3778095331789531, 4910813465857036, 5137553967349467, 4984396828084641, 3687371747598377}, + {1479550570874507, 2294055327463876, 3724831818626703, 1654245262468829, 3019040190597313}, + {1873423061916096, 248167770548070, 903648623666602, 2087943940366473, 547940262578569}, + }, + { + {4725001988101218, 6546220549270451, 3469130078731384, 5687075187757928, 3413336519371176}, + {1413358533598756, 2252005803690891, 1458088388485468, 1671589233622260, 1797166284473808}, + {523276182513223, 343307024193534, 937383689926833, 1330219799726239, 2232356434433501}, + }, + { + {3569532147039540, 4195918401728545, 5115321889044388, 6609417783186476, 3958938427322120}, + {2397395505704106, 1262743052475361, 2547892063055852, 2321536665849090, 2021113849426924}, + {141428615990698, 1565258204511290, 2188430123291708, 1781055032390171, 763358600759749}, + }, + { + {3906824289179955, 5654339223566203, 5504976063361072, 6361176910130113, 5155227057638370}, + {721005728190537, 2847737995575099, 3056729868442396, 2393716554993649, 3467469336561398}, + {160800301986322, 534920738504617, 1465194074759867, 132949302971740, 1176455782582044}, + }, + { + {3433889410020031, 3665956712149865, 5366646390977683, 5367384152674927, 4795948454618784}, + {1902504950598053, 1202752625490289, 2565725054888499, 3023474686925025, 3059561010324150}, + {1935479944158543, 1102588664377385, 1651606970291190, 1048887489959304, 1677042940335362}, + }, + }, + { + { + {3858553186233324, 4192597543704949, 4422265554716229, 5060918874051413, 4251667779718110}, + {2960733565044348, 2107676482823115, 1657279889267301, 1609984394439769, 1082526754413784}, + {1823622181083017, 408967151178094, 2033143529389867, 2209724434343478, 918118538477317}, + }, + { + {6088716933512995, 6116095372188681, 4275776721065459, 4475819482692536, 4685952285527508}, + {2842268335288737, 1888183319191451, 3692488899816305, 1677336684221250, 4176880757505444}, + {463491021439363, 1750609461077078, 1169967881279297, 474253519600450, 901070375860211}, + }, + { + {4400692422952866, 4659690717529996, 4722795303748102, 4016471577087528, 3702653606869112}, + {3485976485792634, 1118156106770038, 3653108520059592, 2301046652704138, 2381698882921202}, + {288029433804634, 1918327772711516, 1858109617364668, 1548745667412753, 1635036158704975}, + }, + { + {4899918186072737, 5587073618198231, 5408433162977742, 4217274871182020, 3058703542950255}, + {1915560744141461, 3219944346867669, 1684794323668364, 813038486884416, 2736974530406253}, + {131383425958682, 1726194406199626, 1195125520329959, 1269440178344704, 1934708138886976}, + }, + { + {2560939345231273, 4301322442066007, 4073130192422468, 4440850393019204, 4883344655404735}, + {2185121667669569, 1115206785572251, 704158439711004, 2133851508118048, 1251130304627637}, + {1895230235031468, 1896812472261458, 768470747222158, 1996242383935516, 1420798451369434}, + }, + { + {5839795121226482, 2867951589507385, 4636256264448023, 3052659764389740, 5026931603960818}, + {1579856931436900, 2447051767839229, 2868067823655589, 1688893962924788, 2116170079089324}, + {556211501812000, 449190026847667, 2036295767110360, 128995208617458, 1118467502984960}, + }, + { + {5602461071232607, 3307918487728174, 2854017338064603, 5855272157497266, 6150895900635822}, + {3398390622800229, 1820230761045332, 2690748155578623, 3095835968664066, 2530217218349662}, + {1878982227582804, 1431346083601994, 1534977024077189, 2155113334662581, 1782950372830762}, + }, + { + {4697661970186985, 3763132135142867, 5033467660349912, 2907155321697052, 4660465007863417}, + {2604312744349849, 2452708102821815, 3230466926286856, 2118488738947708, 2304478471957885}, + {1390885694073460, 1816639772663275, 1066627353945560, 1454561122724455, 848860562366790}, + }, + { + {5540829116940004, 3948748499449809, 5260550454870879, 4676389564943908, 4383546683050662}, + {2563789831020858, 3343718595008637, 2259025389677919, 1392665428080842, 3671467539073936}, + {981545110828877, 510698765880228, 2161678679515528, 1436791773758609, 1673597748298096}, + }, + { + {4329713062953095, 4939339976361997, 4958702235647932, 3268883154176961, 6391544885910171}, + {3614223297666549, 3897390208178715, 2811994039134574, 2958689501074087, 2363866533687133}, + {1294858674770242, 529668890256843, 2030539078163824, 294693146073477, 969527805905143}, + }, + { + {4670371383742225, 4002936514889177, 4966859846610707, 4736741110602146, 4760957427324248}, + {1176127152490445, 1894013131106171, 1812632908007715, 3751034747324574, 2289873378487758}, + {61868149975749, 236120696290007, 608351327055311, 1829919587421069, 1627340269896729}, + }, + { + {5062259960708944, 2689430826280744, 4108030288846956, 3316359330121699, 5641758926485313}, + {3722896082959268, 1863222026681564, 2044934869352810, 1385880696113195, 1308481967864035}, + {1796753889379582, 2232245583163596, 176790521107364, 133826841897595, 1041041183235991}, + }, + { + {3537934576014922, 2998428847270897, 5788967881664907, 4283416153137820, 3545722873501844}, + {3424639235617092, 2530506041245943, 3202402279176211, 1867524240141886, 1078908361802522}, + {1442655471934418, 1764674447040318, 316317796980033, 318184491515700, 1168933061547497}, + }, + { + {3599845082833499, 3896846545871592, 4303714095196951, 4532827504261802, 6020561742040974}, + {1580156396502051, 3208244370687690, 223926404960589, 565074765027696, 2169726994764050}, + {1942280341359651, 50425926664281, 1816034234875212, 880607828368837, 2092912650330571}, + }, + { + {5512765861463031, 4125716632501591, 4924530697112776, 5238255918415337, 3653602071478327}, + {1344167653424867, 1048535312223495, 1948741777806718, 3072730820612467, 1645288196866883}, + {1745152490874503, 1836336442271605, 2042898833391948, 1540893062903555, 1183365031475960}, + }, + }, + { + { + {5866266958495514, 5059063420853561, 4485040531648720, 3733835905319672, 3149359201467933}, + {2684460961013652, 3709949712072759, 1783966662497692, 1338383483986408, 1938129546538183}, + {40033251972751, 73885946378640, 1935473366247146, 1461619709267546, 1211799649582059}, + }, + { + {5250457209059169, 6625476149991574, 2830402208757038, 2943786524207392, 4303078760549837}, + {2301225069080269, 2184860938031358, 2273332051328548, 1704804667098002, 1911735781256473}, + {2217303387266656, 2227853943602075, 1384266551040407, 847818056628355, 1874126181291960}, + }, + { + {5228171959238562, 2572808713483427, 4818692310321808, 3983994866935258, 3614639592657195}, + {2763608237796206, 2346801614322209, 3045306834104040, 1893958852943478, 1490859261541415}, + {247688480299164, 1512873113726713, 1351630747308477, 937439467136054, 1030677695284257}, + }, + { + {3673708668048072, 4665314801263177, 6233349558231934, 6339984458236183, 4552548914816150}, + {3247306673138258, 2425869243107473, 2622484905091774, 2040657700179409, 1450858492090282}, + {1636572211186580, 2000987144770729, 1893417472062746, 196779160527558, 1557344243161357}, + }, + { + {6493926578942193, 4543542057302668, 3472731731448002, 3629201377772109, 5141975006754257}, + {2310006248725699, 1647962485872618, 2823143389536034, 2192050419207497, 1818655878772515}, + {1024434193686880, 2242250021719251, 564307645117404, 690001361734624, 239056809198959}, + }, + { + {4713019913612655, 4128228433667681, 5028024885108113, 5705734794679268, 3306562584580656}, + {3717108646348257, 4084515682195001, 3812051722646527, 1684888211341314, 1618372056987552}, + {1877409538331051, 337692456674055, 879114692044355, 2186377676371749, 1343387843321657}, + }, + { + {4142192651183813, 3524721259616285, 3594705099270661, 3959153982160586, 5413021910706886}, + {3669516570196207, 2121969005742829, 1652467606544375, 2698034847882520, 3275951535145684}, + {535664786267626, 858000264335400, 1392803193793530, 460772165692459, 1244185301942167}, + }, + { + {4502106313596470, 6443346829525378, 5721231993875900, 4681113914034302, 5472479613319256}, + {1495731174651276, 2532746921337410, 2156800382632014, 1987445924091844, 3448117379338544}, + {483117633444291, 1721449975252800, 2014677970681898, 2079902425951169, 117285229800651}, + }, + { + {3261832527463430, 3508653912421559, 5988429677058390, 5333822038484553, 3271080652355482}, + {2204547407113574, 2042779888674267, 2424936780736806, 1416144793524967, 2647730853119196}, + {417006946097712, 816142170165382, 321665320486095, 1120596382678137, 995334532083163}, + }, + { + {5667435300952982, 4583050105149113, 3937627982933697, 2917941244133350, 3746324610420174}, + {1654154218632292, 2424649854522191, 2118483268871125, 2658103876978958, 3351121693690514}, + {1757087236610187, 114932695265885, 1498710897730185, 1732388966595209, 145995973897689}, + }, + { + {3747574781762871, 3444173068370155, 2989065545095348, 5144077823603124, 5597474176298234}, + {808058917355435, 1642072317689253, 1764756051109168, 1619463984060522, 2971052737331444}, + {344784500521841, 753070981245028, 1021287645349333, 896645545453199, 449568974542070}, + }, + { + {5037125630216086, 4317087092146610, 4394758621519137, 3169411347551391, 3200762148534134}, + {3758879149962654, 2267958484085658, 725842773817223, 2203610500470887, 1640888914156664}, + {1753063336824455, 1632699439142352, 654655992711894, 254878945844677, 1142235737877277}, + }, + { + {3668977677139265, 4332641682100108, 3590347451295966, 5242849066395039, 2727116665213341}, + {3248235630095651, 1380466035309490, 1790683862609512, 3542725848725101, 2663722245169429}, + {863640852068414, 1530602868551714, 1707160942886152, 54230982937714, 122819573759751}, + }, + { + {5532810941110268, 4585437113624970, 5116705204102219, 3665108856301161, 3445572551989045}, + {2829139259902194, 3388923696568854, 2569841942150467, 2697982670988693, 2163914772008849}, + {2076653457069888, 1193685867720358, 1325584969753937, 1501472994346955, 87079528165998}, + }, + { + {4556025881223574, 5720430347742651, 6074363308505144, 4027406626756934, 2527767620430889}, + {2142131119871606, 2984501701896371, 2717746191530066, 2203225891573820, 2175517225379719}, + {897107227346093, 455907621058237, 864390863340574, 316655721359786, 1688391871841069}, + }, + }, + { + { + {5225107848603314, 3997985175873023, 2901647838494787, 3895284350008311, 5682946636557185}, + {3523031484358436, 2824636666213863, 2395141832526945, 770528850757883, 2501907940021781}, + {722866669050453, 648025000876863, 272387785321835, 1191578896340587, 133025146298323}, + }, + { + {4430018927628058, 5528149113975034, 3884602704599257, 4041974594447505, 3905022194274965}, + {82857304500618, 1554338034359360, 760468202446199, 2344834461467455, 688719719651551}, + {2128452325542740, 952454207454828, 1516099560539414, 1362377470631451, 1181280467630705}, + }, + { + {3877905624740973, 5612025444592814, 3620377076227448, 3557624466809644, 5794884625077990}, + {1234316951156125, 2774803744202148, 3038336850143346, 2839603046584234, 1645722164542234}, + {894237486099210, 1516039905189318, 1740044048087400, 593444525063043, 2109764897178862}, + }, + { + {3625360958175610, 5708422748846073, 3787265901576189, 6157656721094708, 5961588011087405}, + {1482109974932762, 1512691293799179, 3308418655922299, 1669766513116242, 1645628848588889}, + {134048702591674, 1512942576919112, 1666722043826583, 1830910766776036, 90483195207340}, + }, + { + {3762249153136541, 5419647444574112, 5020263484993746, 3697437793067561, 3831953348456062}, + {2494438010166937, 1432383122970498, 3625127628421620, 1764585753875763, 2715866922646858}, + {914153294895020, 1485178337004016, 1172992438642136, 742396957515979, 1460451697085215}, + }, + { + {3293341585462216, 4914585647995248, 3425647660888775, 3851476795826281, 2935952374714235}, + {2881676317687314, 3127597808111770, 1680974550469383, 2631492786928655, 2080467460645229}, + {1084836891982052, 405373371974756, 392292573225522, 1228291428535054, 196706224397467}, + }, + { + {5422966393229312, 3517798661028565, 3491057102408135, 5349612585124235, 5098313025804708}, + {2181085219797570, 2438267619893703, 1398091257339579, 1543623638852333, 2275879750497956}, + {1451708073273912, 640663458576442, 472967005176057, 1940369909273489, 1650816055376110}, + }, + { + {5775591770146864, 4809727687563635, 4066767569195787, 3927850608944429, 5542524111957037}, + {2856057239056516, 3899713821492127, 1178627125851433, 3276833765573271, 1528786153297881}, + {1406590024268518, 1220852036090080, 364949301397175, 1654716393716139, 143122595639438}, + }, + { + {3092682960222618, 5760168522994174, 4966136799494047, 6183321071200806, 5955160799299141}, + {1679800253914106, 1418780742199926, 3419507991072325, 2296436046846462, 2072736467396911}, + {882943817583285, 484844826182032, 423720125645701, 79705330082926, 518433021584838}, + }, + { + {4303808439591566, 4492049110308958, 5005208589399660, 3449528090765045, 3218284505011813}, + {3283940803229324, 4459508559485836, 940189907838090, 1705424518756533, 2039165337931945}, + {892563649969864, 218618659831677, 483384434921296, 1959503286788495, 846111377588119}, + }, + { + {3736052427633640, 3240841928280071, 4678563487154791, 3752373267871112, 4181937274986806}, + {2003615224309886, 1453829786196949, 4170849260029473, 2196915936737576, 3465659437703250}, + {870814358129174, 1509533025339595, 2053081266530331, 1737753718216259, 77875205064950}, + }, + { + {6295693526685959, 4477016414498074, 4045516627237016, 5610462754780940, 5285590675711912}, + {2091650387347437, 4186999032385018, 3695680781345242, 1318896896580492, 3133525015024966}, + {2057751622403208, 2124826136415213, 2162400122701924, 512312961318735, 2072953190856236}, + }, + { + {3421075047723659, 5902999844007244, 5257660560322253, 4411230485782045, 3851018473810833}, + {1356912041975431, 2088651341684568, 2115599337938785, 4037573216393849, 2652908467965391}, + {356251628924273, 2088769627568139, 187882754343055, 394347310503797, 1449630398452630}, + }, + { + {3682820885194585, 5173915763318849, 2521868910298419, 4165015930825951, 4883528324075009}, + {1067127578201981, 2883441503009643, 2032675011298617, 3963320928045487, 1183903438950389}, + {1431421126152216, 738544074023370, 2193830823196529, 1671561335663722, 717735409657132}, + }, + { + {4201586389811353, 4375880219104829, 4192199017276052, 4416844421544609, 3903714904213483}, + {1449584304781523, 3077329128471461, 2135282471631868, 3283981709093825, 2025731372310411}, + {1183319077995597, 1294226945214786, 1175504892926680, 1065468559536653, 2201437139069262}, + }, + }, + { + { + {3505559764260479, 6013086951275753, 5081911139396344, 4716516055339902, 4005184608137658}, + {1941635877650331, 2292936607701027, 802548087270426, 553714331402352, 2637835706093694}, + {1415499622184076, 11739232724558, 1448526577403933, 77973485783393, 148463223858677}, + }, + { + {3556556070469100, 6104580777770606, 3153395731542438, 4746347503688425, 3530835687615003}, + {2563241728545350, 2900457320970642, 2021653799300720, 4081786454058715, 1684057546885165}, + {531432570362576, 1071513573823369, 449672118652203, 98547521251379, 260579416510065}, + }, + { + {3113402949202118, 3224343282781895, 6393340053990193, 4574021187583530, 4354743893457091}, + {2098297300858722, 1637995723173513, 2132191683177015, 592134746032938, 1044637126699087}, + {607038018090674, 1768950085932612, 1176147243379098, 1239851308662055, 1164850159859507}, + }, + { + {6544624144736846, 3158440120316048, 4122467747600782, 3270454787206357, 5173743677397902}, + {2302101840952822, 2675605826160506, 3431414289057246, 2525090851992001, 1591101869035052}, + {67986117053250, 143032219413988, 187059126532888, 1606721935579222, 2108737133289470}, + }, + { + {5726022544095362, 3724045113988627, 3515582956648241, 4176155101637246, 5525745188146662}, + {1710358734492362, 2952544254120043, 2348808532032187, 3458396516769880, 1537007452608630}, + {63942543002426, 322070337950512, 1601643046070686, 1223905889282175, 1741111665223434}, + }, + { + {5315895417052113, 4828375526334729, 4444010786735381, 5993309905616190, 3640401138113649}, + {2860407040121293, 1177142915116463, 3145140653940871, 1733521080031482, 3186874796199337}, + {731527977617797, 464892677638406, 850380242165564, 1707297435867315, 797914062581028}, + }, + { + {4481445847621310, 4194775426039896, 4717484155432068, 3203129625283069, 3774741254649070}, + {2200385186612512, 3830080434695126, 3332312936597714, 1819075993402941, 3697021137208346}, + {1808087344592199, 1917986815291197, 1736625562156353, 1691009053422774, 699554104203468}, + }, + { + {5048623459093582, 3345582890430421, 3965077987869649, 4640623371578895, 4912032720993151}, + {2302864341793270, 2363316925891845, 1559429527589511, 2124275860379685, 1685170275648173}, + {567087552892581, 1562927351866469, 299640978917608, 868196882482839, 81953139898216}, + }, + { + {4967323480101032, 4012272011745302, 3862894427518599, 4308636686245327, 5217499651112315}, + {1252667495912574, 926763760798846, 829943705996489, 1227324880932263, 964621170655609}, + {955876088496614, 2071382636271538, 1339562676294470, 1915921082315197, 857114822306108}, + }, + { + {3257326910061677, 5127439013196396, 4310630254544639, 4686443315427179, 4724730249377907}, + {2936128018106963, 1695470026893168, 2973127512604355, 1666309508011309, 2226049713730899}, + {1512722216346670, 113316334999619, 1851114541854723, 1700671412068281, 1858477808352196}, + }, + { + {5998097796107191, 4771418173207581, 4274779313964863, 6374384720876343, 3691059377431806}, + {1747059722842985, 1151985779666741, 2579873034214805, 2259025270175461, 1104167228907676}, + {1120011747324768, 1881628887342023, 2214290331844435, 486356580332714, 2162135539567334}, + }, + { + {5415017211564966, 4131956504736867, 4606393482137328, 4786286211324892, 4752001899018321}, + {3516707084985218, 3646421870194647, 1944208348735794, 2748388507091938, 2933933255585587}, + {939102610898658, 657762889309704, 1555084457788919, 1150153333777593, 1006706590082496}, + }, + { + {3543688234603472, 4194712450230855, 3880927772745797, 3426761679103243, 3127058186392728}, + {3187981953742084, 2855163365535635, 2396035850573347, 3426339364174055, 2041647909167010}, + {463905214510220, 1910840871806134, 115888611524937, 1537009142155618, 880221457903699}, + }, + { + {5589672840238728, 3432294293459350, 5387677215955058, 6169144676112659, 5379715338757042}, + {1784370156336156, 2235499907922716, 2025309612181078, 2188885065316605, 3233083367725482}, + {417210119430620, 1641361429213146, 1508617462812435, 1831075688628217, 1813350286884393}, + }, + { + {3676762525127118, 5016274613231870, 5279594930346407, 2746860593795830, 4531082394479975}, + {2603791557859206, 567981304762832, 3180006238725203, 2675077654404820, 258215834034235}, + {1643563927005454, 1423516315292419, 46523883479803, 1501791298376850, 1157127033006661}, + }, + }, + { + { + {4640633429716646, 4436352535262760, 5042663907988027, 4328339913162644, 4318409930240684}, + {1650059244213924, 1415687339027798, 3751941600642035, 2204874486713656, 3546077689782506}, + {1247200432261975, 265507035905438, 1620404126253617, 117362009527087, 1746435297969059}, + }, + { + {5340736267872142, 3295470429174750, 4407135163398927, 3488366482378904, 3746520348111790}, + {1068629703061668, 3236562504536698, 3481748917474479, 2110232841828030, 1092532788851750}, + {1306097687903586, 1372543655508231, 1658076721821581, 2200003583698537, 780636112677937}, + }, + { + {5226077937175337, 5692428823576533, 5689014150777050, 3908825240466348, 6345259720261058}, + {3066336104509029, 2314860930152579, 3056640011863338, 2260092480216528, 2073254466378784}, + {479894784370716, 1925880613677947, 2183487522494884, 625094381313712, 854845126872293}, + }, + { + {5197618157762598, 4433464121961190, 3260681654961795, 4120975634792281, 5835262176061498}, + {817093479351430, 4088761935787052, 3171716785010059, 2728541872107727, 1520644895959802}, + {1207982418891449, 1577854720087533, 2009037012572541, 1476807775109585, 764858983320152}, + }, + { + {4643752207568541, 4177425086748798, 2717351689863297, 4063904331524798, 6079476938692958}, + {292623621294171, 1087309087737456, 2573455597713993, 859400146466928, 2565065720265056}, + {1960514462005953, 1030291725190195, 357278058611993, 503261352420903, 409647200988996}, + }, + { + {4137436424426920, 3760583205467834, 5814704535202459, 3679343367155289, 3544651677301793}, + {1640564024541742, 3450104780081118, 1372955845260037, 2487953912194947, 1964015174577549}, + {1832104727099167, 996069167520846, 1100729754186688, 1771584084767106, 2117261745027080}, + }, + { + {4431020636065029, 5503695293870154, 4553592025467096, 4019460577334316, 4832018945114183}, + {1199122074926019, 2522059134402784, 397875262207322, 3119865606750668, 1432109594857765}, + {1875633950147766, 1109790076082089, 897660652998513, 1428078707156757, 908826481148722}, + }, + { + {5054013235620828, 5378852271051704, 4293253473160895, 4319499063151422, 5340758119594162}, + {2634018106321626, 2505108247629684, 3126341578772617, 2016974307899050, 1468999769476078}, + {2013224690617610, 881120726963113, 2087874148443678, 930634847072563, 2100154549645766}, + }, + { + {4096027168378681, 4674912073837464, 4651610619813038, 4659750027669693, 4079639323873143}, + {651560684224625, 2530373654189494, 3125510882371828, 1936741789282769, 4026872663838631}, + {1094258812694036, 1294242138409324, 1090035173467081, 1763568378228799, 1431407300427851}, + }, + { + {5901866474833548, 4953841416438018, 5227230958845012, 5669922347444024, 5683271169352586}, + {2172262341405882, 2561868572136046, 3688730950551326, 2503867014426524, 2213093161812464}, + {1951192547947024, 851119993124706, 1847432304733109, 1277897613708864, 601543383482271}, + }, + { + {3631710539670242, 3768950590313261, 5303952111138864, 5325131792733564, 5315344346171139}, + {3338513542876810, 3006290156706597, 1350992246942434, 903865514364164, 3147437075515383}, + {2230520732543357, 1272781658952307, 896500518331525, 1553870550296913, 1174834176365255}, + }, + { + {4212629881454302, 3511449460350501, 3310343538794185, 3281266357642722, 4487974828971768}, + {2969785173831624, 1505727885325259, 2813024274382127, 1442092766966006, 2775912811267378}, + {1226820412291019, 1429525834475644, 2118443840955994, 611048578379551, 1393279248359119}, + }, + { + {2549845597186375, 3623100753864553, 3499310120841001, 3967554171599715, 5734430215634972}, + {1995271425552231, 3083791126213951, 3279752729240055, 1320836376731637, 2619696559790542}, + {209938911194598, 1168941097549542, 1505719700014288, 296602403362327, 585510095036421}, + }, + { + {4596693410811983, 3239555606447835, 5319792910601399, 5807716310972140, 4978776737081211}, + {4298118886570999, 2595714642338047, 2582204981507639, 2283950348816052, 2880808000087105}, + {1625024000487589, 1577328585741835, 1748162688303583, 1508135442094103, 494130659185316}, + }, + { + {5133202328939711, 5161068400634691, 4982689133170151, 5479854286391464, 3974357722065660}, + {2759508860286693, 3544879646603215, 2393702940511177, 1786833813469860, 2879003887330732}, + {374825657994223, 798281160160783, 1037106323566812, 1491213365794340, 786385610113834}, + }, + }, + } + + GE_BASEPOINT_TABLE := &Gen_Multiply_Table_edwards25519_lo[0] +} diff --git a/core/crypto/_edwards25519/tools/edwards_gen_tables.odin b/core/crypto/_edwards25519/tools/edwards_gen_tables.odin new file mode 100644 index 000000000..d05534d9d --- /dev/null +++ b/core/crypto/_edwards25519/tools/edwards_gen_tables.odin @@ -0,0 +1,134 @@ +package weistrass_tools + +import ed "core:crypto/_edwards25519" +import field "core:crypto/_fiat/field_curve25519" +import scalar "core:crypto/_fiat/field_scalar25519" +import "core:encoding/endian" +import "core:fmt" +import path "core:path/filepath" +import "core:os" +import "core:strings" + +// Yes this leaks memory, fite me IRL. + +GENERATED :: `/* + ------ GENERATED ------ DO NOT EDIT ------ GENERATED ------ DO NOT EDIT ------ GENERATED ------ +*/` + +@(private, rodata) +FE_D2 := field.Tight_Field_Element { + 1859910466990425, + 932731440258426, + 1072319116312658, + 1815898335770999, + 633789495995903, +} + +main :: proc() { + Basepoint_Addend_Group_Element :: struct { + y2_minus_x2: field.Loose_Field_Element, // t1 + y2_plus_x2: field.Loose_Field_Element, // t3 + k_times_t2: field.Tight_Field_Element, // t4 + } + Basepoint_Multiply_Table :: [15]Basepoint_Addend_Group_Element + + ge_bp_addend_set := proc(ge_a: ^Basepoint_Addend_Group_Element, ge: ^ed.Group_Element) { + // We rescale so Z == 1, so T = X * Y + x_, y_, z_inv: field.Tight_Field_Element + field.fe_carry_inv(&z_inv, field.fe_relax_cast(&ge.z)) + field.fe_carry_mul(&x_, field.fe_relax_cast(&ge.x), field.fe_relax_cast(&z_inv)) + field.fe_carry_mul(&y_, field.fe_relax_cast(&ge.y), field.fe_relax_cast(&z_inv)) + + field.fe_sub(&ge_a.y2_minus_x2, &y_, &x_) + field.fe_add(&ge_a.y2_plus_x2, &y_, &x_) + field.fe_carry_mul(&ge_a.k_times_t2, field.fe_relax_cast(&x_), field.fe_relax_cast(&y_)) + field.fe_carry_mul(&ge_a.k_times_t2, field.fe_relax_cast(&ge_a.k_times_t2), field.fe_relax_cast(&FE_D2)) + } + + Multiply_Table_hi: [32]Basepoint_Multiply_Table + Multiply_Table_lo: [32]Basepoint_Multiply_Table + + sc_set_unchecked := proc(sc: ^scalar.Non_Montgomery_Domain_Field_Element, b: []byte) { + sc[0] = endian.unchecked_get_u64le(b[0:]) + sc[1] = endian.unchecked_get_u64le(b[8:]) + sc[2] = endian.unchecked_get_u64le(b[16:]) + sc[3] = endian.unchecked_get_u64le(b[24:]) + } + + g, p: ed.Group_Element + ed.ge_generator(&g) + + sc: scalar.Non_Montgomery_Domain_Field_Element + + // Precompute ([1,15] << n) * G multiples of G, LSB->MSB + for i in 0..<32 { + b: [32]byte + for j in 1..<16 { + b[i] = u8(j) + sc_set_unchecked(&sc, b[:]) + ed.ge_scalarmult_raw(&p, &g, &sc, true) + ge_bp_addend_set(&Multiply_Table_lo[i][j-1], &p) + + b[i] = u8(j) << 4 + sc_set_unchecked(&sc, b[:]) + ed.ge_scalarmult_raw(&p, &g, &sc, true) + ge_bp_addend_set(&Multiply_Table_hi[i][j-1], &p) + + b[i] = 0 + } + } + + fn := path.join({ODIN_ROOT, "core", "crypto", "_edwards25519", "edwards25519_table.odin"}) + bld: strings.Builder + w := strings.to_writer(&bld) + + fmt.wprintln(w, "package _edwards25519") + fmt.wprintln(w, "") + fmt.wprintln(w, GENERATED) + fmt.wprintln(w, "") + fmt.wprintln(w, "import \"core:crypto\"") + fmt.wprintln(w, "") + fmt.wprintln(w, "when crypto.COMPACT_IMPLS == false {") + + fmt.wprintln(w, "\t@(private,rodata)") + fmt.wprintln(w, "\tGen_Multiply_Table_edwards25519_lo := [32]Basepoint_Multiply_Table {") + for &v in Multiply_Table_lo { + fmt.wprintln(w, "\t\t{") + for &ap in v { + fmt.wprintln(w, "\t\t\t{") + + t1, t3, t4 := &ap.y2_minus_x2, &ap.y2_plus_x2, &ap.k_times_t2 + fmt.wprintf(w, "\t\t\t\t{{%d, %d, %d, %d, %d},\n", t1[0], t1[1], t1[2], t1[3], t1[4]) + fmt.wprintf(w, "\t\t\t\t{{%d, %d, %d, %d, %d},\n", t3[0], t3[1], t3[2], t3[3], t3[4]) + fmt.wprintf(w, "\t\t\t\t{{%d, %d, %d, %d, %d},\n", t4[0], t4[1], t4[2], t4[3], t4[4]) + + fmt.wprintln(w, "\t\t\t},") + } + fmt.wprintln(w, "\t\t},") + } + fmt.wprintln(w, "\t}\n") + + fmt.wprintln(w, "\t@(private,rodata)") + fmt.wprintln(w, "\tGen_Multiply_Table_edwards25519_hi := [32]Basepoint_Multiply_Table {") + for &v in Multiply_Table_hi { + fmt.wprintln(w, "\t\t{") + for &ap in v { + fmt.wprintln(w, "\t\t\t{") + + t1, t3, t4 := &ap.y2_minus_x2, &ap.y2_plus_x2, &ap.k_times_t2 + fmt.wprintf(w, "\t\t\t\t{{%d, %d, %d, %d, %d},\n", t1[0], t1[1], t1[2], t1[3], t1[4]) + fmt.wprintf(w, "\t\t\t\t{{%d, %d, %d, %d, %d},\n", t3[0], t3[1], t3[2], t3[3], t3[4]) + fmt.wprintf(w, "\t\t\t\t{{%d, %d, %d, %d, %d},\n", t4[0], t4[1], t4[2], t4[3], t4[4]) + + fmt.wprintln(w, "\t\t\t},") + } + fmt.wprintln(w, "\t\t},") + } + fmt.wprintln(w, "\t}\n") + + fmt.wprintln(w, "\tGE_BASEPOINT_TABLE := &Gen_Multiply_Table_edwards25519_lo[0]") + + fmt.wprintln(w, "}") + + _ = os.write_entire_file(fn, transmute([]byte)(strings.to_string(bld))) +} diff --git a/core/crypto/_fiat/field_p256r1/field.odin b/core/crypto/_fiat/field_p256r1/field.odin new file mode 100644 index 000000000..b1662fd48 --- /dev/null +++ b/core/crypto/_fiat/field_p256r1/field.odin @@ -0,0 +1,346 @@ +package field_p256r1 + +import subtle "core:crypto/_subtle" +import "core:encoding/endian" +import "core:math/bits" +import "core:mem" + +fe_clear :: proc "contextless" (arg1: ^Montgomery_Domain_Field_Element) { + mem.zero_explicit(arg1, size_of(Montgomery_Domain_Field_Element)) +} + +fe_clear_vec :: proc "contextless" ( + arg1: []^Montgomery_Domain_Field_Element, +) { + for fe in arg1 { + fe_clear(fe) + } +} + +fe_from_bytes :: proc "contextless" ( + out1: ^Montgomery_Domain_Field_Element, + arg1: []byte, + unsafe_assume_canonical := false, +) -> bool { + ensure_contextless(len(arg1) == 32, "p256r1: invalid fe input buffer") + + // Note: We assume the input is in big-endian. + tmp := Non_Montgomery_Domain_Field_Element { + endian.unchecked_get_u64be(arg1[24:]), + endian.unchecked_get_u64be(arg1[16:]), + endian.unchecked_get_u64be(arg1[8:]), + endian.unchecked_get_u64be(arg1[0:]), + } + defer mem.zero_explicit(&tmp, size_of(tmp)) + + // Check that tmp is in the the range [0, ELL). + if !unsafe_assume_canonical { + _, borrow := bits.sub_u64(ELL[0] - 1, tmp[0], 0) + _, borrow = bits.sub_u64(ELL[1], tmp[1], borrow) + _, borrow = bits.sub_u64(ELL[2], tmp[2], borrow) + _, borrow = bits.sub_u64(ELL[3], tmp[3], borrow) + if borrow != 0 { + return false + } + } + + fe_to_montgomery(out1, &tmp) + + return true +} + +fe_to_bytes :: proc "contextless" (out1: []byte, arg1: ^Montgomery_Domain_Field_Element) { + ensure_contextless(len(out1) == 32, "p256r1: invalid fe output buffer") + + tmp: Non_Montgomery_Domain_Field_Element + fe_from_montgomery(&tmp, arg1) + + // Note: Likewise, output in big-endian. + endian.unchecked_put_u64be(out1[24:], tmp[0]) + endian.unchecked_put_u64be(out1[16:], tmp[1]) + endian.unchecked_put_u64be(out1[8:], tmp[2]) + endian.unchecked_put_u64be(out1[0:], tmp[3]) + + mem.zero_explicit(&tmp, size_of(tmp)) +} + +@(require_results) +fe_equal :: proc "contextless" (arg1, arg2: ^Montgomery_Domain_Field_Element) -> int { + tmp: Montgomery_Domain_Field_Element + fe_sub(&tmp, arg1, arg2) + + // This will only underflow iff arg1 == arg2, and we return the borrow, + // which will be 1. + is_eq := subtle.u64_is_zero(fe_non_zero(&tmp)) + + fe_clear(&tmp) + + return int(is_eq) +} + +@(require_results) +fe_is_odd :: proc "contextless" (arg1: ^Montgomery_Domain_Field_Element) -> int { + tmp: Non_Montgomery_Domain_Field_Element + defer mem.zero_explicit(&tmp, size_of(tmp)) + + fe_from_montgomery(&tmp, arg1) + return int(tmp[0] & 1) +} + +fe_pow2k :: proc "contextless" ( + out1: ^Montgomery_Domain_Field_Element, + arg1: ^Montgomery_Domain_Field_Element, + arg2: uint, +) { + // Special case: `arg1^(2 * 0) = 1`, though this should never happen. + if arg2 == 0 { + fe_one(out1) + return + } + + fe_square(out1, arg1) + for _ in 1 ..< arg2 { + fe_square(out1, out1) + } +} + +fe_inv :: proc "contextless" (out1, arg1: ^Montgomery_Domain_Field_Element) { + // Inversion computation is derived from the addition chain: + // + // _10 = 2*1 + // _11 = 1 + _10 + // _110 = 2*_11 + // _111 = 1 + _110 + // _111000 = _111 << 3 + // _111111 = _111 + _111000 + // x12 = _111111 << 6 + _111111 + // x15 = x12 << 3 + _111 + // x16 = 2*x15 + 1 + // x32 = x16 << 16 + x16 + // i53 = x32 << 15 + // x47 = x15 + i53 + // i263 = ((i53 << 17 + 1) << 143 + x47) << 47 + // return (x47 + i263) << 2 + // + // Operations: 255 squares 11 multiplies + // + // Generated by github.com/mmcloughlin/addchain v0.4.0. + + // Note: Need to stash `arg1` (`xx`) in the case that `out1`/`arg1` alias, + // as `arg1` is used after `out1` has been altered. + t0, t1, xx: Montgomery_Domain_Field_Element = ---, ---, arg1^ + + // Step 1: z = x^0x2 + fe_square(out1, arg1) + + // Step 2: z = x^0x3 + fe_mul(out1, &xx, out1) + + // Step 3: z = x^0x6 + fe_square(out1, out1) + + // Step 4: z = x^0x7 + fe_mul(out1, &xx, out1) + + // Step 7: t0 = x^0x38 + fe_pow2k(&t0, out1, 3) + + // Step 8: t0 = x^0x3f + fe_mul(&t0, out1, &t0) + + // Step 14: t1 = x^0xfc0 + fe_pow2k(&t1, &t0, 6) + + // Step 15: t0 = x^0xfff + fe_mul(&t0, &t0, &t1) + + // Step 18: t0 = x^0x7ff8 + fe_pow2k(&t0, &t0, 3) + + // Step 19: z = x^0x7fff + fe_mul(out1, out1, &t0) + + // Step 20: t0 = x^0xfffe + fe_square(&t0, out1) + + // Step 21: t0 = x^0xffff + fe_mul(&t0, &xx, &t0) + + // Step 37: t1 = x^0xffff0000 + fe_pow2k(&t1, &t0, 16) + + // Step 38: t0 = x^0xffffffff + fe_mul(&t0, &t0, &t1) + + // Step 53: t0 = x^0x7fffffff8000 + fe_pow2k(&t0, &t0, 15) + + // Step 54: z = x^0x7fffffffffff + fe_mul(out1, out1, &t0) + + // Step 71: t0 = x^0xffffffff00000000 + fe_pow2k(&t0, &t0, 17) + + // Step 72: t0 = x^0xffffffff00000001 + fe_mul(&t0, &xx, &t0) + + // Step 215: t0 = x^0x7fffffff80000000800000000000000000000000000000000000 + fe_pow2k(&t0, &t0, 143) + + // Step 216: t0 = x^0x7fffffff800000008000000000000000000000007fffffffffff + fe_mul(&t0, out1, &t0) + + // Step 263: t0 = x^0x3fffffffc00000004000000000000000000000003fffffffffff800000000000 + fe_pow2k(&t0, &t0, 47) + + // Step 264: z = x^0x3fffffffc00000004000000000000000000000003fffffffffffffffffffffff + fe_mul(out1, out1, &t0) + + // Step 266: z = x^0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc + fe_pow2k(out1, out1, 2) + + fe_mul(out1, out1, &xx) + + fe_clear_vec([]^Montgomery_Domain_Field_Element{&t0, &t1, &xx}) +} + +@(require_results) +fe_sqrt :: proc "contextless" (out1, arg1: ^Montgomery_Domain_Field_Element) -> int { + // Square root candidate can be derived via exponentiation by `(p + 1) / 4` + // From sage: 28948022302589062190674361737351893382521535853822578548883407827216774463488 + // + // // Inversion computation is derived from the addition chain: + // + // _10 = 2*1 + // _11 = 1 + _10 + // _1100 = _11 << 2 + // _1111 = _11 + _1100 + // _11110000 = _1111 << 4 + // _11111111 = _1111 + _11110000 + // x16 = _11111111 << 8 + _11111111 + // x32 = x16 << 16 + x16 + // return ((x32 << 32 + 1) << 96 + 1) << 94 + // + // Operations: 253 squares 7 multiplies + // + // Generated by github.com/mmcloughlin/addchain v0.4.0. + + // Likewise this tramples over arg1, so stash another copy. + t0, xx: Montgomery_Domain_Field_Element = ---, arg1^ + + // Step 1: z = x^0x2 + fe_square(out1, arg1) + + // Step 2: z = x^0x3 + fe_mul(out1, &xx, out1) + + // Step 4: t0 = x^0xc + fe_pow2k(&t0, &xx, 2) + + // Step 5: z = x^0xf + fe_mul(out1, out1, &t0) + + // Step 9: t0 = x^0xf0 + fe_pow2k(&t0, out1, 4) + + // Step 10: z = x^0xff + fe_mul(out1, out1, &t0) + + // Step 18: t0 = x^0xff00 + fe_pow2k(&t0, out1, 8) + + // Step 19: z = x^0xffff + fe_mul(out1, out1, &t0) + + // Step 35: t0 = x^0xffff0000 + fe_pow2k(&t0, out1, 16) + + // Step 36: z = x^0xffffffff + fe_mul(out1, out1, &t0) + + // Step 68: z = x^0xffffffff00000000 + fe_pow2k(out1, out1, 32) + + // Step 69: z = x^0xffffffff00000001 + fe_mul(out1, &xx, out1) + + // Step 165: z = x^0xffffffff00000001000000000000000000000000 + fe_pow2k(out1, out1, 96) + + // Step 166: z = x^0xffffffff00000001000000000000000000000001 + fe_mul(out1, &xx, out1) + + // Step 260: z = x^0x3fffffffc0000000400000000000000000000000400000000000000000000000 + fe_pow2k(out1, out1, 94) + + // Ensure that our candidate is actually the square root. + check, zero: Montgomery_Domain_Field_Element + fe_square(&check, out1) + + is_valid := fe_equal(&check, &xx) + fe_cond_select(out1, &zero, out1, is_valid) + + fe_clear_vec([]^Montgomery_Domain_Field_Element{&t0, &xx, &check}) + + return is_valid + +} + +fe_zero :: proc "contextless" (out1: ^Montgomery_Domain_Field_Element) { + out1[0] = 0 + out1[1] = 0 + out1[2] = 0 + out1[3] = 0 +} + +fe_set :: proc "contextless" (out1, arg1: ^Montgomery_Domain_Field_Element) { + x1 := arg1[0] + x2 := arg1[1] + x3 := arg1[2] + x4 := arg1[3] + out1[0] = x1 + out1[1] = x2 + out1[2] = x3 + out1[3] = x4 +} + +@(optimization_mode = "none") +fe_cond_swap :: #force_no_inline proc "contextless" (out1, out2: ^Montgomery_Domain_Field_Element, arg1: int) { + mask := (u64(arg1) * 0xffffffffffffffff) + x := (out1[0] ~ out2[0]) & mask + x1, y1 := out1[0] ~ x, out2[0] ~ x + x = (out1[1] ~ out2[1]) & mask + x2, y2 := out1[1] ~ x, out2[1] ~ x + x = (out1[2] ~ out2[2]) & mask + x3, y3 := out1[2] ~ x, out2[2] ~ x + x = (out1[3] ~ out2[3]) & mask + x4, y4 := out1[3] ~ x, out2[3] ~ x + out1[0], out2[0] = x1, y1 + out1[1], out2[1] = x2, y2 + out1[2], out2[2] = x3, y3 + out1[3], out2[3] = x4, y4 +} + +@(optimization_mode = "none") +fe_cond_select :: #force_no_inline proc "contextless" ( + out1, arg1, arg2: ^Montgomery_Domain_Field_Element, + arg3: int, +) { + mask := (u64(arg3) * 0xffffffffffffffff) + x1 := ((mask & arg2[0]) | ((~mask) & arg1[0])) + x2 := ((mask & arg2[1]) | ((~mask) & arg1[1])) + x3 := ((mask & arg2[2]) | ((~mask) & arg1[2])) + x4 := ((mask & arg2[3]) | ((~mask) & arg1[3])) + out1[0] = x1 + out1[1] = x2 + out1[2] = x3 + out1[3] = x4 +} + +fe_cond_negate :: proc "contextless" (out1, arg1: ^Montgomery_Domain_Field_Element, ctrl: int) { + tmp1: Montgomery_Domain_Field_Element = --- + fe_opp(&tmp1, arg1) + fe_cond_select(out1, arg1, &tmp1, ctrl) + + fe_clear(&tmp1) +} diff --git a/core/crypto/_fiat/field_p256r1/field64.odin b/core/crypto/_fiat/field_p256r1/field64.odin new file mode 100644 index 000000000..940f2cd07 --- /dev/null +++ b/core/crypto/_fiat/field_p256r1/field64.odin @@ -0,0 +1,501 @@ +// The BSD 1-Clause License (BSD-1-Clause) +// +// Copyright (c) 2015-2020 the fiat-crypto authors (see the AUTHORS file) +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// THIS SOFTWARE IS PROVIDED BY the fiat-crypto authors "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, +// Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package field_p256r1 + +// The file provides arithmetic on the field Z/(2^256 - 2^224 + 2^192 + 2^96 - 1) +// using a 64-bit Montgomery form internal representation. It is derived +// primarily from the machine generated Golang output from the fiat-crypto +// project. +// +// While the base implementation is provably correct, this implementation +// makes no such claims as the port and optimizations were done by hand. +// +// WARNING: While big-endian is the common representation used for this +// curve, the fiat output uses least-significant-limb first. + +import fiat "core:crypto/_fiat" +import "core:math/bits" + +// ELL is the saturated representation of the field order, least-significant +// limb first. +ELL :: [4]u64{0xffffffffffffffff, 0xffffffff, 0x0, 0xffffffff00000001} + +Montgomery_Domain_Field_Element :: distinct [4]u64 +Non_Montgomery_Domain_Field_Element :: distinct [4]u64 + +fe_mul :: proc "contextless" (out1, arg1, arg2: ^Montgomery_Domain_Field_Element) { + x1 := arg1[1] + x2 := arg1[2] + x3 := arg1[3] + x4 := arg1[0] + x6, x5 := bits.mul_u64(x4, arg2[3]) + x8, x7 := bits.mul_u64(x4, arg2[2]) + x10, x9 := bits.mul_u64(x4, arg2[1]) + x12, x11 := bits.mul_u64(x4, arg2[0]) + x13, x14 := bits.add_u64(x12, x9, u64(0x0)) + x15, x16 := bits.add_u64(x10, x7, u64(fiat.u1(x14))) + x17, x18 := bits.add_u64(x8, x5, u64(fiat.u1(x16))) + x19 := (u64(fiat.u1(x18)) + x6) + x21, x20 := bits.mul_u64(x11, 0xffffffff00000001) + x23, x22 := bits.mul_u64(x11, 0xffffffff) + x25, x24 := bits.mul_u64(x11, 0xffffffffffffffff) + x26, x27 := bits.add_u64(x25, x22, u64(0x0)) + x28 := (u64(fiat.u1(x27)) + x23) + _, x30 := bits.add_u64(x11, x24, u64(0x0)) + x31, x32 := bits.add_u64(x13, x26, u64(fiat.u1(x30))) + x33, x34 := bits.add_u64(x15, x28, u64(fiat.u1(x32))) + x35, x36 := bits.add_u64(x17, x20, u64(fiat.u1(x34))) + x37, x38 := bits.add_u64(x19, x21, u64(fiat.u1(x36))) + x40, x39 := bits.mul_u64(x1, arg2[3]) + x42, x41 := bits.mul_u64(x1, arg2[2]) + x44, x43 := bits.mul_u64(x1, arg2[1]) + x46, x45 := bits.mul_u64(x1, arg2[0]) + x47, x48 := bits.add_u64(x46, x43, u64(0x0)) + x49, x50 := bits.add_u64(x44, x41, u64(fiat.u1(x48))) + x51, x52 := bits.add_u64(x42, x39, u64(fiat.u1(x50))) + x53 := (u64(fiat.u1(x52)) + x40) + x54, x55 := bits.add_u64(x31, x45, u64(0x0)) + x56, x57 := bits.add_u64(x33, x47, u64(fiat.u1(x55))) + x58, x59 := bits.add_u64(x35, x49, u64(fiat.u1(x57))) + x60, x61 := bits.add_u64(x37, x51, u64(fiat.u1(x59))) + x62, x63 := bits.add_u64(u64(fiat.u1(x38)), x53, u64(fiat.u1(x61))) + x65, x64 := bits.mul_u64(x54, 0xffffffff00000001) + x67, x66 := bits.mul_u64(x54, 0xffffffff) + x69, x68 := bits.mul_u64(x54, 0xffffffffffffffff) + x70, x71 := bits.add_u64(x69, x66, u64(0x0)) + x72 := (u64(fiat.u1(x71)) + x67) + _, x74 := bits.add_u64(x54, x68, u64(0x0)) + x75, x76 := bits.add_u64(x56, x70, u64(fiat.u1(x74))) + x77, x78 := bits.add_u64(x58, x72, u64(fiat.u1(x76))) + x79, x80 := bits.add_u64(x60, x64, u64(fiat.u1(x78))) + x81, x82 := bits.add_u64(x62, x65, u64(fiat.u1(x80))) + x83 := (u64(fiat.u1(x82)) + u64(fiat.u1(x63))) + x85, x84 := bits.mul_u64(x2, arg2[3]) + x87, x86 := bits.mul_u64(x2, arg2[2]) + x89, x88 := bits.mul_u64(x2, arg2[1]) + x91, x90 := bits.mul_u64(x2, arg2[0]) + x92, x93 := bits.add_u64(x91, x88, u64(0x0)) + x94, x95 := bits.add_u64(x89, x86, u64(fiat.u1(x93))) + x96, x97 := bits.add_u64(x87, x84, u64(fiat.u1(x95))) + x98 := (u64(fiat.u1(x97)) + x85) + x99, x100 := bits.add_u64(x75, x90, u64(0x0)) + x101, x102 := bits.add_u64(x77, x92, u64(fiat.u1(x100))) + x103, x104 := bits.add_u64(x79, x94, u64(fiat.u1(x102))) + x105, x106 := bits.add_u64(x81, x96, u64(fiat.u1(x104))) + x107, x108 := bits.add_u64(x83, x98, u64(fiat.u1(x106))) + x110, x109 := bits.mul_u64(x99, 0xffffffff00000001) + x112, x111 := bits.mul_u64(x99, 0xffffffff) + x114, x113 := bits.mul_u64(x99, 0xffffffffffffffff) + x115, x116 := bits.add_u64(x114, x111, u64(0x0)) + x117 := (u64(fiat.u1(x116)) + x112) + _, x119 := bits.add_u64(x99, x113, u64(0x0)) + x120, x121 := bits.add_u64(x101, x115, u64(fiat.u1(x119))) + x122, x123 := bits.add_u64(x103, x117, u64(fiat.u1(x121))) + x124, x125 := bits.add_u64(x105, x109, u64(fiat.u1(x123))) + x126, x127 := bits.add_u64(x107, x110, u64(fiat.u1(x125))) + x128 := (u64(fiat.u1(x127)) + u64(fiat.u1(x108))) + x130, x129 := bits.mul_u64(x3, arg2[3]) + x132, x131 := bits.mul_u64(x3, arg2[2]) + x134, x133 := bits.mul_u64(x3, arg2[1]) + x136, x135 := bits.mul_u64(x3, arg2[0]) + x137, x138 := bits.add_u64(x136, x133, u64(0x0)) + x139, x140 := bits.add_u64(x134, x131, u64(fiat.u1(x138))) + x141, x142 := bits.add_u64(x132, x129, u64(fiat.u1(x140))) + x143 := (u64(fiat.u1(x142)) + x130) + x144, x145 := bits.add_u64(x120, x135, u64(0x0)) + x146, x147 := bits.add_u64(x122, x137, u64(fiat.u1(x145))) + x148, x149 := bits.add_u64(x124, x139, u64(fiat.u1(x147))) + x150, x151 := bits.add_u64(x126, x141, u64(fiat.u1(x149))) + x152, x153 := bits.add_u64(x128, x143, u64(fiat.u1(x151))) + x155, x154 := bits.mul_u64(x144, 0xffffffff00000001) + x157, x156 := bits.mul_u64(x144, 0xffffffff) + x159, x158 := bits.mul_u64(x144, 0xffffffffffffffff) + x160, x161 := bits.add_u64(x159, x156, u64(0x0)) + x162 := (u64(fiat.u1(x161)) + x157) + _, x164 := bits.add_u64(x144, x158, u64(0x0)) + x165, x166 := bits.add_u64(x146, x160, u64(fiat.u1(x164))) + x167, x168 := bits.add_u64(x148, x162, u64(fiat.u1(x166))) + x169, x170 := bits.add_u64(x150, x154, u64(fiat.u1(x168))) + x171, x172 := bits.add_u64(x152, x155, u64(fiat.u1(x170))) + x173 := (u64(fiat.u1(x172)) + u64(fiat.u1(x153))) + x174, x175 := bits.sub_u64(x165, 0xffffffffffffffff, u64(0x0)) + x176, x177 := bits.sub_u64(x167, 0xffffffff, u64(fiat.u1(x175))) + x178, x179 := bits.sub_u64(x169, u64(0x0), u64(fiat.u1(x177))) + x180, x181 := bits.sub_u64(x171, 0xffffffff00000001, u64(fiat.u1(x179))) + _, x183 := bits.sub_u64(x173, u64(0x0), u64(fiat.u1(x181))) + x184 := fiat.cmovznz_u64(fiat.u1(x183), x174, x165) + x185 := fiat.cmovznz_u64(fiat.u1(x183), x176, x167) + x186 := fiat.cmovznz_u64(fiat.u1(x183), x178, x169) + x187 := fiat.cmovznz_u64(fiat.u1(x183), x180, x171) + out1[0] = x184 + out1[1] = x185 + out1[2] = x186 + out1[3] = x187 +} + +fe_square :: proc "contextless" (out1, arg1: ^Montgomery_Domain_Field_Element) { + x1 := arg1[1] + x2 := arg1[2] + x3 := arg1[3] + x4 := arg1[0] + x6, x5 := bits.mul_u64(x4, arg1[3]) + x8, x7 := bits.mul_u64(x4, arg1[2]) + x10, x9 := bits.mul_u64(x4, arg1[1]) + x12, x11 := bits.mul_u64(x4, arg1[0]) + x13, x14 := bits.add_u64(x12, x9, u64(0x0)) + x15, x16 := bits.add_u64(x10, x7, u64(fiat.u1(x14))) + x17, x18 := bits.add_u64(x8, x5, u64(fiat.u1(x16))) + x19 := (u64(fiat.u1(x18)) + x6) + x21, x20 := bits.mul_u64(x11, 0xffffffff00000001) + x23, x22 := bits.mul_u64(x11, 0xffffffff) + x25, x24 := bits.mul_u64(x11, 0xffffffffffffffff) + x26, x27 := bits.add_u64(x25, x22, u64(0x0)) + x28 := (u64(fiat.u1(x27)) + x23) + _, x30 := bits.add_u64(x11, x24, u64(0x0)) + x31, x32 := bits.add_u64(x13, x26, u64(fiat.u1(x30))) + x33, x34 := bits.add_u64(x15, x28, u64(fiat.u1(x32))) + x35, x36 := bits.add_u64(x17, x20, u64(fiat.u1(x34))) + x37, x38 := bits.add_u64(x19, x21, u64(fiat.u1(x36))) + x40, x39 := bits.mul_u64(x1, arg1[3]) + x42, x41 := bits.mul_u64(x1, arg1[2]) + x44, x43 := bits.mul_u64(x1, arg1[1]) + x46, x45 := bits.mul_u64(x1, arg1[0]) + x47, x48 := bits.add_u64(x46, x43, u64(0x0)) + x49, x50 := bits.add_u64(x44, x41, u64(fiat.u1(x48))) + x51, x52 := bits.add_u64(x42, x39, u64(fiat.u1(x50))) + x53 := (u64(fiat.u1(x52)) + x40) + x54, x55 := bits.add_u64(x31, x45, u64(0x0)) + x56, x57 := bits.add_u64(x33, x47, u64(fiat.u1(x55))) + x58, x59 := bits.add_u64(x35, x49, u64(fiat.u1(x57))) + x60, x61 := bits.add_u64(x37, x51, u64(fiat.u1(x59))) + x62, x63 := bits.add_u64(u64(fiat.u1(x38)), x53, u64(fiat.u1(x61))) + x65, x64 := bits.mul_u64(x54, 0xffffffff00000001) + x67, x66 := bits.mul_u64(x54, 0xffffffff) + x69, x68 := bits.mul_u64(x54, 0xffffffffffffffff) + x70, x71 := bits.add_u64(x69, x66, u64(0x0)) + x72 := (u64(fiat.u1(x71)) + x67) + _, x74 := bits.add_u64(x54, x68, u64(0x0)) + x75, x76 := bits.add_u64(x56, x70, u64(fiat.u1(x74))) + x77, x78 := bits.add_u64(x58, x72, u64(fiat.u1(x76))) + x79, x80 := bits.add_u64(x60, x64, u64(fiat.u1(x78))) + x81, x82 := bits.add_u64(x62, x65, u64(fiat.u1(x80))) + x83 := (u64(fiat.u1(x82)) + u64(fiat.u1(x63))) + x85, x84 := bits.mul_u64(x2, arg1[3]) + x87, x86 := bits.mul_u64(x2, arg1[2]) + x89, x88 := bits.mul_u64(x2, arg1[1]) + x91, x90 := bits.mul_u64(x2, arg1[0]) + x92, x93 := bits.add_u64(x91, x88, u64(0x0)) + x94, x95 := bits.add_u64(x89, x86, u64(fiat.u1(x93))) + x96, x97 := bits.add_u64(x87, x84, u64(fiat.u1(x95))) + x98 := (u64(fiat.u1(x97)) + x85) + x99, x100 := bits.add_u64(x75, x90, u64(0x0)) + x101, x102 := bits.add_u64(x77, x92, u64(fiat.u1(x100))) + x103, x104 := bits.add_u64(x79, x94, u64(fiat.u1(x102))) + x105, x106 := bits.add_u64(x81, x96, u64(fiat.u1(x104))) + x107, x108 := bits.add_u64(x83, x98, u64(fiat.u1(x106))) + x110, x109 := bits.mul_u64(x99, 0xffffffff00000001) + x112, x111 := bits.mul_u64(x99, 0xffffffff) + x114, x113 := bits.mul_u64(x99, 0xffffffffffffffff) + x115, x116 := bits.add_u64(x114, x111, u64(0x0)) + x117 := (u64(fiat.u1(x116)) + x112) + _, x119 := bits.add_u64(x99, x113, u64(0x0)) + x120, x121 := bits.add_u64(x101, x115, u64(fiat.u1(x119))) + x122, x123 := bits.add_u64(x103, x117, u64(fiat.u1(x121))) + x124, x125 := bits.add_u64(x105, x109, u64(fiat.u1(x123))) + x126, x127 := bits.add_u64(x107, x110, u64(fiat.u1(x125))) + x128 := (u64(fiat.u1(x127)) + u64(fiat.u1(x108))) + x130, x129 := bits.mul_u64(x3, arg1[3]) + x132, x131 := bits.mul_u64(x3, arg1[2]) + x134, x133 := bits.mul_u64(x3, arg1[1]) + x136, x135 := bits.mul_u64(x3, arg1[0]) + x137, x138 := bits.add_u64(x136, x133, u64(0x0)) + x139, x140 := bits.add_u64(x134, x131, u64(fiat.u1(x138))) + x141, x142 := bits.add_u64(x132, x129, u64(fiat.u1(x140))) + x143 := (u64(fiat.u1(x142)) + x130) + x144, x145 := bits.add_u64(x120, x135, u64(0x0)) + x146, x147 := bits.add_u64(x122, x137, u64(fiat.u1(x145))) + x148, x149 := bits.add_u64(x124, x139, u64(fiat.u1(x147))) + x150, x151 := bits.add_u64(x126, x141, u64(fiat.u1(x149))) + x152, x153 := bits.add_u64(x128, x143, u64(fiat.u1(x151))) + x155, x154 := bits.mul_u64(x144, 0xffffffff00000001) + x157, x156 := bits.mul_u64(x144, 0xffffffff) + x159, x158 := bits.mul_u64(x144, 0xffffffffffffffff) + x160, x161 := bits.add_u64(x159, x156, u64(0x0)) + x162 := (u64(fiat.u1(x161)) + x157) + _, x164 := bits.add_u64(x144, x158, u64(0x0)) + x165, x166 := bits.add_u64(x146, x160, u64(fiat.u1(x164))) + x167, x168 := bits.add_u64(x148, x162, u64(fiat.u1(x166))) + x169, x170 := bits.add_u64(x150, x154, u64(fiat.u1(x168))) + x171, x172 := bits.add_u64(x152, x155, u64(fiat.u1(x170))) + x173 := (u64(fiat.u1(x172)) + u64(fiat.u1(x153))) + x174, x175 := bits.sub_u64(x165, 0xffffffffffffffff, u64(0x0)) + x176, x177 := bits.sub_u64(x167, 0xffffffff, u64(fiat.u1(x175))) + x178, x179 := bits.sub_u64(x169, u64(0x0), u64(fiat.u1(x177))) + x180, x181 := bits.sub_u64(x171, 0xffffffff00000001, u64(fiat.u1(x179))) + _, x183 := bits.sub_u64(x173, u64(0x0), u64(fiat.u1(x181))) + x184 := fiat.cmovznz_u64(fiat.u1(x183), x174, x165) + x185 := fiat.cmovznz_u64(fiat.u1(x183), x176, x167) + x186 := fiat.cmovznz_u64(fiat.u1(x183), x178, x169) + x187 := fiat.cmovznz_u64(fiat.u1(x183), x180, x171) + out1[0] = x184 + out1[1] = x185 + out1[2] = x186 + out1[3] = x187 +} + +fe_add :: proc "contextless" (out1, arg1, arg2: ^Montgomery_Domain_Field_Element) { + x1, x2 := bits.add_u64(arg1[0], arg2[0], u64(0x0)) + x3, x4 := bits.add_u64(arg1[1], arg2[1], u64(fiat.u1(x2))) + x5, x6 := bits.add_u64(arg1[2], arg2[2], u64(fiat.u1(x4))) + x7, x8 := bits.add_u64(arg1[3], arg2[3], u64(fiat.u1(x6))) + x9, x10 := bits.sub_u64(x1, 0xffffffffffffffff, u64(0x0)) + x11, x12 := bits.sub_u64(x3, 0xffffffff, u64(fiat.u1(x10))) + x13, x14 := bits.sub_u64(x5, u64(0x0), u64(fiat.u1(x12))) + x15, x16 := bits.sub_u64(x7, 0xffffffff00000001, u64(fiat.u1(x14))) + _, x18 := bits.sub_u64(u64(fiat.u1(x8)), u64(0x0), u64(fiat.u1(x16))) + x19 := fiat.cmovznz_u64(fiat.u1(x18), x9, x1) + x20 := fiat.cmovznz_u64(fiat.u1(x18), x11, x3) + x21 := fiat.cmovznz_u64(fiat.u1(x18), x13, x5) + x22 := fiat.cmovznz_u64(fiat.u1(x18), x15, x7) + out1[0] = x19 + out1[1] = x20 + out1[2] = x21 + out1[3] = x22 +} + +fe_sub :: proc "contextless" (out1, arg1, arg2: ^Montgomery_Domain_Field_Element) { + x1, x2 := bits.sub_u64(arg1[0], arg2[0], u64(0x0)) + x3, x4 := bits.sub_u64(arg1[1], arg2[1], u64(fiat.u1(x2))) + x5, x6 := bits.sub_u64(arg1[2], arg2[2], u64(fiat.u1(x4))) + x7, x8 := bits.sub_u64(arg1[3], arg2[3], u64(fiat.u1(x6))) + x9 := fiat.cmovznz_u64(fiat.u1(x8), u64(0x0), 0xffffffffffffffff) + x10, x11 := bits.add_u64(x1, x9, u64(0x0)) + x12, x13 := bits.add_u64(x3, (x9 & 0xffffffff), u64(fiat.u1(x11))) + x14, x15 := bits.add_u64(x5, u64(0x0), u64(fiat.u1(x13))) + x16, _ := bits.add_u64(x7, (x9 & 0xffffffff00000001), u64(fiat.u1(x15))) + out1[0] = x10 + out1[1] = x12 + out1[2] = x14 + out1[3] = x16 +} + +fe_opp :: proc "contextless" (out1, arg1: ^Montgomery_Domain_Field_Element) { + x1, x2 := bits.sub_u64(u64(0x0), arg1[0], u64(0x0)) + x3, x4 := bits.sub_u64(u64(0x0), arg1[1], u64(fiat.u1(x2))) + x5, x6 := bits.sub_u64(u64(0x0), arg1[2], u64(fiat.u1(x4))) + x7, x8 := bits.sub_u64(u64(0x0), arg1[3], u64(fiat.u1(x6))) + x9 := fiat.cmovznz_u64(fiat.u1(x8), u64(0x0), 0xffffffffffffffff) + x10, x11 := bits.add_u64(x1, x9, u64(0x0)) + x12, x13 := bits.add_u64(x3, (x9 & 0xffffffff), u64(fiat.u1(x11))) + x14, x15 := bits.add_u64(x5, u64(0x0), u64(fiat.u1(x13))) + x16, _ := bits.add_u64(x7, (x9 & 0xffffffff00000001), u64(fiat.u1(x15))) + out1[0] = x10 + out1[1] = x12 + out1[2] = x14 + out1[3] = x16 +} + +fe_one :: proc "contextless" (out1: ^Montgomery_Domain_Field_Element) { + out1[0] = 0x1 + out1[1] = 0xffffffff00000000 + out1[2] = 0xffffffffffffffff + out1[3] = 0xfffffffe +} + +fe_non_zero :: proc "contextless" (arg1: ^Montgomery_Domain_Field_Element) -> u64 { + return arg1[0] | (arg1[1] | (arg1[2] | arg1[3])) +} + +@(optimization_mode = "none") +fe_cond_assign :: #force_no_inline proc "contextless" ( + out1, arg1: ^Montgomery_Domain_Field_Element, + arg2: int, +) { + x1 := fiat.cmovznz_u64(fiat.u1(arg2), out1[0], arg1[0]) + x2 := fiat.cmovznz_u64(fiat.u1(arg2), out1[1], arg1[1]) + x3 := fiat.cmovznz_u64(fiat.u1(arg2), out1[2], arg1[2]) + x4 := fiat.cmovznz_u64(fiat.u1(arg2), out1[3], arg1[3]) + out1[0] = x1 + out1[1] = x2 + out1[2] = x3 + out1[3] = x4 +} + +fe_from_montgomery :: proc "contextless" ( + out1: ^Non_Montgomery_Domain_Field_Element, + arg1: ^Montgomery_Domain_Field_Element, +) { + x1 := arg1[0] + x3, x2 := bits.mul_u64(x1, 0xffffffff00000001) + x5, x4 := bits.mul_u64(x1, 0xffffffff) + x7, x6 := bits.mul_u64(x1, 0xffffffffffffffff) + x8, x9 := bits.add_u64(x7, x4, u64(0x0)) + _, x11 := bits.add_u64(x1, x6, u64(0x0)) + x12, x13 := bits.add_u64(u64(0x0), x8, u64(fiat.u1(x11))) + x14, x15 := bits.add_u64(x12, arg1[1], u64(0x0)) + x17, x16 := bits.mul_u64(x14, 0xffffffff00000001) + x19, x18 := bits.mul_u64(x14, 0xffffffff) + x21, x20 := bits.mul_u64(x14, 0xffffffffffffffff) + x22, x23 := bits.add_u64(x21, x18, u64(0x0)) + _, x25 := bits.add_u64(x14, x20, u64(0x0)) + x26, x27 := bits.add_u64((u64(fiat.u1(x15)) + (u64(fiat.u1(x13)) + (u64(fiat.u1(x9)) + x5))), x22, u64(fiat.u1(x25))) + x28, x29 := bits.add_u64(x2, (u64(fiat.u1(x23)) + x19), u64(fiat.u1(x27))) + x30, x31 := bits.add_u64(x3, x16, u64(fiat.u1(x29))) + x32, x33 := bits.add_u64(x26, arg1[2], u64(0x0)) + x34, x35 := bits.add_u64(x28, u64(0x0), u64(fiat.u1(x33))) + x36, x37 := bits.add_u64(x30, u64(0x0), u64(fiat.u1(x35))) + x39, x38 := bits.mul_u64(x32, 0xffffffff00000001) + x41, x40 := bits.mul_u64(x32, 0xffffffff) + x43, x42 := bits.mul_u64(x32, 0xffffffffffffffff) + x44, x45 := bits.add_u64(x43, x40, u64(0x0)) + _, x47 := bits.add_u64(x32, x42, u64(0x0)) + x48, x49 := bits.add_u64(x34, x44, u64(fiat.u1(x47))) + x50, x51 := bits.add_u64(x36, (u64(fiat.u1(x45)) + x41), u64(fiat.u1(x49))) + x52, x53 := bits.add_u64((u64(fiat.u1(x37)) + (u64(fiat.u1(x31)) + x17)), x38, u64(fiat.u1(x51))) + x54, x55 := bits.add_u64(x48, arg1[3], u64(0x0)) + x56, x57 := bits.add_u64(x50, u64(0x0), u64(fiat.u1(x55))) + x58, x59 := bits.add_u64(x52, u64(0x0), u64(fiat.u1(x57))) + x61, x60 := bits.mul_u64(x54, 0xffffffff00000001) + x63, x62 := bits.mul_u64(x54, 0xffffffff) + x65, x64 := bits.mul_u64(x54, 0xffffffffffffffff) + x66, x67 := bits.add_u64(x65, x62, u64(0x0)) + _, x69 := bits.add_u64(x54, x64, u64(0x0)) + x70, x71 := bits.add_u64(x56, x66, u64(fiat.u1(x69))) + x72, x73 := bits.add_u64(x58, (u64(fiat.u1(x67)) + x63), u64(fiat.u1(x71))) + x74, x75 := bits.add_u64((u64(fiat.u1(x59)) + (u64(fiat.u1(x53)) + x39)), x60, u64(fiat.u1(x73))) + x76 := (u64(fiat.u1(x75)) + x61) + x77, x78 := bits.sub_u64(x70, 0xffffffffffffffff, u64(0x0)) + x79, x80 := bits.sub_u64(x72, 0xffffffff, u64(fiat.u1(x78))) + x81, x82 := bits.sub_u64(x74, u64(0x0), u64(fiat.u1(x80))) + x83, x84 := bits.sub_u64(x76, 0xffffffff00000001, u64(fiat.u1(x82))) + _, x86 := bits.sub_u64(u64(0x0), u64(0x0), u64(fiat.u1(x84))) + x87 := fiat.cmovznz_u64(fiat.u1(x86), x77, x70) + x88 := fiat.cmovznz_u64(fiat.u1(x86), x79, x72) + x89 := fiat.cmovznz_u64(fiat.u1(x86), x81, x74) + x90 := fiat.cmovznz_u64(fiat.u1(x86), x83, x76) + out1[0] = x87 + out1[1] = x88 + out1[2] = x89 + out1[3] = x90 +} + +fe_to_montgomery :: proc "contextless" ( + out1: ^Montgomery_Domain_Field_Element, + arg1: ^Non_Montgomery_Domain_Field_Element, +) { + x1 := arg1[1] + x2 := arg1[2] + x3 := arg1[3] + x4 := arg1[0] + x6, x5 := bits.mul_u64(x4, 0x4fffffffd) + x8, x7 := bits.mul_u64(x4, 0xfffffffffffffffe) + x10, x9 := bits.mul_u64(x4, 0xfffffffbffffffff) + x12, x11 := bits.mul_u64(x4, 0x3) + x13, x14 := bits.add_u64(x12, x9, u64(0x0)) + x15, x16 := bits.add_u64(x10, x7, u64(fiat.u1(x14))) + x17, x18 := bits.add_u64(x8, x5, u64(fiat.u1(x16))) + x20, x19 := bits.mul_u64(x11, 0xffffffff00000001) + x22, x21 := bits.mul_u64(x11, 0xffffffff) + x24, x23 := bits.mul_u64(x11, 0xffffffffffffffff) + x25, x26 := bits.add_u64(x24, x21, u64(0x0)) + _, x28 := bits.add_u64(x11, x23, u64(0x0)) + x29, x30 := bits.add_u64(x13, x25, u64(fiat.u1(x28))) + x31, x32 := bits.add_u64(x15, (u64(fiat.u1(x26)) + x22), u64(fiat.u1(x30))) + x33, x34 := bits.add_u64(x17, x19, u64(fiat.u1(x32))) + x35, x36 := bits.add_u64((u64(fiat.u1(x18)) + x6), x20, u64(fiat.u1(x34))) + x38, x37 := bits.mul_u64(x1, 0x4fffffffd) + x40, x39 := bits.mul_u64(x1, 0xfffffffffffffffe) + x42, x41 := bits.mul_u64(x1, 0xfffffffbffffffff) + x44, x43 := bits.mul_u64(x1, 0x3) + x45, x46 := bits.add_u64(x44, x41, u64(0x0)) + x47, x48 := bits.add_u64(x42, x39, u64(fiat.u1(x46))) + x49, x50 := bits.add_u64(x40, x37, u64(fiat.u1(x48))) + x51, x52 := bits.add_u64(x29, x43, u64(0x0)) + x53, x54 := bits.add_u64(x31, x45, u64(fiat.u1(x52))) + x55, x56 := bits.add_u64(x33, x47, u64(fiat.u1(x54))) + x57, x58 := bits.add_u64(x35, x49, u64(fiat.u1(x56))) + x60, x59 := bits.mul_u64(x51, 0xffffffff00000001) + x62, x61 := bits.mul_u64(x51, 0xffffffff) + x64, x63 := bits.mul_u64(x51, 0xffffffffffffffff) + x65, x66 := bits.add_u64(x64, x61, u64(0x0)) + _, x68 := bits.add_u64(x51, x63, u64(0x0)) + x69, x70 := bits.add_u64(x53, x65, u64(fiat.u1(x68))) + x71, x72 := bits.add_u64(x55, (u64(fiat.u1(x66)) + x62), u64(fiat.u1(x70))) + x73, x74 := bits.add_u64(x57, x59, u64(fiat.u1(x72))) + x75, x76 := bits.add_u64(((u64(fiat.u1(x58)) + u64(fiat.u1(x36))) + (u64(fiat.u1(x50)) + x38)), x60, u64(fiat.u1(x74))) + x78, x77 := bits.mul_u64(x2, 0x4fffffffd) + x80, x79 := bits.mul_u64(x2, 0xfffffffffffffffe) + x82, x81 := bits.mul_u64(x2, 0xfffffffbffffffff) + x84, x83 := bits.mul_u64(x2, 0x3) + x85, x86 := bits.add_u64(x84, x81, u64(0x0)) + x87, x88 := bits.add_u64(x82, x79, u64(fiat.u1(x86))) + x89, x90 := bits.add_u64(x80, x77, u64(fiat.u1(x88))) + x91, x92 := bits.add_u64(x69, x83, u64(0x0)) + x93, x94 := bits.add_u64(x71, x85, u64(fiat.u1(x92))) + x95, x96 := bits.add_u64(x73, x87, u64(fiat.u1(x94))) + x97, x98 := bits.add_u64(x75, x89, u64(fiat.u1(x96))) + x100, x99 := bits.mul_u64(x91, 0xffffffff00000001) + x102, x101 := bits.mul_u64(x91, 0xffffffff) + x104, x103 := bits.mul_u64(x91, 0xffffffffffffffff) + x105, x106 := bits.add_u64(x104, x101, u64(0x0)) + _, x108 := bits.add_u64(x91, x103, u64(0x0)) + x109, x110 := bits.add_u64(x93, x105, u64(fiat.u1(x108))) + x111, x112 := bits.add_u64(x95, (u64(fiat.u1(x106)) + x102), u64(fiat.u1(x110))) + x113, x114 := bits.add_u64(x97, x99, u64(fiat.u1(x112))) + x115, x116 := bits.add_u64(((u64(fiat.u1(x98)) + u64(fiat.u1(x76))) + (u64(fiat.u1(x90)) + x78)), x100, u64(fiat.u1(x114))) + x118, x117 := bits.mul_u64(x3, 0x4fffffffd) + x120, x119 := bits.mul_u64(x3, 0xfffffffffffffffe) + x122, x121 := bits.mul_u64(x3, 0xfffffffbffffffff) + x124, x123 := bits.mul_u64(x3, 0x3) + x125, x126 := bits.add_u64(x124, x121, u64(0x0)) + x127, x128 := bits.add_u64(x122, x119, u64(fiat.u1(x126))) + x129, x130 := bits.add_u64(x120, x117, u64(fiat.u1(x128))) + x131, x132 := bits.add_u64(x109, x123, u64(0x0)) + x133, x134 := bits.add_u64(x111, x125, u64(fiat.u1(x132))) + x135, x136 := bits.add_u64(x113, x127, u64(fiat.u1(x134))) + x137, x138 := bits.add_u64(x115, x129, u64(fiat.u1(x136))) + x140, x139 := bits.mul_u64(x131, 0xffffffff00000001) + x142, x141 := bits.mul_u64(x131, 0xffffffff) + x144, x143 := bits.mul_u64(x131, 0xffffffffffffffff) + x145, x146 := bits.add_u64(x144, x141, u64(0x0)) + _, x148 := bits.add_u64(x131, x143, u64(0x0)) + x149, x150 := bits.add_u64(x133, x145, u64(fiat.u1(x148))) + x151, x152 := bits.add_u64(x135, (u64(fiat.u1(x146)) + x142), u64(fiat.u1(x150))) + x153, x154 := bits.add_u64(x137, x139, u64(fiat.u1(x152))) + x155, x156 := bits.add_u64(((u64(fiat.u1(x138)) + u64(fiat.u1(x116))) + (u64(fiat.u1(x130)) + x118)), x140, u64(fiat.u1(x154))) + x157, x158 := bits.sub_u64(x149, 0xffffffffffffffff, u64(0x0)) + x159, x160 := bits.sub_u64(x151, 0xffffffff, u64(fiat.u1(x158))) + x161, x162 := bits.sub_u64(x153, u64(0x0), u64(fiat.u1(x160))) + x163, x164 := bits.sub_u64(x155, 0xffffffff00000001, u64(fiat.u1(x162))) + _, x166 := bits.sub_u64(u64(fiat.u1(x156)), u64(0x0), u64(fiat.u1(x164))) + x167 := fiat.cmovznz_u64(fiat.u1(x166), x157, x149) + x168 := fiat.cmovznz_u64(fiat.u1(x166), x159, x151) + x169 := fiat.cmovznz_u64(fiat.u1(x166), x161, x153) + x170 := fiat.cmovznz_u64(fiat.u1(x166), x163, x155) + out1[0] = x167 + out1[1] = x168 + out1[2] = x169 + out1[3] = x170 +} diff --git a/core/crypto/_fiat/field_scalar25519/field.odin b/core/crypto/_fiat/field_scalar25519/field.odin index 933637c54..96b279ce7 100644 --- a/core/crypto/_fiat/field_scalar25519/field.odin +++ b/core/crypto/_fiat/field_scalar25519/field.odin @@ -1,5 +1,6 @@ package field_scalar25519 +import subtle "core:crypto/_subtle" import "core:encoding/endian" import "core:math/bits" import "core:mem" @@ -121,13 +122,11 @@ fe_equal :: proc "contextless" (arg1, arg2: ^Montgomery_Domain_Field_Element) -> tmp: Montgomery_Domain_Field_Element fe_sub(&tmp, arg1, arg2) - // This will only underflow iff arg1 == arg2, and we return the borrow, - // which will be 1. - _, borrow := bits.sub_u64(fe_non_zero(&tmp), 1, 0) + is_eq := subtle.eq(fe_non_zero(&tmp), 0) fe_clear(&tmp) - return int(borrow) + return int(is_eq) } fe_zero :: proc "contextless" (out1: ^Montgomery_Domain_Field_Element) { diff --git a/core/crypto/_fiat/field_scalarp256r1/field.odin b/core/crypto/_fiat/field_scalarp256r1/field.odin new file mode 100644 index 000000000..73c01fb46 --- /dev/null +++ b/core/crypto/_fiat/field_scalarp256r1/field.odin @@ -0,0 +1,210 @@ +package field_scalarp256r1 + +import subtle "core:crypto/_subtle" +import "core:encoding/endian" +import "core:math/bits" +import "core:mem" + +@(private, rodata) +TWO_192 := Montgomery_Domain_Field_Element{ + 2482910415990817935, + 2879494685571067143, + 8732918506673730078, + 85565669603516024, +} +@(private, rodata) +TWO_384 := Montgomery_Domain_Field_Element{ + 2127524300190691059, + 17014302137236182484, + 16604910261202196099, + 3621421107472562910, +} +// 2^384 % p (From sage) +// 0x431905529c0166ce652e96b7ccca0a99679b73e19ad16947f01cf013fc632551 + +fe_clear :: proc "contextless" (arg1: ^Montgomery_Domain_Field_Element) { + mem.zero_explicit(arg1, size_of(Montgomery_Domain_Field_Element)) +} + +fe_clear_vec :: proc "contextless" ( + arg1: []^Montgomery_Domain_Field_Element, +) { + for fe in arg1 { + fe_clear(fe) + } +} + +fe_from_bytes :: proc "contextless" ( + out1: ^Montgomery_Domain_Field_Element, + arg1: []byte, +) -> bool { + ensure_contextless(len(out1) <= 64, "p256r1: invalid scalar input buffer") + + is_canonical := false + s_len := len(arg1) + switch { + case s_len < 32: + // No way this can be greater than the order. + fe_unchecked_set(out1, arg1) + is_canonical = true + case s_len == 32: + // It is quite likely that a reduction mod p is required, + // as the order of the curve is sufficiently smaller than + // 2^256-1, so just check if we actually needed to reduced + // and do the reduction anyway, so that things that require + // canonical scalars can reject non-canonical encodings. + is_canonical = fe_is_canonical(arg1) + fallthrough + case: + // Use Frank Denis' trick, as documented by Filippo Valsorda + // at https://words.filippo.io/dispatches/wide-reduction/ + // + // "I represent the value as a+b*2^192+c*2^384" + // + // Note: Omitting the `c` computation is fine as, reduction + // being length dependent provides no useful timing information. + + // Zero extend to 512-bits. + src_512: [64]byte + copy(src_512[64-s_len:], arg1) + defer mem.zero_explicit(&src_512, size_of(src_512)) + + fe_unchecked_set(out1, src_512[40:]) // a + b: Montgomery_Domain_Field_Element + fe_unchecked_set(&b, src_512[16:40]) // b + + fe_mul(&b, &b, &TWO_192) + fe_add(out1, out1, &b) + if s_len >= 48 { + c: Montgomery_Domain_Field_Element + fe_unchecked_set(&c, src_512[:16]) // c + fe_mul(&c, &c, &TWO_384) + fe_add(out1, out1, &c) + + fe_clear(&c) + } + + fe_clear(&b) + } + + return !is_canonical +} + +@(private) +fe_is_canonical :: proc "contextless" (arg1: []byte) -> bool { + _, borrow := bits.sub_u64(ELL[0] - 1, endian.unchecked_get_u64be(arg1[24:]), 0) + _, borrow = bits.sub_u64(ELL[1], endian.unchecked_get_u64be(arg1[16:]), borrow) + _, borrow = bits.sub_u64(ELL[2], endian.unchecked_get_u64be(arg1[8:]), borrow) + _, borrow = bits.sub_u64(ELL[3], endian.unchecked_get_u64be(arg1[0:]), borrow) + return borrow == 0 +} + +@(private) +fe_unchecked_set :: proc "contextless" (out1: ^Montgomery_Domain_Field_Element, arg1: []byte) { + arg1_256: [32]byte + defer mem.zero_explicit(&arg1_256, size_of(arg1_256)) + copy(arg1_256[32-len(arg1):], arg1) + + tmp := Non_Montgomery_Domain_Field_Element { + endian.unchecked_get_u64be(arg1_256[24:]), + endian.unchecked_get_u64be(arg1_256[16:]), + endian.unchecked_get_u64be(arg1_256[8:]), + endian.unchecked_get_u64be(arg1_256[0:]), + } + defer mem.zero_explicit(&tmp, size_of(tmp)) + + fe_to_montgomery(out1, &tmp) +} + +fe_to_bytes :: proc "contextless" (out1: []byte, arg1: ^Montgomery_Domain_Field_Element) { + ensure_contextless(len(out1) == 32, "p256r1: invalid scalar output buffer") + + tmp: Non_Montgomery_Domain_Field_Element + fe_from_montgomery(&tmp, arg1) + + // Note: Likewise, output in big-endian. + endian.unchecked_put_u64be(out1[24:], tmp[0]) + endian.unchecked_put_u64be(out1[16:], tmp[1]) + endian.unchecked_put_u64be(out1[8:], tmp[2]) + endian.unchecked_put_u64be(out1[0:], tmp[3]) + + mem.zero_explicit(&tmp, size_of(tmp)) +} + +fe_equal :: proc "contextless" (arg1, arg2: ^Montgomery_Domain_Field_Element) -> int { + tmp: Montgomery_Domain_Field_Element + fe_sub(&tmp, arg1, arg2) + + is_eq := subtle.u64_is_zero(fe_non_zero(&tmp)) + + fe_clear(&tmp) + + return int(is_eq) +} + +fe_is_odd :: proc "contextless" (arg1: ^Montgomery_Domain_Field_Element) -> int { + tmp: Non_Montgomery_Domain_Field_Element + defer mem.zero_explicit(&tmp, size_of(tmp)) + + fe_from_montgomery(&tmp, arg1) + return int(tmp[0] & 1) +} + +fe_zero :: proc "contextless" (out1: ^Montgomery_Domain_Field_Element) { + out1[0] = 0 + out1[1] = 0 + out1[2] = 0 + out1[3] = 0 +} + +fe_set :: proc "contextless" (out1, arg1: ^Montgomery_Domain_Field_Element) { + x1 := arg1[0] + x2 := arg1[1] + x3 := arg1[2] + x4 := arg1[3] + out1[0] = x1 + out1[1] = x2 + out1[2] = x3 + out1[3] = x4 +} + +@(optimization_mode = "none") +fe_cond_swap :: #force_no_inline proc "contextless" (out1, out2: ^Montgomery_Domain_Field_Element, arg1: int) { + mask := (u64(arg1) * 0xffffffffffffffff) + x := (out1[0] ~ out2[0]) & mask + x1, y1 := out1[0] ~ x, out2[0] ~ x + x = (out1[1] ~ out2[1]) & mask + x2, y2 := out1[1] ~ x, out2[1] ~ x + x = (out1[2] ~ out2[2]) & mask + x3, y3 := out1[2] ~ x, out2[2] ~ x + x = (out1[3] ~ out2[3]) & mask + x4, y4 := out1[3] ~ x, out2[3] ~ x + out1[0], out2[0] = x1, y1 + out1[1], out2[1] = x2, y2 + out1[2], out2[2] = x3, y3 + out1[3], out2[3] = x4, y4 +} + +@(optimization_mode = "none") +fe_cond_select :: #force_no_inline proc "contextless" ( + out1, arg1, arg2: ^Montgomery_Domain_Field_Element, + arg3: int, +) { + mask := (u64(arg3) * 0xffffffffffffffff) + x1 := ((mask & arg2[0]) | ((~mask) & arg1[0])) + x2 := ((mask & arg2[1]) | ((~mask) & arg1[1])) + x3 := ((mask & arg2[2]) | ((~mask) & arg1[2])) + x4 := ((mask & arg2[3]) | ((~mask) & arg1[3])) + out1[0] = x1 + out1[1] = x2 + out1[2] = x3 + out1[3] = x4 +} + +fe_cond_negate :: proc "contextless" (out1, arg1: ^Montgomery_Domain_Field_Element, ctrl: int) { + tmp1: Montgomery_Domain_Field_Element = --- + fe_opp(&tmp1, arg1) + fe_cond_select(out1, arg1, &tmp1, ctrl) + + fe_clear(&tmp1) +} diff --git a/core/crypto/_fiat/field_scalarp256r1/field64.odin b/core/crypto/_fiat/field_scalarp256r1/field64.odin new file mode 100644 index 000000000..4217374a7 --- /dev/null +++ b/core/crypto/_fiat/field_scalarp256r1/field64.odin @@ -0,0 +1,569 @@ +// The BSD 1-Clause License (BSD-1-Clause) +// +// Copyright (c) 2015-2020 the fiat-crypto authors (see the AUTHORS file) +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// THIS SOFTWARE IS PROVIDED BY the fiat-crypto authors "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, +// Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package field_scalarp256r1 + +// The file provides arithmetic on the field Z/(2^256 - 2^224 + 2^192 - +// 89188191075325690597107910205041859247) using a 64-bit Montgomery form +// internal representation. It is derived primarily from the machine +// generated Golang output from the fiat-crypto project. +// +// While the base implementation is provably correct, this implementation +// makes no such claims as the port and optimizations were done by hand. +// +// WARNING: While big-endian is the common representation used for this +// curve, the fiat output uses least-significant-limb first. + +import fiat "core:crypto/_fiat" +import "core:math/bits" + +// ELL is the saturated representation of the field order, least-significant +// limb first. +ELL :: [4]u64{0xf3b9cac2fc632551, 0xbce6faada7179e84, 0xffffffffffffffff, 0xffffffff00000000} + +Montgomery_Domain_Field_Element :: distinct [4]u64 +Non_Montgomery_Domain_Field_Element :: distinct [4]u64 + +fe_mul :: proc "contextless" (out1, arg1, arg2: ^Montgomery_Domain_Field_Element) { + x1 := arg1[1] + x2 := arg1[2] + x3 := arg1[3] + x4 := arg1[0] + x6, x5 := bits.mul_u64(x4, arg2[3]) + x8, x7 := bits.mul_u64(x4, arg2[2]) + x10, x9 := bits.mul_u64(x4, arg2[1]) + x12, x11 := bits.mul_u64(x4, arg2[0]) + x13, x14 := bits.add_u64(x12, x9, u64(0x0)) + x15, x16 := bits.add_u64(x10, x7, u64(fiat.u1(x14))) + x17, x18 := bits.add_u64(x8, x5, u64(fiat.u1(x16))) + x19 := (u64(fiat.u1(x18)) + x6) + _, x20 := bits.mul_u64(x11, 0xccd1c8aaee00bc4f) + x23, x22 := bits.mul_u64(x20, 0xffffffff00000000) + x25, x24 := bits.mul_u64(x20, 0xffffffffffffffff) + x27, x26 := bits.mul_u64(x20, 0xbce6faada7179e84) + x29, x28 := bits.mul_u64(x20, 0xf3b9cac2fc632551) + x30, x31 := bits.add_u64(x29, x26, u64(0x0)) + x32, x33 := bits.add_u64(x27, x24, u64(fiat.u1(x31))) + x34, x35 := bits.add_u64(x25, x22, u64(fiat.u1(x33))) + x36 := (u64(fiat.u1(x35)) + x23) + _, x38 := bits.add_u64(x11, x28, u64(0x0)) + x39, x40 := bits.add_u64(x13, x30, u64(fiat.u1(x38))) + x41, x42 := bits.add_u64(x15, x32, u64(fiat.u1(x40))) + x43, x44 := bits.add_u64(x17, x34, u64(fiat.u1(x42))) + x45, x46 := bits.add_u64(x19, x36, u64(fiat.u1(x44))) + x48, x47 := bits.mul_u64(x1, arg2[3]) + x50, x49 := bits.mul_u64(x1, arg2[2]) + x52, x51 := bits.mul_u64(x1, arg2[1]) + x54, x53 := bits.mul_u64(x1, arg2[0]) + x55, x56 := bits.add_u64(x54, x51, u64(0x0)) + x57, x58 := bits.add_u64(x52, x49, u64(fiat.u1(x56))) + x59, x60 := bits.add_u64(x50, x47, u64(fiat.u1(x58))) + x61 := (u64(fiat.u1(x60)) + x48) + x62, x63 := bits.add_u64(x39, x53, u64(0x0)) + x64, x65 := bits.add_u64(x41, x55, u64(fiat.u1(x63))) + x66, x67 := bits.add_u64(x43, x57, u64(fiat.u1(x65))) + x68, x69 := bits.add_u64(x45, x59, u64(fiat.u1(x67))) + x70, x71 := bits.add_u64(u64(fiat.u1(x46)), x61, u64(fiat.u1(x69))) + _, x72 := bits.mul_u64(x62, 0xccd1c8aaee00bc4f) + x75, x74 := bits.mul_u64(x72, 0xffffffff00000000) + x77, x76 := bits.mul_u64(x72, 0xffffffffffffffff) + x79, x78 := bits.mul_u64(x72, 0xbce6faada7179e84) + x81, x80 := bits.mul_u64(x72, 0xf3b9cac2fc632551) + x82, x83 := bits.add_u64(x81, x78, u64(0x0)) + x84, x85 := bits.add_u64(x79, x76, u64(fiat.u1(x83))) + x86, x87 := bits.add_u64(x77, x74, u64(fiat.u1(x85))) + x88 := (u64(fiat.u1(x87)) + x75) + _, x90 := bits.add_u64(x62, x80, u64(0x0)) + x91, x92 := bits.add_u64(x64, x82, u64(fiat.u1(x90))) + x93, x94 := bits.add_u64(x66, x84, u64(fiat.u1(x92))) + x95, x96 := bits.add_u64(x68, x86, u64(fiat.u1(x94))) + x97, x98 := bits.add_u64(x70, x88, u64(fiat.u1(x96))) + x99 := (u64(fiat.u1(x98)) + u64(fiat.u1(x71))) + x101, x100 := bits.mul_u64(x2, arg2[3]) + x103, x102 := bits.mul_u64(x2, arg2[2]) + x105, x104 := bits.mul_u64(x2, arg2[1]) + x107, x106 := bits.mul_u64(x2, arg2[0]) + x108, x109 := bits.add_u64(x107, x104, u64(0x0)) + x110, x111 := bits.add_u64(x105, x102, u64(fiat.u1(x109))) + x112, x113 := bits.add_u64(x103, x100, u64(fiat.u1(x111))) + x114 := (u64(fiat.u1(x113)) + x101) + x115, x116 := bits.add_u64(x91, x106, u64(0x0)) + x117, x118 := bits.add_u64(x93, x108, u64(fiat.u1(x116))) + x119, x120 := bits.add_u64(x95, x110, u64(fiat.u1(x118))) + x121, x122 := bits.add_u64(x97, x112, u64(fiat.u1(x120))) + x123, x124 := bits.add_u64(x99, x114, u64(fiat.u1(x122))) + _, x125 := bits.mul_u64(x115, 0xccd1c8aaee00bc4f) + x128, x127 := bits.mul_u64(x125, 0xffffffff00000000) + x130, x129 := bits.mul_u64(x125, 0xffffffffffffffff) + x132, x131 := bits.mul_u64(x125, 0xbce6faada7179e84) + x134, x133 := bits.mul_u64(x125, 0xf3b9cac2fc632551) + x135, x136 := bits.add_u64(x134, x131, u64(0x0)) + x137, x138 := bits.add_u64(x132, x129, u64(fiat.u1(x136))) + x139, x140 := bits.add_u64(x130, x127, u64(fiat.u1(x138))) + x141 := (u64(fiat.u1(x140)) + x128) + _, x143 := bits.add_u64(x115, x133, u64(0x0)) + x144, x145 := bits.add_u64(x117, x135, u64(fiat.u1(x143))) + x146, x147 := bits.add_u64(x119, x137, u64(fiat.u1(x145))) + x148, x149 := bits.add_u64(x121, x139, u64(fiat.u1(x147))) + x150, x151 := bits.add_u64(x123, x141, u64(fiat.u1(x149))) + x152 := (u64(fiat.u1(x151)) + u64(fiat.u1(x124))) + x154, x153 := bits.mul_u64(x3, arg2[3]) + x156, x155 := bits.mul_u64(x3, arg2[2]) + x158, x157 := bits.mul_u64(x3, arg2[1]) + x160, x159 := bits.mul_u64(x3, arg2[0]) + x161, x162 := bits.add_u64(x160, x157, u64(0x0)) + x163, x164 := bits.add_u64(x158, x155, u64(fiat.u1(x162))) + x165, x166 := bits.add_u64(x156, x153, u64(fiat.u1(x164))) + x167 := (u64(fiat.u1(x166)) + x154) + x168, x169 := bits.add_u64(x144, x159, u64(0x0)) + x170, x171 := bits.add_u64(x146, x161, u64(fiat.u1(x169))) + x172, x173 := bits.add_u64(x148, x163, u64(fiat.u1(x171))) + x174, x175 := bits.add_u64(x150, x165, u64(fiat.u1(x173))) + x176, x177 := bits.add_u64(x152, x167, u64(fiat.u1(x175))) + _, x178 := bits.mul_u64(x168, 0xccd1c8aaee00bc4f) + x181, x180 := bits.mul_u64(x178, 0xffffffff00000000) + x183, x182 := bits.mul_u64(x178, 0xffffffffffffffff) + x185, x184 := bits.mul_u64(x178, 0xbce6faada7179e84) + x187, x186 := bits.mul_u64(x178, 0xf3b9cac2fc632551) + x188, x189 := bits.add_u64(x187, x184, u64(0x0)) + x190, x191 := bits.add_u64(x185, x182, u64(fiat.u1(x189))) + x192, x193 := bits.add_u64(x183, x180, u64(fiat.u1(x191))) + x194 := (u64(fiat.u1(x193)) + x181) + _, x196 := bits.add_u64(x168, x186, u64(0x0)) + x197, x198 := bits.add_u64(x170, x188, u64(fiat.u1(x196))) + x199, x200 := bits.add_u64(x172, x190, u64(fiat.u1(x198))) + x201, x202 := bits.add_u64(x174, x192, u64(fiat.u1(x200))) + x203, x204 := bits.add_u64(x176, x194, u64(fiat.u1(x202))) + x205 := (u64(fiat.u1(x204)) + u64(fiat.u1(x177))) + x206, x207 := bits.sub_u64(x197, 0xf3b9cac2fc632551, u64(0x0)) + x208, x209 := bits.sub_u64(x199, 0xbce6faada7179e84, u64(fiat.u1(x207))) + x210, x211 := bits.sub_u64(x201, 0xffffffffffffffff, u64(fiat.u1(x209))) + x212, x213 := bits.sub_u64(x203, 0xffffffff00000000, u64(fiat.u1(x211))) + _, x215 := bits.sub_u64(x205, u64(0x0), u64(fiat.u1(x213))) + x216 := fiat.cmovznz_u64(fiat.u1(x215), x206, x197) + x217 := fiat.cmovznz_u64(fiat.u1(x215), x208, x199) + x218 := fiat.cmovznz_u64(fiat.u1(x215), x210, x201) + x219 := fiat.cmovznz_u64(fiat.u1(x215), x212, x203) + out1[0] = x216 + out1[1] = x217 + out1[2] = x218 + out1[3] = x219 +} + +fe_square :: proc "contextless" (out1, arg1: ^Montgomery_Domain_Field_Element) { + x1 := arg1[1] + x2 := arg1[2] + x3 := arg1[3] + x4 := arg1[0] + x6, x5 := bits.mul_u64(x4, arg1[3]) + x8, x7 := bits.mul_u64(x4, arg1[2]) + x10, x9 := bits.mul_u64(x4, arg1[1]) + x12, x11 := bits.mul_u64(x4, arg1[0]) + x13, x14 := bits.add_u64(x12, x9, u64(0x0)) + x15, x16 := bits.add_u64(x10, x7, u64(fiat.u1(x14))) + x17, x18 := bits.add_u64(x8, x5, u64(fiat.u1(x16))) + x19 := (u64(fiat.u1(x18)) + x6) + _, x20 := bits.mul_u64(x11, 0xccd1c8aaee00bc4f) + x23, x22 := bits.mul_u64(x20, 0xffffffff00000000) + x25, x24 := bits.mul_u64(x20, 0xffffffffffffffff) + x27, x26 := bits.mul_u64(x20, 0xbce6faada7179e84) + x29, x28 := bits.mul_u64(x20, 0xf3b9cac2fc632551) + x30, x31 := bits.add_u64(x29, x26, u64(0x0)) + x32, x33 := bits.add_u64(x27, x24, u64(fiat.u1(x31))) + x34, x35 := bits.add_u64(x25, x22, u64(fiat.u1(x33))) + x36 := (u64(fiat.u1(x35)) + x23) + _, x38 := bits.add_u64(x11, x28, u64(0x0)) + x39, x40 := bits.add_u64(x13, x30, u64(fiat.u1(x38))) + x41, x42 := bits.add_u64(x15, x32, u64(fiat.u1(x40))) + x43, x44 := bits.add_u64(x17, x34, u64(fiat.u1(x42))) + x45, x46 := bits.add_u64(x19, x36, u64(fiat.u1(x44))) + x48, x47 := bits.mul_u64(x1, arg1[3]) + x50, x49 := bits.mul_u64(x1, arg1[2]) + x52, x51 := bits.mul_u64(x1, arg1[1]) + x54, x53 := bits.mul_u64(x1, arg1[0]) + x55, x56 := bits.add_u64(x54, x51, u64(0x0)) + x57, x58 := bits.add_u64(x52, x49, u64(fiat.u1(x56))) + x59, x60 := bits.add_u64(x50, x47, u64(fiat.u1(x58))) + x61 := (u64(fiat.u1(x60)) + x48) + x62, x63 := bits.add_u64(x39, x53, u64(0x0)) + x64, x65 := bits.add_u64(x41, x55, u64(fiat.u1(x63))) + x66, x67 := bits.add_u64(x43, x57, u64(fiat.u1(x65))) + x68, x69 := bits.add_u64(x45, x59, u64(fiat.u1(x67))) + x70, x71 := bits.add_u64(u64(fiat.u1(x46)), x61, u64(fiat.u1(x69))) + _, x72 := bits.mul_u64(x62, 0xccd1c8aaee00bc4f) + x75, x74 := bits.mul_u64(x72, 0xffffffff00000000) + x77, x76 := bits.mul_u64(x72, 0xffffffffffffffff) + x79, x78 := bits.mul_u64(x72, 0xbce6faada7179e84) + x81, x80 := bits.mul_u64(x72, 0xf3b9cac2fc632551) + x82, x83 := bits.add_u64(x81, x78, u64(0x0)) + x84, x85 := bits.add_u64(x79, x76, u64(fiat.u1(x83))) + x86, x87 := bits.add_u64(x77, x74, u64(fiat.u1(x85))) + x88 := (u64(fiat.u1(x87)) + x75) + _, x90 := bits.add_u64(x62, x80, u64(0x0)) + x91, x92 := bits.add_u64(x64, x82, u64(fiat.u1(x90))) + x93, x94 := bits.add_u64(x66, x84, u64(fiat.u1(x92))) + x95, x96 := bits.add_u64(x68, x86, u64(fiat.u1(x94))) + x97, x98 := bits.add_u64(x70, x88, u64(fiat.u1(x96))) + x99 := (u64(fiat.u1(x98)) + u64(fiat.u1(x71))) + x101, x100 := bits.mul_u64(x2, arg1[3]) + x103, x102 := bits.mul_u64(x2, arg1[2]) + x105, x104 := bits.mul_u64(x2, arg1[1]) + x107, x106 := bits.mul_u64(x2, arg1[0]) + x108, x109 := bits.add_u64(x107, x104, u64(0x0)) + x110, x111 := bits.add_u64(x105, x102, u64(fiat.u1(x109))) + x112, x113 := bits.add_u64(x103, x100, u64(fiat.u1(x111))) + x114 := (u64(fiat.u1(x113)) + x101) + x115, x116 := bits.add_u64(x91, x106, u64(0x0)) + x117, x118 := bits.add_u64(x93, x108, u64(fiat.u1(x116))) + x119, x120 := bits.add_u64(x95, x110, u64(fiat.u1(x118))) + x121, x122 := bits.add_u64(x97, x112, u64(fiat.u1(x120))) + x123, x124 := bits.add_u64(x99, x114, u64(fiat.u1(x122))) + _, x125 := bits.mul_u64(x115, 0xccd1c8aaee00bc4f) + x128, x127 := bits.mul_u64(x125, 0xffffffff00000000) + x130, x129 := bits.mul_u64(x125, 0xffffffffffffffff) + x132, x131 := bits.mul_u64(x125, 0xbce6faada7179e84) + x134, x133 := bits.mul_u64(x125, 0xf3b9cac2fc632551) + x135, x136 := bits.add_u64(x134, x131, u64(0x0)) + x137, x138 := bits.add_u64(x132, x129, u64(fiat.u1(x136))) + x139, x140 := bits.add_u64(x130, x127, u64(fiat.u1(x138))) + x141 := (u64(fiat.u1(x140)) + x128) + _, x143 := bits.add_u64(x115, x133, u64(0x0)) + x144, x145 := bits.add_u64(x117, x135, u64(fiat.u1(x143))) + x146, x147 := bits.add_u64(x119, x137, u64(fiat.u1(x145))) + x148, x149 := bits.add_u64(x121, x139, u64(fiat.u1(x147))) + x150, x151 := bits.add_u64(x123, x141, u64(fiat.u1(x149))) + x152 := (u64(fiat.u1(x151)) + u64(fiat.u1(x124))) + x154, x153 := bits.mul_u64(x3, arg1[3]) + x156, x155 := bits.mul_u64(x3, arg1[2]) + x158, x157 := bits.mul_u64(x3, arg1[1]) + x160, x159 := bits.mul_u64(x3, arg1[0]) + x161, x162 := bits.add_u64(x160, x157, u64(0x0)) + x163, x164 := bits.add_u64(x158, x155, u64(fiat.u1(x162))) + x165, x166 := bits.add_u64(x156, x153, u64(fiat.u1(x164))) + x167 := (u64(fiat.u1(x166)) + x154) + x168, x169 := bits.add_u64(x144, x159, u64(0x0)) + x170, x171 := bits.add_u64(x146, x161, u64(fiat.u1(x169))) + x172, x173 := bits.add_u64(x148, x163, u64(fiat.u1(x171))) + x174, x175 := bits.add_u64(x150, x165, u64(fiat.u1(x173))) + x176, x177 := bits.add_u64(x152, x167, u64(fiat.u1(x175))) + _, x178 := bits.mul_u64(x168, 0xccd1c8aaee00bc4f) + x181, x180 := bits.mul_u64(x178, 0xffffffff00000000) + x183, x182 := bits.mul_u64(x178, 0xffffffffffffffff) + x185, x184 := bits.mul_u64(x178, 0xbce6faada7179e84) + x187, x186 := bits.mul_u64(x178, 0xf3b9cac2fc632551) + x188, x189 := bits.add_u64(x187, x184, u64(0x0)) + x190, x191 := bits.add_u64(x185, x182, u64(fiat.u1(x189))) + x192, x193 := bits.add_u64(x183, x180, u64(fiat.u1(x191))) + x194 := (u64(fiat.u1(x193)) + x181) + _, x196 := bits.add_u64(x168, x186, u64(0x0)) + x197, x198 := bits.add_u64(x170, x188, u64(fiat.u1(x196))) + x199, x200 := bits.add_u64(x172, x190, u64(fiat.u1(x198))) + x201, x202 := bits.add_u64(x174, x192, u64(fiat.u1(x200))) + x203, x204 := bits.add_u64(x176, x194, u64(fiat.u1(x202))) + x205 := (u64(fiat.u1(x204)) + u64(fiat.u1(x177))) + x206, x207 := bits.sub_u64(x197, 0xf3b9cac2fc632551, u64(0x0)) + x208, x209 := bits.sub_u64(x199, 0xbce6faada7179e84, u64(fiat.u1(x207))) + x210, x211 := bits.sub_u64(x201, 0xffffffffffffffff, u64(fiat.u1(x209))) + x212, x213 := bits.sub_u64(x203, 0xffffffff00000000, u64(fiat.u1(x211))) + _, x215 := bits.sub_u64(x205, u64(0x0), u64(fiat.u1(x213))) + x216 := fiat.cmovznz_u64(fiat.u1(x215), x206, x197) + x217 := fiat.cmovznz_u64(fiat.u1(x215), x208, x199) + x218 := fiat.cmovznz_u64(fiat.u1(x215), x210, x201) + x219 := fiat.cmovznz_u64(fiat.u1(x215), x212, x203) + out1[0] = x216 + out1[1] = x217 + out1[2] = x218 + out1[3] = x219 +} + +fe_add :: proc "contextless" (out1, arg1, arg2: ^Montgomery_Domain_Field_Element) { + x1, x2 := bits.add_u64(arg1[0], arg2[0], u64(0x0)) + x3, x4 := bits.add_u64(arg1[1], arg2[1], u64(fiat.u1(x2))) + x5, x6 := bits.add_u64(arg1[2], arg2[2], u64(fiat.u1(x4))) + x7, x8 := bits.add_u64(arg1[3], arg2[3], u64(fiat.u1(x6))) + x9, x10 := bits.sub_u64(x1, 0xf3b9cac2fc632551, u64(0x0)) + x11, x12 := bits.sub_u64(x3, 0xbce6faada7179e84, u64(fiat.u1(x10))) + x13, x14 := bits.sub_u64(x5, 0xffffffffffffffff, u64(fiat.u1(x12))) + x15, x16 := bits.sub_u64(x7, 0xffffffff00000000, u64(fiat.u1(x14))) + _, x18 := bits.sub_u64(u64(fiat.u1(x8)), u64(0x0), u64(fiat.u1(x16))) + x19 := fiat.cmovznz_u64(fiat.u1(x18), x9, x1) + x20 := fiat.cmovznz_u64(fiat.u1(x18), x11, x3) + x21 := fiat.cmovznz_u64(fiat.u1(x18), x13, x5) + x22 := fiat.cmovznz_u64(fiat.u1(x18), x15, x7) + out1[0] = x19 + out1[1] = x20 + out1[2] = x21 + out1[3] = x22 +} + +fe_sub :: proc "contextless" (out1, arg1, arg2: ^Montgomery_Domain_Field_Element) { + x1, x2 := bits.sub_u64(arg1[0], arg2[0], u64(0x0)) + x3, x4 := bits.sub_u64(arg1[1], arg2[1], u64(fiat.u1(x2))) + x5, x6 := bits.sub_u64(arg1[2], arg2[2], u64(fiat.u1(x4))) + x7, x8 := bits.sub_u64(arg1[3], arg2[3], u64(fiat.u1(x6))) + x9 := fiat.cmovznz_u64(fiat.u1(x8), u64(0x0), 0xffffffffffffffff) + x10, x11 := bits.add_u64(x1, (x9 & 0xf3b9cac2fc632551), u64(0x0)) + x12, x13 := bits.add_u64(x3, (x9 & 0xbce6faada7179e84), u64(fiat.u1(x11))) + x14, x15 := bits.add_u64(x5, x9, u64(fiat.u1(x13))) + x16, _ := bits.add_u64(x7, (x9 & 0xffffffff00000000), u64(fiat.u1(x15))) + out1[0] = x10 + out1[1] = x12 + out1[2] = x14 + out1[3] = x16 +} + +fe_opp :: proc "contextless" (out1, arg1: ^Montgomery_Domain_Field_Element) { + x1, x2 := bits.sub_u64(u64(0x0), arg1[0], u64(0x0)) + x3, x4 := bits.sub_u64(u64(0x0), arg1[1], u64(fiat.u1(x2))) + x5, x6 := bits.sub_u64(u64(0x0), arg1[2], u64(fiat.u1(x4))) + x7, x8 := bits.sub_u64(u64(0x0), arg1[3], u64(fiat.u1(x6))) + x9 := fiat.cmovznz_u64(fiat.u1(x8), u64(0x0), 0xffffffffffffffff) + x10, x11 := bits.add_u64(x1, (x9 & 0xf3b9cac2fc632551), u64(0x0)) + x12, x13 := bits.add_u64(x3, (x9 & 0xbce6faada7179e84), u64(fiat.u1(x11))) + x14, x15 := bits.add_u64(x5, x9, u64(fiat.u1(x13))) + x16, _ := bits.add_u64(x7, (x9 & 0xffffffff00000000), u64(fiat.u1(x15))) + out1[0] = x10 + out1[1] = x12 + out1[2] = x14 + out1[3] = x16 +} + +fe_one :: proc "contextless" (out1: ^Montgomery_Domain_Field_Element) { + out1[0] = 0xc46353d039cdaaf + out1[1] = 0x4319055258e8617b + out1[2] = u64(0x0) + out1[3] = 0xffffffff +} + +fe_non_zero :: proc "contextless" (arg1: ^Montgomery_Domain_Field_Element) -> u64 { + return arg1[0] | (arg1[1] | (arg1[2] | arg1[3])) +} + +@(optimization_mode = "none") +fe_cond_assign :: #force_no_inline proc "contextless" ( + out1, arg1: ^Montgomery_Domain_Field_Element, + arg2: int, +) { + x1 := fiat.cmovznz_u64(fiat.u1(arg2), out1[0], arg1[0]) + x2 := fiat.cmovznz_u64(fiat.u1(arg2), out1[1], arg1[1]) + x3 := fiat.cmovznz_u64(fiat.u1(arg2), out1[2], arg1[2]) + x4 := fiat.cmovznz_u64(fiat.u1(arg2), out1[3], arg1[3]) + out1[0] = x1 + out1[1] = x2 + out1[2] = x3 + out1[3] = x4 +} + +fe_from_montgomery :: proc "contextless" ( + out1: ^Non_Montgomery_Domain_Field_Element, + arg1: ^Montgomery_Domain_Field_Element, +) { + x1 := arg1[0] + _, x2 := bits.mul_u64(x1, 0xccd1c8aaee00bc4f) + x5, x4 := bits.mul_u64(x2, 0xffffffff00000000) + x7, x6 := bits.mul_u64(x2, 0xffffffffffffffff) + x9, x8 := bits.mul_u64(x2, 0xbce6faada7179e84) + x11, x10 := bits.mul_u64(x2, 0xf3b9cac2fc632551) + x12, x13 := bits.add_u64(x11, x8, u64(0x0)) + x14, x15 := bits.add_u64(x9, x6, u64(fiat.u1(x13))) + x16, x17 := bits.add_u64(x7, x4, u64(fiat.u1(x15))) + _, x19 := bits.add_u64(x1, x10, u64(0x0)) + x20, x21 := bits.add_u64(u64(0x0), x12, u64(fiat.u1(x19))) + x22, x23 := bits.add_u64(u64(0x0), x14, u64(fiat.u1(x21))) + x24, x25 := bits.add_u64(u64(0x0), x16, u64(fiat.u1(x23))) + x26, x27 := bits.add_u64(x20, arg1[1], u64(0x0)) + x28, x29 := bits.add_u64(x22, u64(0x0), u64(fiat.u1(x27))) + x30, x31 := bits.add_u64(x24, u64(0x0), u64(fiat.u1(x29))) + _, x32 := bits.mul_u64(x26, 0xccd1c8aaee00bc4f) + x35, x34 := bits.mul_u64(x32, 0xffffffff00000000) + x37, x36 := bits.mul_u64(x32, 0xffffffffffffffff) + x39, x38 := bits.mul_u64(x32, 0xbce6faada7179e84) + x41, x40 := bits.mul_u64(x32, 0xf3b9cac2fc632551) + x42, x43 := bits.add_u64(x41, x38, u64(0x0)) + x44, x45 := bits.add_u64(x39, x36, u64(fiat.u1(x43))) + x46, x47 := bits.add_u64(x37, x34, u64(fiat.u1(x45))) + _, x49 := bits.add_u64(x26, x40, u64(0x0)) + x50, x51 := bits.add_u64(x28, x42, u64(fiat.u1(x49))) + x52, x53 := bits.add_u64(x30, x44, u64(fiat.u1(x51))) + x54, x55 := bits.add_u64((u64(fiat.u1(x31)) + (u64(fiat.u1(x25)) + (u64(fiat.u1(x17)) + x5))), x46, u64(fiat.u1(x53))) + x56, x57 := bits.add_u64(x50, arg1[2], u64(0x0)) + x58, x59 := bits.add_u64(x52, u64(0x0), u64(fiat.u1(x57))) + x60, x61 := bits.add_u64(x54, u64(0x0), u64(fiat.u1(x59))) + _, x62 := bits.mul_u64(x56, 0xccd1c8aaee00bc4f) + x65, x64 := bits.mul_u64(x62, 0xffffffff00000000) + x67, x66 := bits.mul_u64(x62, 0xffffffffffffffff) + x69, x68 := bits.mul_u64(x62, 0xbce6faada7179e84) + x71, x70 := bits.mul_u64(x62, 0xf3b9cac2fc632551) + x72, x73 := bits.add_u64(x71, x68, u64(0x0)) + x74, x75 := bits.add_u64(x69, x66, u64(fiat.u1(x73))) + x76, x77 := bits.add_u64(x67, x64, u64(fiat.u1(x75))) + _, x79 := bits.add_u64(x56, x70, u64(0x0)) + x80, x81 := bits.add_u64(x58, x72, u64(fiat.u1(x79))) + x82, x83 := bits.add_u64(x60, x74, u64(fiat.u1(x81))) + x84, x85 := bits.add_u64((u64(fiat.u1(x61)) + (u64(fiat.u1(x55)) + (u64(fiat.u1(x47)) + x35))), x76, u64(fiat.u1(x83))) + x86, x87 := bits.add_u64(x80, arg1[3], u64(0x0)) + x88, x89 := bits.add_u64(x82, u64(0x0), u64(fiat.u1(x87))) + x90, x91 := bits.add_u64(x84, u64(0x0), u64(fiat.u1(x89))) + _, x92 := bits.mul_u64(x86, 0xccd1c8aaee00bc4f) + x95, x94 := bits.mul_u64(x92, 0xffffffff00000000) + x97, x96 := bits.mul_u64(x92, 0xffffffffffffffff) + x99, x98 := bits.mul_u64(x92, 0xbce6faada7179e84) + x101, x100 := bits.mul_u64(x92, 0xf3b9cac2fc632551) + x102, x103 := bits.add_u64(x101, x98, u64(0x0)) + x104, x105 := bits.add_u64(x99, x96, u64(fiat.u1(x103))) + x106, x107 := bits.add_u64(x97, x94, u64(fiat.u1(x105))) + _, x109 := bits.add_u64(x86, x100, u64(0x0)) + x110, x111 := bits.add_u64(x88, x102, u64(fiat.u1(x109))) + x112, x113 := bits.add_u64(x90, x104, u64(fiat.u1(x111))) + x114, x115 := bits.add_u64((u64(fiat.u1(x91)) + (u64(fiat.u1(x85)) + (u64(fiat.u1(x77)) + x65))), x106, u64(fiat.u1(x113))) + x116 := (u64(fiat.u1(x115)) + (u64(fiat.u1(x107)) + x95)) + x117, x118 := bits.sub_u64(x110, 0xf3b9cac2fc632551, u64(0x0)) + x119, x120 := bits.sub_u64(x112, 0xbce6faada7179e84, u64(fiat.u1(x118))) + x121, x122 := bits.sub_u64(x114, 0xffffffffffffffff, u64(fiat.u1(x120))) + x123, x124 := bits.sub_u64(x116, 0xffffffff00000000, u64(fiat.u1(x122))) + _, x126 := bits.sub_u64(u64(0x0), u64(0x0), u64(fiat.u1(x124))) + x127 := fiat.cmovznz_u64(fiat.u1(x126), x117, x110) + x128 := fiat.cmovznz_u64(fiat.u1(x126), x119, x112) + x129 := fiat.cmovznz_u64(fiat.u1(x126), x121, x114) + x130 := fiat.cmovznz_u64(fiat.u1(x126), x123, x116) + out1[0] = x127 + out1[1] = x128 + out1[2] = x129 + out1[3] = x130 +} + +fe_to_montgomery :: proc "contextless" ( + out1: ^Montgomery_Domain_Field_Element, + arg1: ^Non_Montgomery_Domain_Field_Element, +) { + x1 := arg1[1] + x2 := arg1[2] + x3 := arg1[3] + x4 := arg1[0] + x6, x5 := bits.mul_u64(x4, 0x66e12d94f3d95620) + x8, x7 := bits.mul_u64(x4, 0x2845b2392b6bec59) + x10, x9 := bits.mul_u64(x4, 0x4699799c49bd6fa6) + x12, x11 := bits.mul_u64(x4, 0x83244c95be79eea2) + x13, x14 := bits.add_u64(x12, x9, u64(0x0)) + x15, x16 := bits.add_u64(x10, x7, u64(fiat.u1(x14))) + x17, x18 := bits.add_u64(x8, x5, u64(fiat.u1(x16))) + _, x19 := bits.mul_u64(x11, 0xccd1c8aaee00bc4f) + x22, x21 := bits.mul_u64(x19, 0xffffffff00000000) + x24, x23 := bits.mul_u64(x19, 0xffffffffffffffff) + x26, x25 := bits.mul_u64(x19, 0xbce6faada7179e84) + x28, x27 := bits.mul_u64(x19, 0xf3b9cac2fc632551) + x29, x30 := bits.add_u64(x28, x25, u64(0x0)) + x31, x32 := bits.add_u64(x26, x23, u64(fiat.u1(x30))) + x33, x34 := bits.add_u64(x24, x21, u64(fiat.u1(x32))) + _, x36 := bits.add_u64(x11, x27, u64(0x0)) + x37, x38 := bits.add_u64(x13, x29, u64(fiat.u1(x36))) + x39, x40 := bits.add_u64(x15, x31, u64(fiat.u1(x38))) + x41, x42 := bits.add_u64(x17, x33, u64(fiat.u1(x40))) + x43, x44 := bits.add_u64((u64(fiat.u1(x18)) + x6), (u64(fiat.u1(x34)) + x22), u64(fiat.u1(x42))) + x46, x45 := bits.mul_u64(x1, 0x66e12d94f3d95620) + x48, x47 := bits.mul_u64(x1, 0x2845b2392b6bec59) + x50, x49 := bits.mul_u64(x1, 0x4699799c49bd6fa6) + x52, x51 := bits.mul_u64(x1, 0x83244c95be79eea2) + x53, x54 := bits.add_u64(x52, x49, u64(0x0)) + x55, x56 := bits.add_u64(x50, x47, u64(fiat.u1(x54))) + x57, x58 := bits.add_u64(x48, x45, u64(fiat.u1(x56))) + x59, x60 := bits.add_u64(x37, x51, u64(0x0)) + x61, x62 := bits.add_u64(x39, x53, u64(fiat.u1(x60))) + x63, x64 := bits.add_u64(x41, x55, u64(fiat.u1(x62))) + x65, x66 := bits.add_u64(x43, x57, u64(fiat.u1(x64))) + _, x67 := bits.mul_u64(x59, 0xccd1c8aaee00bc4f) + x70, x69 := bits.mul_u64(x67, 0xffffffff00000000) + x72, x71 := bits.mul_u64(x67, 0xffffffffffffffff) + x74, x73 := bits.mul_u64(x67, 0xbce6faada7179e84) + x76, x75 := bits.mul_u64(x67, 0xf3b9cac2fc632551) + x77, x78 := bits.add_u64(x76, x73, u64(0x0)) + x79, x80 := bits.add_u64(x74, x71, u64(fiat.u1(x78))) + x81, x82 := bits.add_u64(x72, x69, u64(fiat.u1(x80))) + _, x84 := bits.add_u64(x59, x75, u64(0x0)) + x85, x86 := bits.add_u64(x61, x77, u64(fiat.u1(x84))) + x87, x88 := bits.add_u64(x63, x79, u64(fiat.u1(x86))) + x89, x90 := bits.add_u64(x65, x81, u64(fiat.u1(x88))) + x91, x92 := bits.add_u64(((u64(fiat.u1(x66)) + u64(fiat.u1(x44))) + (u64(fiat.u1(x58)) + x46)), (u64(fiat.u1(x82)) + x70), u64(fiat.u1(x90))) + x94, x93 := bits.mul_u64(x2, 0x66e12d94f3d95620) + x96, x95 := bits.mul_u64(x2, 0x2845b2392b6bec59) + x98, x97 := bits.mul_u64(x2, 0x4699799c49bd6fa6) + x100, x99 := bits.mul_u64(x2, 0x83244c95be79eea2) + x101, x102 := bits.add_u64(x100, x97, u64(0x0)) + x103, x104 := bits.add_u64(x98, x95, u64(fiat.u1(x102))) + x105, x106 := bits.add_u64(x96, x93, u64(fiat.u1(x104))) + x107, x108 := bits.add_u64(x85, x99, u64(0x0)) + x109, x110 := bits.add_u64(x87, x101, u64(fiat.u1(x108))) + x111, x112 := bits.add_u64(x89, x103, u64(fiat.u1(x110))) + x113, x114 := bits.add_u64(x91, x105, u64(fiat.u1(x112))) + _, x115 := bits.mul_u64(x107, 0xccd1c8aaee00bc4f) + x118, x117 := bits.mul_u64(x115, 0xffffffff00000000) + x120, x119 := bits.mul_u64(x115, 0xffffffffffffffff) + x122, x121 := bits.mul_u64(x115, 0xbce6faada7179e84) + x124, x123 := bits.mul_u64(x115, 0xf3b9cac2fc632551) + x125, x126 := bits.add_u64(x124, x121, u64(0x0)) + x127, x128 := bits.add_u64(x122, x119, u64(fiat.u1(x126))) + x129, x130 := bits.add_u64(x120, x117, u64(fiat.u1(x128))) + _, x132 := bits.add_u64(x107, x123, u64(0x0)) + x133, x134 := bits.add_u64(x109, x125, u64(fiat.u1(x132))) + x135, x136 := bits.add_u64(x111, x127, u64(fiat.u1(x134))) + x137, x138 := bits.add_u64(x113, x129, u64(fiat.u1(x136))) + x139, x140 := bits.add_u64(((u64(fiat.u1(x114)) + u64(fiat.u1(x92))) + (u64(fiat.u1(x106)) + x94)), (u64(fiat.u1(x130)) + x118), u64(fiat.u1(x138))) + x142, x141 := bits.mul_u64(x3, 0x66e12d94f3d95620) + x144, x143 := bits.mul_u64(x3, 0x2845b2392b6bec59) + x146, x145 := bits.mul_u64(x3, 0x4699799c49bd6fa6) + x148, x147 := bits.mul_u64(x3, 0x83244c95be79eea2) + x149, x150 := bits.add_u64(x148, x145, u64(0x0)) + x151, x152 := bits.add_u64(x146, x143, u64(fiat.u1(x150))) + x153, x154 := bits.add_u64(x144, x141, u64(fiat.u1(x152))) + x155, x156 := bits.add_u64(x133, x147, u64(0x0)) + x157, x158 := bits.add_u64(x135, x149, u64(fiat.u1(x156))) + x159, x160 := bits.add_u64(x137, x151, u64(fiat.u1(x158))) + x161, x162 := bits.add_u64(x139, x153, u64(fiat.u1(x160))) + _, x163 := bits.mul_u64(x155, 0xccd1c8aaee00bc4f) + x166, x165 := bits.mul_u64(x163, 0xffffffff00000000) + x168, x167 := bits.mul_u64(x163, 0xffffffffffffffff) + x170, x169 := bits.mul_u64(x163, 0xbce6faada7179e84) + x172, x171 := bits.mul_u64(x163, 0xf3b9cac2fc632551) + x173, x174 := bits.add_u64(x172, x169, u64(0x0)) + x175, x176 := bits.add_u64(x170, x167, u64(fiat.u1(x174))) + x177, x178 := bits.add_u64(x168, x165, u64(fiat.u1(x176))) + _, x180 := bits.add_u64(x155, x171, u64(0x0)) + x181, x182 := bits.add_u64(x157, x173, u64(fiat.u1(x180))) + x183, x184 := bits.add_u64(x159, x175, u64(fiat.u1(x182))) + x185, x186 := bits.add_u64(x161, x177, u64(fiat.u1(x184))) + x187, x188 := bits.add_u64(((u64(fiat.u1(x162)) + u64(fiat.u1(x140))) + (u64(fiat.u1(x154)) + x142)), (u64(fiat.u1(x178)) + x166), u64(fiat.u1(x186))) + x189, x190 := bits.sub_u64(x181, 0xf3b9cac2fc632551, u64(0x0)) + x191, x192 := bits.sub_u64(x183, 0xbce6faada7179e84, u64(fiat.u1(x190))) + x193, x194 := bits.sub_u64(x185, 0xffffffffffffffff, u64(fiat.u1(x192))) + x195, x196 := bits.sub_u64(x187, 0xffffffff00000000, u64(fiat.u1(x194))) + _, x198 := bits.sub_u64(u64(fiat.u1(x188)), u64(0x0), u64(fiat.u1(x196))) + x199 := fiat.cmovznz_u64(fiat.u1(x198), x189, x181) + x200 := fiat.cmovznz_u64(fiat.u1(x198), x191, x183) + x201 := fiat.cmovznz_u64(fiat.u1(x198), x193, x185) + x202 := fiat.cmovznz_u64(fiat.u1(x198), x195, x187) + out1[0] = x199 + out1[1] = x200 + out1[2] = x201 + out1[3] = x202 +} diff --git a/core/crypto/_subtle/subtle.odin b/core/crypto/_subtle/subtle.odin new file mode 100644 index 000000000..89328072c --- /dev/null +++ b/core/crypto/_subtle/subtle.odin @@ -0,0 +1,42 @@ +/* +Various useful bit operations in constant time. +*/ +package _subtle + +import "core:math/bits" + +// byte_eq returns 1 iff a == b, 0 otherwise. +@(optimization_mode="none") +byte_eq :: proc "contextless" (a, b: byte) -> int { + v := a ~ b + + // v == 0 iff a == b. The subtraction will underflow, setting the + // sign bit, which will get returned. + return int((u32(v)-1) >> 31) +} + +// u64_eq returns 1 iff a == b, 0 otherwise. +@(optimization_mode="none") +u64_eq :: proc "contextless" (a, b: u64) -> u64 { + _, borrow := bits.sub_u64(0, a ~ b, 0) + return (~borrow) & 1 +} + +eq :: proc { + byte_eq, + u64_eq, +} + +// u64_is_zero returns 1 iff a == 0, 0 otherwise. +@(optimization_mode="none") +u64_is_zero :: proc "contextless" (a: u64) -> u64 { + _, borrow := bits.sub_u64(a, 1, 0) + return borrow +} + +// u64_is_non_zero returns 1 iff a != 0, 0 otherwise. +@(optimization_mode="none") +u64_is_non_zero :: proc "contextless" (a: u64) -> u64 { + is_zero := u64_is_zero(a) + return (~is_zero) & 1 +} diff --git a/core/crypto/_weierstrass/fe.odin b/core/crypto/_weierstrass/fe.odin new file mode 100644 index 000000000..1a160a03c --- /dev/null +++ b/core/crypto/_weierstrass/fe.odin @@ -0,0 +1,135 @@ +package _weierstrass + +import p256r1 "core:crypto/_fiat/field_p256r1" +import "core:math/bits" + +Field_Element_p256r1 :: p256r1.Montgomery_Domain_Field_Element + +FE_SIZE_P256R1 :: 32 + +fe_clear :: proc { + p256r1.fe_clear, +} + +fe_clear_vec :: proc { + p256r1.fe_clear_vec, +} + +fe_set_bytes :: proc { + p256r1.fe_from_bytes, +} +fe_bytes :: proc { + p256r1.fe_to_bytes, +} + +fe_set :: proc { + p256r1.fe_set, +} + +fe_zero :: proc { + p256r1.fe_zero, +} + +fe_a :: proc { + fe_a_p256r1, +} + +fe_b :: proc { + fe_b_p256r1, +} + +fe_gen_x :: proc { + fe_gen_x_p256r1, +} + +fe_gen_y :: proc { + fe_gen_y_p256r1, +} + +fe_one :: proc { + p256r1.fe_one, +} + +fe_add :: proc { + p256r1.fe_add, +} + +fe_sub :: proc { + p256r1.fe_sub, +} + +fe_negate :: proc { + p256r1.fe_opp, +} + +fe_mul :: proc { + p256r1.fe_mul, +} + +fe_square :: proc { + p256r1.fe_square, +} + +fe_inv :: proc { + p256r1.fe_inv, +} + +fe_sqrt :: proc { + p256r1.fe_sqrt, +} + +fe_equal :: proc { + p256r1.fe_equal, +} + +fe_is_odd :: proc { + p256r1.fe_is_odd, +} + +fe_is_zero :: proc { + fe_is_zero_p256r1, +} + +fe_cond_select :: proc { + p256r1.fe_cond_select, +} + +fe_a_p256r1 :: proc "contextless" (fe: ^Field_Element_p256r1) { + // a = 0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc + // = -3 mod p + fe[0] = 18446744073709551612 + fe[1] = 17179869183 + fe[2] = 0 + fe[3] = 18446744056529682436 +} + +fe_b_p256r1 :: proc "contextless" (fe: ^Field_Element_p256r1) { + // b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b + fe[0] = 15608596021259845087 + fe[1] = 12461466548982526096 + fe[2] = 16546823903870267094 + fe[3] = 15866188208926050356 +} + +fe_gen_x_p256r1 :: proc "contextless" (fe: ^Field_Element_p256r1) { + // G_x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296 + fe[0] = 8784043285714375740 + fe[1] = 8483257759279461889 + fe[2] = 8789745728267363600 + fe[3] = 1770019616739251654 +} + +fe_gen_y_p256r1 :: proc "contextless" (fe: ^Field_Element_p256r1) { + // G_y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5 + fe[0] = 15992936863339206154 + fe[1] = 10037038012062884956 + fe[2] = 15197544864945402661 + fe[3] = 9615747158586711429 +} + +@(require_results) +fe_is_zero_p256r1 :: proc "contextless" (fe: ^Field_Element_p256r1) -> int { + ctrl := p256r1.fe_non_zero(fe) + _, borrow := bits.sub_u64(ctrl, 1, 0) + return int(borrow) +} diff --git a/core/crypto/_weierstrass/point.odin b/core/crypto/_weierstrass/point.odin new file mode 100644 index 000000000..cde82ebb2 --- /dev/null +++ b/core/crypto/_weierstrass/point.odin @@ -0,0 +1,548 @@ +package _weierstrass + +/* +This implements prime order short Weierstrass curves defined over a field +k with char(k) != 2, 3 (`y^2 = x^3 + ax + b`). for the purpose of +implementing ECDH and ECDSA. Use of this package for other purposes is +NOT RECOMMENDED. + +As an explicit simplicity/performance tradeoff, projective representation +was chosen so that it is possible to use the complete addition +formulas. + +See: +- https://eprint.iacr.org/2015/1060.pdf +- https://hyperelliptic.org/EFD/g1p/auto-shortw-projective.html + +WARNING: The point addition and doubling formulas are specialized for +`a = -3`, which covers secp256r1, secp384r1, secp521r1, FRP256v1, SM2, +and GOST 34.10. The brainpool curves and secp256k1 are NOT SUPPORTED +and would require slightly different formulas. +*/ + +Point_p256r1 :: struct { + x: Field_Element_p256r1, + y: Field_Element_p256r1, + z: Field_Element_p256r1, +} + +@(require_results) +pt_set_xy_bytes :: proc "contextless" (p: ^$T, x_raw, y_raw: []byte) -> bool { + when T == Point_p256r1 { + FE_SZ :: FE_SIZE_P256R1 + x, y: Field_Element_p256r1 + defer fe_clear_vec([]^Field_Element_p256r1{&x, &y}) + } else { + #panic("weierstrass: invalid curve") + } + + if len(x_raw) != FE_SZ || len(y_raw) != FE_SZ { + return false + } + + if !fe_set_bytes(&x, x_raw) { + return false + } + if !fe_set_bytes(&y, y_raw) { + return false + } + if !is_on_curve(&x, &y) { + return false + } + + fe_set(&p.x, &x) + fe_set(&p.y, &y) + fe_one(&p.z) + + return true +} + +@(require_results) +pt_set_x_bytes :: proc "contextless" (p: ^$T, x_raw: []byte, y_is_odd: int) -> bool { + when T == Point_p256r1 { + FE_SZ :: FE_SIZE_P256R1 + x, y, yy, y_neg: Field_Element_p256r1 + defer fe_clear_vec([]^Field_Element_p256r1{&x, &y, &yy, &y_neg}) + } else { + #panic("weierstrass: invalid curve") + } + + if len(x_raw) != FE_SZ { + return false + } + + if !fe_set_bytes(&x, x_raw) { + return false + } + set_yy_candidate(&yy, &x) + if fe_sqrt(&y, &yy) != 1 { + return false + } + + // Pick the correct y-coordinate. + fe_negate(&y_neg, &y) + parity_neq := (y_is_odd ~ fe_is_odd(&y)) & 1 + + fe_set(&p.x, &x) + fe_cond_select(&p.y, &y, &y_neg, parity_neq) + fe_one(&p.z) + + return true +} + +@(require_results) +pt_bytes :: proc "contextless" (x, y: []byte, p: ^$T) -> bool { + when T == Point_p256r1 { + FE_SZ :: FE_SIZE_P256R1 + } else { + #panic("weierstrass: invalid curve") + } + + if pt_is_identity(p) == 1 { + return false + } + + // Convert to affine coordinates. + pt_rescale(p, p) + + switch len(x) { + case 0: + case FE_SZ: + fe_bytes(x, &p.x) + case: + panic_contextless("weierstrass: invalid x buffer") + } + switch len(y) { + case 0: + case FE_SZ: + fe_bytes(y, &p.y) + case: + panic_contextless("weierstrass: invalid y buffer") + } + + return true +} + +pt_set :: proc "contextless" (p, q: ^$T) { + fe_set(&p.x, &q.x) + fe_set(&p.y, &q.y) + fe_set(&p.z, &q.z) +} + +pt_identity :: proc "contextless" (p: ^$T) { + fe_zero(&p.x) + fe_one(&p.y) + fe_zero(&p.z) +} + +pt_generator :: proc "contextless" (p: ^$T) { + fe_gen_x(&p.x) + fe_gen_y(&p.y) + fe_one(&p.z) +} + +pt_clear :: proc "contextless" (p: ^$T) { + fe_clear(&p.x) + fe_clear(&p.y) + fe_clear(&p.z) +} + +pt_clear_vec :: proc "contextless" (arg: []^$T) { + for p in arg { + pt_clear(p) + } +} + +pt_add :: proc "contextless" (p, a, b: ^$T) { + // Algorithm 4 from "Complete addition formulas for prime + // order elliptic curves" by Renes, Costello, and Batina. + // + // The formula is complete in that it is valid for all a and b, + // without exceptions or extra assumptions about the inputs. + // + // The operation costs are `12M + 2mb + 29a`. + + when T == Point_p256r1 { + t0, t1, t2, t3, t4, b_fe: Field_Element_p256r1 + x3, y3, z3: Field_Element_p256r1 + defer fe_clear_vec([]^Field_Element_p256r1{&t0, &t1, &t2, &t3, &t4, &x3, &y3, &z3}) + } else { + #panic("weierstrass: invalid curve") + } + + x1, y1, z1 := &a.x, &a.y, &a.z + x2, y2, z2 := &b.x, &b.y, &b.z + + fe_b(&b_fe) + + // t0 := X1 * X2 ; t1 := Y1 * Y2 ; t2 := Z1 * Z2 ; + fe_mul(&t0, x1, x2) + fe_mul(&t1, y1, y2) + fe_mul(&t2, z1, z2) + + // t3 := X1 + Y1 ; t4 := X2 + Y2 ; t3 := t3 * t4 ; + fe_add(&t3, x1, y1) + fe_add(&t4, x2, y2) + fe_mul(&t3, &t3, &t4) + + // t4 := t0 + t1 ; t3 := t3 - t4 ; t4 := Y1 + Z1 ; + fe_add(&t4, &t0, &t1) + fe_sub(&t3, &t3, &t4) + fe_add(&t4, y1, z1) + + // X3 := Y2 + Z2 ; t4 := t4 * X3 ; X3 := t1 + t2 ; + fe_add(&x3, y2, z2) + fe_mul(&t4, &t4, &x3) + fe_add(&x3, &t1, &t2) + + // t4 := t4 - X3 ; X3 := X1 + Z1 ; Y3 := X2 + Z2 ; + fe_sub(&t4, &t4, &x3) + fe_add(&x3, x1, z1) + fe_add(&y3, x2, z2) + + // X3 := X3 * Y3 ; Y3 := t0 + t2 ; Y3 := X3 - Y3 ; + fe_mul(&x3, &x3, &y3) + fe_add(&y3, &t0, &t2) + fe_sub(&y3, &x3, &y3) + + // Z3 := b * t2 ; X3 := Y3 - Z3 ; Z3 := X3 + X3 ; + fe_mul(&z3, &b_fe, &t2) + fe_sub(&x3, &y3, &z3) + fe_add(&z3, &x3, &x3) + + // X3 := X3 + Z3 ; Z3 := t1 - X3 ; X3 := t1 + X3 ; + fe_add(&x3, &x3, &z3) + fe_sub(&z3, &t1, &x3) + fe_add(&x3, &t1, &x3) + + // Y3 := b * Y3 ; t1 := t2 + t2 ; t2 := t1 + t2 ; + fe_mul(&y3, &b_fe, &y3) + fe_add(&t1, &t2, &t2) + fe_add(&t2, &t1, &t2) + + // Y3 := Y3 - t2 ; Y3 := Y3 - t0 ; t1 := Y3 + Y3 ; + fe_sub(&y3, &y3, &t2) + fe_sub(&y3, &y3, &t0) + fe_add(&t1, &y3, &y3) + + // Y3 := t1 + Y3 ; t1 := t0 + t0 ; t0 := t1 + t0 ; + fe_add(&y3, &t1, &y3) + fe_add(&t1, &t0, &t0) + fe_add(&t0, &t1, &t0) + + // t0 := t0 - t2 ; t1 := t4 * Y3 ; t2 := t0 * Y3 ; + fe_sub(&t0, &t0, &t2) + fe_mul(&t1, &t4, &y3) + fe_mul(&t2, &t0, &y3) + + // Y3 := X3 * Z3 ; Y3 := Y3 + t2 ; X3 := t3 * X3 ; + fe_mul(&y3, &x3, &z3) + fe_add(&y3, &y3, &t2) + fe_mul(&x3, &t3, &x3) + + // X3 := X3 - t1 ; Z3 := t4 * Z3 ; t1 := t3 * t0 ; + fe_sub(&x3, &x3, &t1) + fe_mul(&z3, &t4, &z3) + fe_mul(&t1, &t3, &t0) + + // Z3 := Z3 + t1 ; + fe_add(&z3, &z3, &t1) + + // return X3 , Y3 , Z3 ; + fe_set(&p.x, &x3) + fe_set(&p.y, &y3) + fe_set(&p.z, &z3) +} + +@(private) +pt_add_mixed :: proc "contextless" (p, a: ^$T, x2, y2: ^$U) { + // Algorithm 5 from "Complete addition formulas for prime + // order elliptic curves" by Renes, Costello, and Batina. + // + // The formula is mixed in that it assumes the z-coordinate + // of the addend (`Z2`) is `1`, meaning that it CAN NOT + // handle the addend being the point at infinity. + // + // The operation costs are `11M + 2mb + 23a` saving + // `1M + 6a` over `pt_add`. + + when T == Point_p256r1 && U == Field_Element_p256r1 { + t0, t1, t2, t3, t4, b_fe: Field_Element_p256r1 + x3, y3, z3: Field_Element_p256r1 + defer fe_clear_vec([]^Field_Element_p256r1{&t0, &t1, &t2, &t3, &t4, &x3, &y3, &z3}) + } else { + #panic("weierstrass: invalid curve") + } + + x1, y1, z1 := &a.x, &a.y, &a.z + + fe_b(&b_fe) + + // t0 := X1 * X2 ; t1 := Y1 * Y2 ; t3 := X2 + Y2 ; + fe_mul(&t0, x1, x2) + fe_mul(&t1, y1, y2) + fe_add(&t3, x2, y2) + + // t4 := X1 + Y1 ; t3 := t3 * t4 ; t4 := t0 + t1 ; + fe_add(&t4, x1, y1) + fe_mul(&t3, &t3, &t4) + fe_add(&t4, &t0, &t1) + + // t3 := t3 − t4 ; t4 := Y2 * Z1 ; t4 := t4 + Y1 ; + fe_sub(&t3, &t3, &t4) + fe_mul(&t4, y2, z1) + fe_add(&t4, &t4, y1) + + // Y3 := X2 * Z1 ; Y3 := Y3 + X1 ; Z3 := b * Z1 ; + fe_mul(&y3, x2, z1) + fe_add(&y3, &y3, x1) + fe_mul(&z3, &b_fe, z1) + + // X3 := Y3 − Z3 ; Z3 := X3 + X3 ; X3 := X3 + Z3 ; + fe_sub(&x3, &y3, &z3) + fe_add(&z3, &x3, &x3) + fe_add(&x3, &x3, &z3) + + // Z3 := t1 − X3 ; X3 := t1 + X3 ;. Y3 := b * Y3 ; + fe_sub(&z3, &t1, &x3) + fe_add(&x3, &t1, &x3) + fe_mul(&y3, &b_fe, &y3) + + // t1 := Z1 + Z1 ; t2 := t1 + Z1 ; Y3 := Y3 − t2 ; + fe_add(&t1, z1, z1) + fe_add(&t2, &t1, z1) + fe_sub(&y3, &y3, &t2) + + // Y3 := Y3 − t0 ; t1 := Y3 + Y3 ; Y3 := t1 + Y3 ; + fe_sub(&y3, &y3, &t0) + fe_add(&t1, &y3, &y3) + fe_add(&y3, &t1, &y3) + + // t1 := t0 + t0 ; t0 := t1 + t0 ; t0 := t0 − t2 ; + fe_add(&t1, &t0, &t0) + fe_add(&t0, &t1, &t0) + fe_sub(&t0, &t0, &t2) + + // t1 := t4 * Y3 ; t2 := t0 * Y3 ; Y3 := X3 * Z3 ; + fe_mul(&t1, &t4, &y3) + fe_mul(&t2, &t0, &y3) + fe_mul(&y3, &x3, &z3) + + // Y3 := Y3 + t2 ; X3 := t3 * X3 ; X3 := X3 − t1 ; + fe_add(&y3, &y3, &t2) + fe_mul(&x3, &t3, &x3) + fe_sub(&x3, &x3, &t1) + + // Z3 := t4 * Z3 ; t1 := t3 * t0 ; Z3 := Z3 + t1 ; + fe_mul(&z3, &t4, &z3) + fe_mul(&t1, &t3, &t0) + fe_add(&z3, &z3, &t1) + + // return X3 , Y3 , Z3 ; + fe_set(&p.x, &x3) + fe_set(&p.y, &y3) + fe_set(&p.z, &z3) +} + +pt_double :: proc "contextless" (p, a: ^$T) { + // Algorithm 6 from "Complete addition formulas for prime + // order elliptic curves" by Renes, Costello, and Batina. + // + // The formula is complete in that it is valid for all a, + // without exceptions or extra assumptions about the inputs. + // + // The operation costs are `8M + 3S + 2mb + 21a`. + + when T == Point_p256r1 { + t0, t1, t2, t3, b_fe: Field_Element_p256r1 + x3, y3, z3: Field_Element_p256r1 + defer fe_clear_vec([]^Field_Element_p256r1{&t0, &t1, &t2, &t3, &x3, &y3, &z3}) + } else { + #panic("weierstrass: invalid curve") + } + + x, y, z := &a.x, &a.y, &a.z + + fe_b(&b_fe) + + // t0 := X ^2; t1 := Y ^2; t2 := Z ^2; + fe_square(&t0, x) + fe_square(&t1, y) + fe_square(&t2, z) + + // t3 := X * Y ; t3 := t3 + t3 ; Z3 := X * Z ; + fe_mul(&t3, x, y) + fe_add(&t3, &t3, &t3) + fe_mul(&z3, x, z) + + // Z3 := Z3 + Z3 ; Y3 := b * t2 ; Y3 := Y3 - Z3 ; + fe_add(&z3, &z3, &z3) + fe_mul(&y3, &b_fe, &t2) + fe_sub(&y3, &y3, &z3) + + // X3 := Y3 + Y3 ; Y3 := X3 + Y3 ; X3 := t1 - Y3 ; + fe_add(&x3, &y3, &y3) + fe_add(&y3, &x3, &y3) + fe_sub(&x3, &t1, &y3) + + // Y3 := t1 + Y3 ; Y3 := X3 * Y3 ; X3 := X3 * t3 ; + fe_add(&y3, &t1, &y3) + fe_mul(&y3, &x3, &y3) + fe_mul(&x3, &x3, &t3) + + // t3 := t2 + t2 ; t2 := t2 + t3 ; Z3 := b * Z3 ; + fe_add(&t3, &t2, &t2) + fe_add(&t2, &t2, &t3) + fe_mul(&z3, &b_fe, &z3) + + // Z3 := Z3 - t2 ; Z3 := Z3 - t0 ; t3 := Z3 + Z3 ; + fe_sub(&z3, &z3, &t2) + fe_sub(&z3, &z3, &t0) + fe_add(&t3, &z3, &z3) + + // Z3 := Z3 + t3 ; t3 := t0 + t0 ; t0 := t3 + t0 ; + fe_add(&z3, &z3, &t3) + fe_add(&t3, &t0, &t0) + fe_add(&t0, &t3, &t0) + + // t0 := t0 - t2 ; t0 := t0 * Z3 ; Y3 := Y3 + t0 ; + fe_sub(&t0, &t0, &t2) + fe_mul(&t0, &t0, &z3) + fe_add(&y3, &y3, &t0) + + // t0 := Y * Z ; t0 := t0 + t0 ; Z3 := t0 * Z3 ; + fe_mul(&t0, y, z) + fe_add(&t0, &t0, &t0) + fe_mul(&z3, &t0, &z3) + + // X3 := X3 - Z3 ; Z3 := t0 * t1 ; Z3 := Z3 + Z3 ; + fe_sub(&x3, &x3, &z3) + fe_mul(&z3, &t0, &t1) + fe_add(&z3, &z3, &z3) + + // Z3 := Z3 + Z3 ; + fe_add(&z3, &z3, &z3) + + // return X3 , Y3 , Z3 ; + fe_set(&p.x, &x3) + fe_set(&p.y, &y3) + fe_set(&p.z, &z3) +} + +pt_sub :: proc "contextless" (p, a, b: ^$T) { + b_neg: T + pt_negate(&b_neg, b) + pt_add(p, a, &b_neg) + + fe_clear(&b_neg) +} + +pt_negate :: proc "contextless" (p, a: ^$T) { + fe_set(&p.x, &a.x) + fe_negate(&p.y, &a.y) + fe_set(&p.z, &a.z) +} + +pt_rescale :: proc "contextless" (p, a: ^$T) { + // A = 1/Z1 + // X3 = A*X1 + // Y3 = A*Y1 + // Z3 = 1 + // + // As per "From A to Z: Projective coordinates leakage in the wild" + // leaking the Z-coordinate is bad. The modular inversion algorithm + // used in this library is based on Fermat's Little Theorem. + // + // See: https://eprint.iacr.org/2020/432.pdf + + was_identity := pt_is_identity(a) + + when T == Point_p256r1 { + z_inv: Field_Element_p256r1 + } else { + #panic("weierstrass: invalid curve") + } + + ident: T + fe_inv(&z_inv, &a.z) + fe_mul(&p.x, &a.x, &z_inv) + fe_mul(&p.y, &a.y, &z_inv) + fe_one(&p.z) + + pt_identity(&ident) + pt_cond_select(p, p, &ident, was_identity) + + fe_clear(&z_inv) +} + +pt_cond_select :: proc "contextless" (p, a, b: ^$T, ctrl: int) { + fe_cond_select(&p.x, &a.x, &b.x, ctrl) + fe_cond_select(&p.y, &a.y, &b.y, ctrl) + fe_cond_select(&p.z, &a.z, &b.z, ctrl) +} + +@(require_results) +pt_equal :: proc "contextless" (a, b: ^$T) -> int { + when T == Point_p256r1 { + x1z2, x2z1, y1z2, y2z1: Field_Element_p256r1 + } else { + #panic("weierstrass: invalid curve") + } + + // Check X1Z2 == X2Z1 && Y1Z2 == Y2Z1 + fe_mul(&x1z2, &a.x, &b.z) + fe_mul(&x2z1, &b.x, &a.z) + + fe_mul(&y1z2, &a.y, &b.z) + fe_mul(&y2z1, &b.y, &a.z) + + return fe_equal(&x1z2, &x2z1) & fe_equal(&y1z2, &y2z1) +} + +@(require_results) +pt_is_identity :: proc "contextless" (p: ^$T) -> int { + return fe_is_zero(&p.z) +} + +@(require_results) +pt_is_y_odd :: proc "contextless" (p: ^$T) -> int { + tmp: T + defer pt_clear(&tmp) + + fe_set(&tmp, p) + pt_rescale(&tmp) + + return fe_is_odd(&tmp.y) +} + +@(private) +is_on_curve :: proc "contextless" (x, y: ^$T) -> bool { + maybe_yy, yy: T + defer fe_clear_vec([]^T{&maybe_yy, &yy}) + + // RHS: x^3 + ax + b + set_yy_candidate(&maybe_yy, x) + + // LHS: y^2 + fe_square(&yy, y) + + return fe_equal(&maybe_yy, &yy) == 1 +} + +@(private) +set_yy_candidate :: proc "contextless" (maybe_yy, x: ^$T) { + // RHS: x^3 + ax + b + rhs, tmp: T + + fe_square(&tmp, x) + fe_mul(&rhs, &tmp, x) + + fe_a(&tmp) + fe_mul(&tmp, &tmp, x) + fe_add(&rhs, &rhs, &tmp) + + fe_b(&tmp) + fe_add(maybe_yy, &rhs, &tmp) + + fe_clear(&rhs) +} diff --git a/core/crypto/_weierstrass/point_s11n_sec.odin b/core/crypto/_weierstrass/point_s11n_sec.odin new file mode 100644 index 000000000..ae009edb0 --- /dev/null +++ b/core/crypto/_weierstrass/point_s11n_sec.odin @@ -0,0 +1,95 @@ +package _weierstrass + +@(require) import "core:mem" + +@(private) +SEC_PREFIX_IDENTITY :: 0x00 +@(private) +SEC_PREFIX_COMPRESSED_EVEN :: 0x02 +@(private) +SEC_PREFIX_COMPRESSED_ODD :: 0x03 +SEC_PREFIX_UNCOMPRESSED :: 0x04 + +@(require_results) +pt_set_sec_bytes :: proc "contextless" (p: ^$T, b: []byte) -> bool { + when T == Point_p256r1 { + FE_SZ :: FE_SIZE_P256R1 + } else { + #panic("weierstrass: invalid curve") + } + + b_len := len(b) + if b_len < 1 { + return false + } + + switch b[0] { + case SEC_PREFIX_IDENTITY: + if b_len != 1 { + return false + } + pt_identity(p) + return true + case SEC_PREFIX_COMPRESSED_EVEN, SEC_PREFIX_COMPRESSED_ODD: + if b_len != 1 + FE_SZ { + return false + } + y_is_odd := b[0] - SEC_PREFIX_COMPRESSED_EVEN + return pt_set_x_bytes(p, b[1:], int(y_is_odd)) + case SEC_PREFIX_UNCOMPRESSED: + if b_len != 1 + 2 * FE_SZ { + return false + } + x, y := b[1:1+FE_SZ], b[1+FE_SZ:] + return pt_set_xy_bytes(p, x, y) + case: + return false + } +} + +@(require_results) +pt_sec_bytes :: proc "contextless" (b: []byte, p: ^$T, compressed: bool) -> bool { + when T == Point_p256r1 { + FE_SZ :: FE_SIZE_P256R1 + } else { + #panic("weierstrass: invalid curve") + } + + b_len := len(b) + if pt_is_identity(p) == 1 { + if b_len != 1 { + return false + } + b[0] = SEC_PREFIX_IDENTITY + return true + } + + x, y: []byte + y_: [FE_SZ]byte + switch compressed { + case true: + if b_len != 1 + FE_SZ { + return false + } + x, y = b[1:], y_[:] + case false: + if b_len != 1 + 2 * FE_SZ { + return false + } + b[0]= SEC_PREFIX_UNCOMPRESSED + x, y = b[1:1+FE_SZ], b[1+FE_SZ:] + } + if !pt_bytes(x, y, p) { + return false + } + if compressed { + // Instead of calling pt_is_y_odd, just serializing + // y into a temp buffer and checking the parity saves + // 1 redundant rescale call. + y_is_odd := byte(y[FE_SZ-1] & 1) + b[0] = SEC_PREFIX_COMPRESSED_EVEN + y_is_odd + mem.zero_explicit(&y_, size_of(y_)) + } + + return true +} diff --git a/core/crypto/_weierstrass/sc.odin b/core/crypto/_weierstrass/sc.odin new file mode 100644 index 000000000..2ed9459bc --- /dev/null +++ b/core/crypto/_weierstrass/sc.odin @@ -0,0 +1,76 @@ +package _weierstrass + +import p256r1 "core:crypto/_fiat/field_scalarp256r1" +import subtle "core:crypto/_subtle" + +Scalar_p256r1 :: p256r1.Montgomery_Domain_Field_Element + +SC_SIZE_P256R1 :: 32 + +sc_clear :: proc { + p256r1.fe_clear, +} + +sc_clear_vec :: proc { + p256r1.fe_clear_vec, +} + +sc_set_bytes :: proc { + p256r1.fe_from_bytes, +} +sc_bytes :: proc { + p256r1.fe_to_bytes, +} + +sc_set :: proc { + p256r1.fe_set, +} + +sc_zero :: proc { + p256r1.fe_zero, +} + +sc_one_p256r1 :: proc { + p256r1.fe_one, +} + +sc_add :: proc { + p256r1.fe_add, +} + +sc_sub :: proc { + p256r1.fe_sub, +} + +sc_negate :: proc { + p256r1.fe_opp, +} + +sc_mul :: proc { + p256r1.fe_mul, +} + +sc_square :: proc { + p256r1.fe_square, +} + +sc_cond_assign :: proc { + p256r1.fe_cond_assign, +} + +sc_equal :: proc { + p256r1.fe_equal, +} + +sc_is_odd :: proc { + p256r1.fe_is_odd, +} + +sc_is_zero :: proc { + sc_is_zero_p256r1, +} + +@(require_results) +sc_is_zero_p256r1 :: proc "contextless" (fe: ^Scalar_p256r1) -> int { + return int(subtle.u64_is_zero(p256r1.fe_non_zero(fe))) +} diff --git a/core/crypto/_weierstrass/scalar_mul.odin b/core/crypto/_weierstrass/scalar_mul.odin new file mode 100644 index 000000000..1781ac3b6 --- /dev/null +++ b/core/crypto/_weierstrass/scalar_mul.odin @@ -0,0 +1,204 @@ +package _weierstrass + +import "core:crypto" +import subtle "core:crypto/_subtle" +import "core:mem" + +pt_scalar_mul :: proc "contextless" ( + p, a: ^$T, + sc: ^$S, + unsafe_is_vartime: bool = false, +) { + when T == Point_p256r1 && S == Scalar_p256r1 { + SC_SZ :: SC_SIZE_P256R1 + } else { + #panic("weierstrass: invalid curve") + } + + b: [SC_SZ]byte = --- + sc_bytes(b[:], sc) + + pt_scalar_mul_bytes(p, a, b[:], unsafe_is_vartime) + + if !unsafe_is_vartime { + mem.zero_explicit(&b, size_of(b)) + } +} + +pt_scalar_mul_bytes :: proc "contextless" ( + p, a: ^$T, + sc: []byte, + unsafe_is_vartime: bool = false, +) { + when T == Point_p256r1 { + p_tbl: Multiply_Table_p256r1 = --- + q, tmp: Point_p256r1 = ---, --- + SC_SZ :: SC_SIZE_P256R1 + } else { + #panic("weierstrass: invalid curve") + } + + assert_contextless(len(sc) == SC_SZ, "weierstrass: invalid scalar size") + mul_tbl_set(&p_tbl, a, unsafe_is_vartime) + + pt_identity(&q) + for limb_byte, i in sc { + hi, lo := (limb_byte >> 4) & 0x0f, limb_byte & 0x0f + + if i != 0 { + pt_double(&q, &q) + pt_double(&q, &q) + pt_double(&q, &q) + pt_double(&q, &q) + } + mul_tbl_lookup_add(&q, &tmp, &p_tbl, u64(hi), unsafe_is_vartime) + + pt_double(&q, &q) + pt_double(&q, &q) + pt_double(&q, &q) + pt_double(&q, &q) + mul_tbl_lookup_add(&q, &tmp, &p_tbl, u64(lo), unsafe_is_vartime) + } + + pt_set(p, &q) + + if !unsafe_is_vartime { + mem.zero_explicit(&p_tbl, size_of(p_tbl)) + pt_clear_vec([]^T{&q, &tmp}) + } +} + +when crypto.COMPACT_IMPLS == true { + pt_scalar_mul_generator :: proc "contextless" ( + p: ^$T, + sc: ^$S, + unsafe_is_vartime: bool = false, + ) { + g: T + pt_generator(&g) + + pt_scalar_mul(p, &g, sc, unsafe_is_vartime) + } +} else { + pt_scalar_mul_generator :: proc "contextless" ( + p: ^$T, + sc: ^$S, + unsafe_is_vartime: bool = false, + ) { + when T == Point_p256r1 && S == Scalar_p256r1 { + p_tbl_hi := &Gen_Multiply_Table_p256r1_hi + p_tbl_lo := &Gen_Multiply_Table_p256r1_lo + tmp: Point_p256r1 = --- + SC_SZ :: SC_SIZE_P256R1 + } else { + #panic("weierstrass: invalid curve") + } + + b: [SC_SZ]byte + sc_bytes(b[:], sc) + + pt_identity(p) + for limb_byte, i in b { + hi, lo := (limb_byte >> 4) & 0x0f, limb_byte & 0x0f + mul_affine_tbl_lookup_add(p, &tmp, &p_tbl_hi[i], u64(hi), unsafe_is_vartime) + mul_affine_tbl_lookup_add(p, &tmp, &p_tbl_lo[i], u64(lo), unsafe_is_vartime) + } + + if !unsafe_is_vartime { + mem.zero_explicit(&b, size_of(b)) + pt_clear(&tmp) + } + } +} + +@(private="file") +Multiply_Table_p256r1 :: [15]Point_p256r1 + +@(private="file") +mul_tbl_set :: proc "contextless"( + tbl: ^$T, + point: ^$U, + unsafe_is_vartime: bool, +) { + when T == Multiply_Table_p256r1 && U == Point_p256r1{ + tmp: Point_p256r1 + pt_set(&tmp, point) + } else { + #panic("weierstrass: invalid curve") + } + + pt_set(&tbl[0], &tmp) + for i in 1 ..<15 { + pt_add(&tmp, &tmp, point) + pt_set(&tbl[i], &tmp) + } + + if !unsafe_is_vartime { + pt_clear(&tmp) + } +} + +@(private="file") +mul_tbl_lookup_add :: proc "contextless" ( + point, tmp: ^$T, + tbl: ^$U, + idx: u64, + unsafe_is_vartime: bool, + ) { + if unsafe_is_vartime { + switch idx { + case 0: + case: + pt_add(point, point, &tbl[idx - 1]) + } + return + } + + pt_identity(tmp) + for i in u64(1)..<16 { + ctrl := subtle.eq(i, idx) + pt_cond_select(tmp, tmp, &tbl[i - 1], int(ctrl)) + } + + pt_add(point, point, tmp) +} + +when crypto.COMPACT_IMPLS == false { + @(private) + Affine_Point_p256r1 :: struct { + x: Field_Element_p256r1, + y: Field_Element_p256r1, + } + + @(private="file") + mul_affine_tbl_lookup_add :: proc "contextless" ( + point, tmp: ^$T, + tbl: ^$U, + idx: u64, + unsafe_is_vartime: bool, + ) { + if unsafe_is_vartime { + switch idx { + case 0: + case: + pt_add_mixed(point, point, &tbl[idx - 1].x, &tbl[idx - 1].y) + } + return + } + + pt_identity(tmp) + for i in u64(1)..<16 { + ctrl := int(subtle.eq(i, idx)) + fe_cond_select(&tmp.x, &tmp.x, &tbl[i - 1].x, ctrl) + fe_cond_select(&tmp.y, &tmp.y, &tbl[i - 1].y, ctrl) + } + + // The mixed addition formula assumes that the addend is not + // the neutral element. Do the addition regardless, and then + // conditionally select the right result. + pt_add_mixed(tmp, point, &tmp.x, &tmp.y) + + ctrl := subtle.u64_is_non_zero(idx) + pt_cond_select(point, point, tmp, int(ctrl)) + } +} diff --git a/core/crypto/_weierstrass/secp256r1_table.odin b/core/crypto/_weierstrass/secp256r1_table.odin new file mode 100644 index 000000000..1a6bc3ef6 --- /dev/null +++ b/core/crypto/_weierstrass/secp256r1_table.odin @@ -0,0 +1,3985 @@ +package _weierstrass + +/* + ------ GENERATED ------ DO NOT EDIT ------ GENERATED ------ DO NOT EDIT ------ GENERATED ------ +*/ + +import "core:crypto" + +when crypto.COMPACT_IMPLS == false { + @(private,rodata) + Gen_Multiply_Table_p256r1_hi := [32][15]Affine_Point_p256r1 { + { + { + {9259451175701532574, 15597985540941612547, 4541553034987877619, 8927802479718285609}, + {14672230714928802576, 14284617950605306700, 13339970812390782046, 787078889494395850}, + }, + { + {18165439414433063919, 14693282888419586094, 14992616289789993230, 13232208150801553912}, + {16850347485914337693, 223364064845089224, 7302899015436300563, 4391216311540396088}, + }, + { + {12558388403188680537, 10687978569513354810, 9373570856564649772, 4079327722512691465}, + {5372437374337150740, 3297421622932790851, 9326853593823854687, 8305371884938201251}, + }, + { + {13121472331750731303, 323745485980480220, 15110308702528119977, 4696302365805118372}, + {9859094500834571602, 5315656270700787939, 4187063204400651801, 1695695129564818327}, + }, + { + {12817586844019849804, 15425488216915741929, 15293562913126043054, 11770898970765978555}, + {6806103820345670787, 17789094149138630459, 3807781571713999192, 5823254011289457198}, + }, + { + {10112524230916015604, 13571143908656270599, 6031089010487808103, 5774558171390644848}, + {1808959243244841573, 14071312530426692155, 9241399242704553402, 9836150050655369231}, + }, + { + {14083007972403535491, 16009534514129505275, 12481249112231139039, 10309390659262581143}, + {5782517315325366794, 16717384553294759530, 4578392002424884134, 239005024949492645}, + }, + { + {1836857790164349346, 11263074778654917115, 4786985732596838094, 10525445084936097674}, + {1484357665966453236, 3110871407036679558, 1668700683093601768, 2736269131339849752}, + }, + { + {9249362594190920246, 8088172462140746331, 4080107866285682736, 16205599538438551353}, + {18312943145606312277, 9100632964181080418, 3969991115337154345, 5340098959750368315}, + }, + { + {12122448407048035645, 2891250339380982359, 12794212052932523400, 7166035112141500392}, + {15777441312724841162, 4552528682229856831, 2210391301762911476, 16410254680957321386}, + }, + { + {6910044784455706429, 11951245774670922855, 207795885948948810, 3884359690300962405}, + {4578772752480772344, 2948797025787714138, 16774444535658202808, 1388183483009000463}, + }, + { + {16561979129019905420, 1881862411760441386, 15441950514711322010, 12933020223458438856}, + {5570341451312029630, 18172638959728259059, 9074261777549091198, 6171200053222754816}, + }, + { + {10126435102176037237, 1545112930055760251, 11563139991870561593, 10766754172364938834}, + {5116781688621052838, 14471715119500781375, 4724882615229687192, 10031687030722046325}, + }, + { + {15016829467434780812, 6777508689306592732, 3811682306063049290, 11475361222871876387}, + {6080948654298953274, 11612742274762615033, 5268311600240325047, 9147351973710519861}, + }, + { + {12130203770930472759, 3880998309361490881, 8807462332494735511, 9291388074337055133}, + {18165312304248982432, 12733144434841535979, 18090195697688236271, 5825342884125782172}, + }, + }, + { + { + {194633990068625151, 1028128699653523895, 7436102537486268753, 1855520454959348468}, + {5098690958966904466, 3342676718901330604, 6942212660412942406, 16510188838209674083}, + }, + { + {7963995066277321795, 14986230345162551366, 10616366460602472778, 16186943329215681149}, + {9522855644164647723, 9858336437877021178, 16344942402271072884, 18027353494090590022}, + }, + { + {13392726161043192788, 7606793939450765773, 9543984695709321129, 6135912406103198328}, + {10903991926178685177, 529801710637680784, 8207012095420105234, 4590962949922268360}, + }, + { + {13175608910844763921, 11168387468381338510, 5555873864224342205, 17780559602571640345}, + {1582669533588472814, 8145133762789622706, 1625372887980692455, 4576809104068554285}, + }, + { + {17616803153811079355, 17809794753465712025, 10788493879428408032, 1263026253532745742}, + {331896291298606534, 13299145463579793142, 8951131463540898010, 11121758705853021600}, + }, + { + {17015522374255846157, 7155392284047197223, 1248775493117789546, 9199472299655737207}, + {13126885324657282947, 12092989376083683289, 2035698983314262432, 835441512024005104}, + }, + { + {12481871371020004325, 15786477648044981224, 2586272424816191689, 4208704695692543659}, + {16940467964964992440, 11207566805119564978, 2858987625603639630, 9561510646236248154}, + }, + { + {2900978533555060931, 1749946807863203576, 11705734511931072459, 4446980691693419424}, + {14437524160594907241, 12795912566640000773, 10400036254697939154, 8356113088668925361}, + }, + { + {3770654812111500682, 7723332701546321657, 12057007323752084660, 11871339027463593983}, + {8927366002257844381, 331175455338905356, 6085376066711046662, 195998713859126244}, + }, + { + {15888580251537997623, 14253909833728698978, 14445538492667230716, 4028538972354525849}, + {7720263170150940477, 1190890222876864097, 8657188516818851005, 1987613286973742753}, + }, + { + {1556082539082087499, 9191446579576007527, 16923484407567577707, 4662661048159090855}, + {12760778972220173745, 3942937056545553996, 12952479961991875179, 8914103212381870290}, + }, + { + {8900726473285671992, 890209742292473781, 16059468388719373167, 16577940938542233221}, + {17381766864962227733, 231915274132518769, 16477817024012878700, 15646021286310268545}, + }, + { + {10104554368814337641, 170400126349943750, 16051269335758964391, 7842493858299913771}, + {9246756702190574744, 110682656515867335, 11402798562961521905, 17325237240525801251}, + }, + { + {15837018286366797690, 18114413810565810328, 9441874034567150801, 14075941137889189393}, + {12786763055047269260, 9121030808281463204, 1713778999270814105, 17015261864438490667}, + }, + { + {12997570542605430113, 5500897611058123544, 4160129407772614089, 13768264346635084004}, + {6638654171187871203, 6080635069726153281, 2255431148803290413, 3789670411999607189}, + }, + }, + { + { + {1830819081327272165, 11951292080860646547, 18002500803418629938, 13317986695217403840}, + {5005574200470766330, 10138179785738652504, 1610518863105278224, 13309443265578956954}, + }, + { + {14192194428653714479, 11578618567931657764, 6032668189933768881, 15981535562386193924}, + {8925792218631314923, 9408714146004183681, 8859017894477140398, 1675606340537058506}, + }, + { + {3265119697568866078, 13753322853248061974, 15435163376825672274, 13646180516491714938}, + {15620545622955090250, 18241486585498394565, 459566729126467878, 9728217493753855944}, + }, + { + {9883406233903270985, 17184231210468300584, 5498903678702785900, 6903833261382863389}, + {11489138095102981636, 9021901931786177471, 3227433089132150317, 16639455550797627042}, + }, + { + {839045372102318861, 2032615141683118500, 1921816835840256924, 504869150737570005}, + {15932184001422473505, 7849475855313305697, 1189994394722618598, 9874798350548229684}, + }, + { + {4636201671610663345, 16662311204732135584, 12398897461787695675, 1355753199357412657}, + {14695655628527768564, 1692838776852698754, 7346906782826540912, 14869028424564984700}, + }, + { + {14240080119980315297, 4751983902385717684, 7941412103662252178, 4796803816695225123}, + {9327986654018000413, 15111345676387005726, 3582558555283734415, 11913156735178831102}, + }, + { + {12915868875134296756, 3071143582305760275, 10848717856747030010, 10973183887638314967}, + {5983269487036236823, 9885184706933333413, 14509493669845681951, 9669608065801379977}, + }, + { + {7848634325810890057, 4356492357483949442, 8777700982672429871, 447737364627887590}, + {2892466086138453900, 12013259293340538023, 3423275627272380730, 11171074631447548946}, + }, + { + {14593553227914306527, 7393098159726367793, 959457858782426605, 12924066827318848802}, + {14790800265003508462, 13805969419986022239, 4408523909823076864, 16722715416825698787}, + }, + { + {8554182115079118694, 17233907570567075631, 12336560627384786590, 5123566378696582545}, + {96401035522143140, 10138155491929979850, 17651328686428132420, 3453390145222258032}, + }, + { + {16197242500758474188, 3349369240724295499, 9422940308750670637, 16888844525585804807}, + {14045424784406071799, 13180603138700207746, 2683581192503868543, 3842875784859878}, + }, + { + {17498073686183419231, 6922314891526280784, 16083733402282932920, 15425477806093217459}, + {12425976625898608391, 16458101989314253841, 10013521940061058050, 10858868879196007236}, + }, + { + {123600201037598181, 6690762836954208162, 17157040810691942664, 15263405971805161132}, + {8685477170453562173, 10331174323986544033, 5789045082422148337, 3007978469441468974}, + }, + { + {2402095889286816125, 18054120920831753009, 11753130221915918396, 10341553510464463050}, + {280903370426929900, 14994955837151914025, 13551362401871479612, 14711789630561753093}, + }, + }, + { + { + {14086745261650819748, 17953107869776717888, 1777725846494438428, 2765314406831814212}, + {2603997194371852991, 2223517025105045134, 15579901335531749634, 6571733615332171148}, + }, + { + {5478465698516556930, 287443454357750768, 12201204663663129285, 782849770204658255}, + {11270045035009204251, 18152683972363144337, 10463300037926642739, 14363641589598863851}, + }, + { + {3790592075869665284, 5120320091554329756, 15361581282394028709, 14360464660911164915}, + {15249656958991931940, 2563751872827049233, 13745792006936646733, 14572943674933168173}, + }, + { + {3167679014977537749, 3417445004776702290, 1709246158507866266, 5861367897285174360}, + {8437429877561342262, 17231607446243478748, 16047596399306766948, 17656438585829685897}, + }, + { + {12977336347094692192, 13723871955002954132, 17399919575273038847, 16163973860244779675}, + {14997921584659740746, 6543247361992425067, 4675926398794487109, 17580512382853194054}, + }, + { + {10778828023580771765, 9812611440536367405, 14168149065325522570, 6692229110872358750}, + {11010962724400581057, 13055203605065073902, 11396463140731730116, 16969789651736772232}, + }, + { + {3285258013801327520, 14114268241282882888, 5367399533198476395, 17277410244918727028}, + {2751895479568588421, 751309667192066167, 13038472116718581917, 16013586354334596135}, + }, + { + {12364168614988940500, 13194367252463423118, 12223406606527741280, 5014139294736037086}, + {11244699482831816093, 5336498572491451990, 14268404582568856142, 14502318820969599316}, + }, + { + {13295673091232554814, 313981772853781347, 11829785736449464030, 13341198421333360997}, + {16787450350663111566, 6525407229623764159, 2012189087039636323, 2110887590404698758}, + }, + { + {16984895766311549717, 1057465499230843916, 13565444352859773343, 1019268943988786852}, + {2190009140530404855, 10045598732295352970, 4789803496780829836, 10700158388954091321}, + }, + { + {14840255112988420500, 10066628133368048408, 6527354835873855384, 16106607076894419125}, + {3989024604987083046, 10713316697020150694, 16811389107269552264, 11294596059797019619}, + }, + { + {622403023838932676, 11423409007234191765, 17086830255702454786, 1213655124481948199}, + {3976593910085142945, 6315875935390432543, 17947502153968859628, 18031540937011531543}, + }, + { + {342675887578148289, 18366454547938469828, 3853530442390999217, 7499455395579634652}, + {768597405171336502, 1636271570683567151, 16786205337983572309, 13056241332863199715}, + }, + { + {15991153618414855143, 803325462494472241, 5709347424437559249, 10138502962472290727}, + {4675124205115228106, 9599016746550345197, 2769443894695609085, 12311020551315051087}, + }, + { + {11470964304318784059, 17313372553735202469, 10686997186364536871, 9228453594798060121}, + {57933324335302024, 8931389936300346353, 17823596478938529898, 1126996688113949835}, + }, + }, + { + { + {15804957839814547154, 7924193945337173678, 1080401129055171214, 10816444561878528576}, + {13171610473229361771, 8099842733764406841, 9284741070210451667, 9245195215372025289}, + }, + { + {7185947197544988797, 13306809398790059447, 11440959253278285287, 15084384140482244570}, + {5059824327869316332, 7585354587200615362, 6801884469610571467, 6427162399794357267}, + }, + { + {1505501490785526604, 6062033360335279190, 13214531355927393851, 8869230490276248430}, + {11596558698255017116, 6698268011950867978, 15445165013361223076, 4910055064120213146}, + }, + { + {1453348772281274490, 13028088570940491471, 16100623112750251840, 5210244400259879874}, + {9443916155735416174, 16869520919318450506, 7479400208826706574, 14374970913352602458}, + }, + { + {13057495656815142976, 1743194961605203063, 15733599697884179267, 3501754291485677593}, + {7405256272105757266, 12344297842308545819, 3389605493339498760, 3092252531918600248}, + }, + { + {5038191990715247960, 2723916483244871576, 4891019526710760134, 11094632341133260369}, + {6274429941353136467, 1408871421293516065, 12455625869488488781, 3401549469990652817}, + }, + { + {4716563932720198201, 1584625214845878997, 13213357619008940082, 13122950207230795185}, + {12303370001794463898, 6725033180592084698, 12302152314224424594, 6139100303374835750}, + }, + { + {10149597276931117465, 5778043705364022356, 13888443605241209218, 6889225091714429810}, + {16209363638493043975, 8516350006446457646, 9214830076046105138, 8894115046323798175}, + }, + { + {161027176918876103, 2287100732338401479, 16561946444121779293, 9805329436091376243}, + {11473978632757961256, 1245289731366992705, 7338435771556366282, 15749864527919116005}, + }, + { + {2753237807828198865, 11508305846735597339, 9058745440380813449, 3960739040735759442}, + {17921955885187582871, 10231929062430218022, 18115018235326517243, 17854413167898372208}, + }, + { + {638684488109167329, 14596365931372343092, 1917271942976854297, 12291978018935761003}, + {5076527739384635812, 7833625460571766680, 17060902137821849350, 17134703695475138982}, + }, + { + {13026208197163596446, 1935567165776196957, 17296090833026336866, 8461284827078097590}, + {14545382879887213077, 3302103559307506085, 16026840048628844803, 4599071908983273604}, + }, + { + {9156540407095300222, 7598243263658987831, 1996711254516517688, 13013193687414837552}, + {116495354444693499, 12803585308662671588, 8278106437192580735, 3374263264867687146}, + }, + { + {4318910866113560561, 8122780372606489166, 11952351993471767425, 9581759925599323445}, + {12268585667545114307, 7286163136539353394, 12697490728074784421, 7270019569202782882}, + }, + { + {16247467139569457576, 14043942371464607677, 6338399572126720647, 9528527345786650933}, + {16344656963096275115, 13804658662065732334, 2991248997774547140, 12174436388699549119}, + }, + }, + { + { + {1169887957113173798, 4936710663791789838, 8029349457377894665, 3317691225106441967}, + {3622769674498678594, 1954144360900150482, 1432045977341997899, 934737636789214593}, + }, + { + {9646181593082190523, 16068017411165381498, 13319927590045936565, 6113055520205251774}, + {5576373032696512038, 13880344501714804196, 12022206929479211261, 7387979357081975315}, + }, + { + {13553890993911526641, 1237937561304731611, 11053651340854998814, 8737874920379363783}, + {15414508226001886918, 9311523317130687807, 12080742822716708234, 4715194040021784977}, + }, + { + {17182132836049601530, 1486820395924546410, 14089047182364760490, 5375431386740917568}, + {2352352269256972682, 6220398075470064021, 11444733678216077372, 8173002234516562536}, + }, + { + {7896339057146013415, 17613745684396593735, 4238258305077796259, 15438639564771394288}, + {1482402451684594916, 3104492350488980260, 5195487229736262641, 1361150797580203482}, + }, + { + {15949855327936545010, 15892613064802301412, 7776232754624386979, 2193423430757249310}, + {10751855334513902678, 13772090376350944100, 5644047706587449960, 370992037484721524}, + }, + { + {16329953561108738383, 14553061366216182492, 5112198484879130320, 1893048255589705004}, + {11469678860036344015, 8992526488267920066, 18208245559304821518, 8980963391041920447}, + }, + { + {5783711159088718530, 3503029393593618754, 10736192136662142256, 15443859608128978668}, + {271805305647187927, 8244170003029416464, 17017071503038388446, 2536084345379259313}, + }, + { + {9850291665987916519, 6499970366121170030, 7001995026899086280, 9961826319039756858}, + {7497823327397141096, 6975352931548332265, 4068344268340314997, 15888973419716629698}, + }, + { + {3982898776583485812, 10403233710814076420, 8681461491810344216, 4116685619183896910}, + {18192868132325233114, 17377077437999490605, 17997716263755054576, 10376686656480866118}, + }, + { + {3479412946560984795, 5044366097675527819, 13707564929638264911, 5666779920208401261}, + {10137470376683230183, 2075467328249870088, 11457126564907274413, 13701087332649256159}, + }, + { + {12574253652565934836, 8388159655344384255, 16127953452716629313, 1877819316325313228}, + {8945746653921217760, 4616678606113198065, 1336330019150074567, 11910289150769410280}, + }, + { + {9565592090082898867, 1968790057506790036, 4797721149040405609, 13125809848505545280}, + {14122665390767023537, 17271175538744290850, 16007653062195668190, 16371835205840876479}, + }, + { + {10409691258933377688, 13736467137095186370, 2757793467881882435, 12443439690522935631}, + {17601924849565694404, 988048065500720515, 7554063443268400107, 4274248596892038508}, + }, + { + {8972162505776549196, 16209364130421564220, 13018196697272262431, 418388148277092169}, + {11645493996879973039, 5024734975063482607, 3708889997144620499, 11208942121415360714}, + }, + }, + { + { + {17596113920958619489, 11920824479658301378, 3786905428099710821, 11112764289322906111}, + {8817260450068629272, 6518847791514184438, 14593687325057339783, 18018581321332807475}, + }, + { + {2056254186648603335, 12143016575009965669, 3290271983033386616, 4338404082685850854}, + {12660444972475266123, 6345409453044955404, 13278869140778657354, 10063005167581762786}, + }, + { + {5303950317664091150, 17409642188139937758, 12135894348302287058, 16444741243419918751}, + {13935885817311324323, 8496908197501732703, 12163317723288843510, 16891353436915314685}, + }, + { + {4168420842704770545, 338440394515115377, 2102734009665481092, 9772725684473416465}, + {1247616337419130000, 4222072446972129729, 4836898447189504007, 9154346000276664999}, + }, + { + {14649401370738987318, 10044081678892811795, 1306517740393103656, 16586067283450489622}, + {8211832777731897494, 12849393859171286949, 17327526552807783018, 14171704619529498238}, + }, + { + {12849053390245557890, 12693731077061619694, 5891211584023409476, 1008960642219209210}, + {15593393872187214387, 7381248773473326001, 16559656086795428559, 2106025108820858934}, + }, + { + {4347667984894353308, 2129883711661222690, 1076488804494872856, 15059968377755299195}, + {12380937310378496242, 16425480883270944108, 4769192332535557551, 10388305045430499744}, + }, + { + {8553482596123775980, 12627020622203381515, 10774788686070344669, 6271789114731522097}, + {6270586844349642345, 5584690155569770537, 9478526526319537174, 3405597782572827563}, + }, + { + {10255408065071335198, 2384996481315588922, 10679447117297819075, 3734157461055440416}, + {1635042286365643780, 11321809677772938996, 2373960964139986040, 4869129159740273704}, + }, + { + {16681657814739017038, 2045405432090866328, 9473434018957974472, 5549808619751464269}, + {3650191693776946828, 15805634549736708741, 16764187297356548667, 6849534466635874363}, + }, + { + {15295973549776084894, 8150873746601283651, 8017271980921908229, 4899654767305073834}, + {15257501950484641691, 17365331272978440066, 14582514748324426172, 14727798284858071666}, + }, + { + {3180828552573045472, 17698570278585440462, 8986722854533057232, 4518665117523514004}, + {1718699978312382231, 16973074530347269964, 5684175730451960274, 17228649521631238473}, + }, + { + {2897180423141326703, 13691273076814343144, 2967066815351306232, 1032540647518716635}, + {16365716239989474776, 9503666134295232767, 4599017511227366879, 14475021161770955579}, + }, + { + {4512626226592149712, 13575110216387069176, 13488662643497927183, 9673147324484250604}, + {143936220816719815, 2307325398241477161, 468315224038772027, 17743582630124600591}, + }, + { + {1476494936296433813, 3408612621327299295, 11632756669813257564, 14296719897220703576}, + {2241234207239321749, 12237974399755684219, 16253635131573079566, 11892871179872526079}, + }, + }, + { + { + {9440495138081785154, 17328162383695942099, 1870751290505230781, 17987066187778049275}, + {9952223038481207705, 10126409487298126876, 1181369784146909444, 8158422380540037915}, + }, + { + {10892870009313407934, 5709686117526627488, 16343828906887149047, 16063790174205876315}, + {9076070192754075075, 4639156357669822592, 4904064385440242264, 5942264027390072320}, + }, + { + {14586043427955633062, 1886633882927769308, 12786104261802569226, 17414735423561048102}, + {3869682486341171982, 17146691898427698057, 9886217016173201579, 17515773620461053745}, + }, + { + {17271984572727555145, 2097715321690717305, 5328035183708920909, 13206781766168781008}, + {5915693606819932446, 3870849056297265622, 18070792155150730518, 7786839743829304936}, + }, + { + {14091274565690260814, 5039742420071412611, 2322945829654574283, 7678395717670225646}, + {17396071770599775867, 4747582460834310767, 13387178106758137047, 7224458787360678986}, + }, + { + {2020583809775623843, 3803516109208330416, 10492323079463714031, 18244921722581618682}, + {6400055933742731191, 18370212581946723247, 11415812944884122048, 5987324147127294665}, + }, + { + {3106709870210381627, 3437108621064387068, 3265644153772373951, 14353255805499610949}, + {11329727508866046420, 5461257448868659690, 8139681370942905079, 8439558396411914298}, + }, + { + {7939886940063870939, 3597929036186322512, 12732772396498766041, 13300425267730247515}, + {2345112231224079293, 12327614629296314761, 17106102937162407683, 1702694317559034053}, + }, + { + {4276582831142955483, 1304336253044853784, 18317056640605949326, 11200473213973297420}, + {3937030502759894542, 2315314353886242360, 2673827662906962132, 9781744582918546067}, + }, + { + {17837268310687096164, 10122495457633601623, 11985150009870152981, 11282144500794610389}, + {13999168735732598559, 9030771445951876212, 6423904381826094276, 6148980837201061250}, + }, + { + {14621142736654260750, 1806201536162806753, 12562675185535659971, 5326177198980139868}, + {8675433132905478434, 10796034085894917871, 7562073626744691385, 1491977564717017512}, + }, + { + {8821632341545057929, 16708916351043551467, 9171560460858577216, 5711973041149612575}, + {15808302665077457285, 8412173943543358851, 12602476370021215716, 4778674887660148537}, + }, + { + {7524796586818405222, 5468491023058834244, 7965536127579551161, 9575670558568595724}, + {4020611179055350793, 186082735900253826, 11198349470461895384, 2693853052562145978}, + }, + { + {7977371007734934919, 1442746893361509157, 15080044066626816201, 9179319344686817504}, + {17927184654813605164, 16541635384799094673, 1663389722548868092, 9157422724003022421}, + }, + { + {4167146676307544690, 12042136744739037957, 6606952994938338836, 7554398412699794678}, + {11844277247778765775, 8165791089025933303, 14954338535964037723, 16693854111477654477}, + }, + }, + { + { + {5841260956815214452, 9461234662498869948, 4761949640006529525, 18229823346336752572}, + {16055957459773168413, 4272222475092786627, 18249888117586812770, 4531982814021269346}, + }, + { + {7270238601276019194, 7318279377964882079, 5226788506940171017, 16838449902078450273}, + {3375184937745100689, 16320655850583231520, 2173229791272659780, 9816381971766204380}, + }, + { + {17113448198982970082, 8879656883528014268, 15215762680430094206, 15232212751792759071}, + {13699137317730183483, 11815206710130297569, 12298409691055054593, 2192455093917691024}, + }, + { + {9742819322069712752, 8779224519997661749, 2591205872359340025, 9144644967919881415}, + {10495832103710459914, 4557264342687723360, 935865282128150338, 7120324256648044882}, + }, + { + {4683169301229531061, 14940390399739549639, 13128742567354398401, 15222231511210090535}, + {7352694898928671332, 1221555526903686446, 8697118143614336514, 14515400523185205597}, + }, + { + {10239864229747754958, 12477284975467600510, 14054830413782031834, 17752968481181892755}, + {16082713391521411762, 17191329716867535304, 11245514405315337909, 15159733745232554536}, + }, + { + {15444441705629456398, 12030687282161152512, 16500102437404896225, 11467410246278043769}, + {14031300093087427598, 14458597378298191386, 9434445586505481169, 18221119130471329822}, + }, + { + {12694666558858009121, 10992313774737315187, 6046508760845509477, 16818819584649823054}, + {10464090160691032219, 1221502600750419478, 8658907655588546849, 16110628890984509877}, + }, + { + {14304143349839262251, 13048055876309896774, 8676204847923624352, 8365498293767636038}, + {13565995665971214654, 10895028049457785231, 5911971723937387023, 8436244239466286317}, + }, + { + {11501032393232899227, 3895174794911924947, 3230698222875450976, 7264134402609589101}, + {18091100044992147344, 13252184705645692134, 8424205723200969631, 5731735154358029264}, + }, + { + {12163905774765001813, 3911227235818691672, 9833792088244333742, 6413344327541478453}, + {15325942369130325853, 12629318625161567307, 8784755949357111975, 9462269284575183222}, + }, + { + {2157617452419341992, 3753997642171159286, 6553292364671628995, 4814048166016850277}, + {6152139240994642263, 14066819599579263267, 7377541740373798192, 17830582976167057789}, + }, + { + {6906089045659836134, 17967958089618664024, 13353206790928340833, 14671934547763383296}, + {12187232481950713594, 8718528695481423527, 18137604428804898613, 17758096361511845106}, + }, + { + {17646581888040948752, 8252837592394234071, 2508742924483223473, 5332070238932154531}, + {13165985796861395246, 4409584176627274781, 9230253121183107430, 8784052955551358471}, + }, + { + {5394535031187713437, 5279515585052353937, 14159976884067043134, 10130852155763718010}, + {13777927158878861230, 14015445621678244733, 3350717438960860318, 7071836838770144750}, + }, + }, + { + { + {10708602749843635238, 8046488591192123621, 11391158257016334553, 2512908912806916201}, + {14760224624269838038, 2631910198880826809, 2387247811669872033, 2048193899742148806}, + }, + { + {17392983665205025720, 12603331233691760840, 3752711326309791976, 8281544857330094164}, + {17004651346561270106, 10399322540256775923, 9721299450284863176, 3725182263994944884}, + }, + { + {13643198694788276032, 8127425924819487897, 14165945065582850538, 16520977003164405917}, + {1941948502806705647, 12390949208067741787, 17112117376594486408, 10232906951259490042}, + }, + { + {74190110112564319, 11227229657066745164, 10151080599595091944, 16591051376074591375}, + {8256332495682655293, 7127985739945537626, 5708687346183367016, 18310921046455023281}, + }, + { + {10040565835468209502, 3986586816478505371, 7957179672896506016, 13347112914739722590}, + {14099734293320932556, 13921950344400895005, 17478414833301838037, 961445463330402797}, + }, + { + {10553899634420153414, 4215979268474142438, 3643081140297634139, 11620906704125380460}, + {17733628678553828301, 137473878710304143, 6211837577294956591, 13926110616399428016}, + }, + { + {15203257341351417031, 11597829209697937782, 17317571979811895272, 15929491640570317745}, + {5731227916276913121, 17093153916149088230, 3908757069480556294, 18211818355208735794}, + }, + { + {6887629766078662088, 15330755394432598442, 14144608177273202986, 13258654996547018856}, + {8975611270007504091, 16869834856279102361, 12707970875852047823, 8520055680055874514}, + }, + { + {1643407997152867899, 5400650551136488814, 14663391437159245064, 4743209938058826866}, + {1728998201888511561, 11238331920657195520, 11617984741897247805, 13858029141809651878}, + }, + { + {14003691155137683825, 14641672309228817657, 4031783205073356111, 7414359968614421153}, + {8166814052414482491, 5209260157266028169, 17555696996149558694, 9780166780476833956}, + }, + { + {16029688335186691281, 4244772808651443261, 6450459413414527821, 695875191412722741}, + {11104054226249884864, 146461617619843327, 17480214580411209436, 11285418463967817315}, + }, + { + {4922928863857449168, 7226901725606965824, 7568276305032368752, 6253457805758596797}, + {14345040877576203078, 1718759302498746946, 3544444746772280646, 17880302727399449566}, + }, + { + {10693864548794383214, 736148233485985101, 5241869061152863453, 7166954323782542739}, + {16861482585847848251, 11483636939866570861, 5950529069765100144, 700887039653157350}, + }, + { + {3906969739692830848, 5546431121705298614, 10491799900914853406, 5871175286230239238}, + {2851574662174517162, 5511397532379144624, 17409985391224790540, 319012646822749823}, + }, + { + {15269778527761027251, 16471737837294177924, 8830398856035267114, 8206807757132984992}, + {1421214226977370752, 14233751335943482739, 9668238787333455452, 8700964319357541954}, + }, + }, + { + { + {16477698187919702699, 2757160833848759781, 5976267476122243443, 7375951277779829055}, + {6525111513935493528, 9969722922172879681, 12582700753056539952, 3861958159147836631}, + }, + { + {6001837395299394988, 7545846298204709215, 6662102781970969966, 12696054550672669874}, + {7436995610194789060, 9042605089262227561, 11621508125069628605, 7289479057360149973}, + }, + { + {9447061002880879247, 14620964119546151815, 12310553083192998735, 15923694411935453454}, + {7392925129127637753, 14135139889986895975, 12760571438361221130, 17000514617803354735}, + }, + { + {15555649500689005370, 7857014165815014600, 4664069234996337119, 8058230521837307501}, + {18090421626009183450, 9278179697462444898, 17138879353097908770, 18285223269807746171}, + }, + { + {6099842409325199202, 2732701612070195412, 18229871238556385053, 10275023622778520796}, + {5986266691884320152, 9796109565274465130, 8132405984970989382, 4521405733027618902}, + }, + { + {7427469853953577123, 9581104712231034671, 1702722776800247878, 12656779221313783543}, + {17977155285174544822, 7208039998659519604, 16978428797146101290, 4487821481774245164}, + }, + { + {8040999562333134211, 6854344540855006667, 2481534773419348751, 15571316619985340537}, + {10089854957334316687, 4775911690791701632, 15619815835608539594, 336338508421162031}, + }, + { + {12741225973381753432, 5461579923265799106, 4348015554411389960, 14970536173310927872}, + {11568371199139699619, 11748662751675667230, 15495664823061891700, 670495577617908409}, + }, + { + {6065163107315563308, 10179715614080542168, 15046885616273736618, 3965401047645186422}, + {7013093813183571821, 6087826007582017410, 14469686436525543908, 9620661780899615891}, + }, + { + {4469547109588409455, 11124190799085603197, 7471495874998642156, 14754586999614006506}, + {88849924092797594, 3031352551776027825, 15701321561580429717, 783416358537121491}, + }, + { + {16899538363784443428, 1224176808212436099, 8044883358999763192, 8119246882922976226}, + {1602185320898819533, 7795133078900055750, 15379182653822915088, 11717676755990779936}, + }, + { + {9865772269601493999, 7325690007062740244, 18437964667185475354, 9546360111100619473}, + {6266116854923135821, 295905071295541234, 16037468634731642095, 16602609756229843150}, + }, + { + {9871952371310035629, 16929106233175362415, 3445554197529258762, 1598752868683659684}, + {10123732080482057842, 2393692486932623922, 2380673894473467164, 14578017559552626408}, + }, + { + {16688239163561330036, 11170579336923472003, 3699145675255553709, 3266133724446548264}, + {13646430870088709566, 9802235972068927845, 4016187574117121322, 8646347483626678378}, + }, + { + {3473609455134319994, 8666646689587058890, 10588670228528079578, 1636194164122827747}, + {10443498896203771168, 1711092164750178258, 3641509682909832777, 11037852869436666140}, + }, + }, + { + { + {15254713655124736464, 6283719686609422435, 5417864180357938798, 14010638809605797246}, + {10873690600705871523, 15014239467130590294, 15765460219545280655, 6048061577845125750}, + }, + { + {12012729503226546642, 4811951115754240681, 2652621264600062520, 1108958391967017223}, + {2508980100759035797, 9023233544151778447, 11183557587641545146, 10726727280840759519}, + }, + { + {396296174223428093, 16763788748988621834, 10606803701784640909, 2399987183687936561}, + {3641562114746393614, 8536687357022564742, 14532545286961725758, 14658331097531946901}, + }, + { + {2386026063595321071, 9144724461940169335, 13121187420621518554, 17351696676224980491}, + {143495028693925520, 4590642171152119027, 8655406817079059692, 10005507077955932112}, + }, + { + {2047964090310465728, 14133690277069748515, 8287749071957055844, 16821270580974431218}, + {10324684883587585565, 9652498187344172497, 2461802306013063247, 15048850312040680643}, + }, + { + {105705035058376953, 7541598459498134635, 6627685529861836787, 5724525771392188178}, + {13865897118300842617, 627652561624109853, 167084371112939132, 14192831153344015422}, + }, + { + {12837696619944805389, 13470316523008526719, 3074966674353053986, 2630814767089382743}, + {13353767941686870870, 11405513520090968568, 3071969598389884693, 8212421686942839224}, + }, + { + {3464453985305889088, 7486900500389940957, 8944303108517222303, 18319933556403836918}, + {6782476025105836770, 12822840946923377510, 2799592944286097404, 8737598030273298051}, + }, + { + {170025682710985810, 13049055489275530431, 1714038719952287416, 8470425667049459662}, + {15692449588624337561, 6306908925988159475, 7292362624201217567, 10084542069209889549}, + }, + { + {5788423445465760069, 7489854375947810149, 2512436350424132958, 18422682564857699600}, + {5177251288327577128, 13879051611542381588, 12430182880452441435, 16367520376757404605}, + }, + { + {1828702178325893477, 504110179554648546, 13285173922848349127, 15811513724231368560}, + {5009291056218383875, 12726125712718222937, 2511326207435121241, 4878070763721166868}, + }, + { + {3151967592390934907, 8745573685636820318, 6591530195811780291, 2269684725432150574}, + {7575618284647930930, 14430170051221190457, 17370623489799706048, 17190167628015666439}, + }, + { + {13971505255871035961, 14447456703883945351, 7749508685925819836, 12281701633335081378}, + {4638096293890044597, 16388439049639616700, 2805317369196495081, 5611057071508020450}, + }, + { + {3416635149605340108, 10996030428276056653, 14121021550848949146, 17748729969482499931}, + {12079053778595035959, 7473419378019222577, 1862205264236631673, 13655366704192015583}, + }, + { + {4817911180954611512, 14468615228783100826, 5900448495927012352, 2522071476550218088}, + {15649024877429766334, 3445298745493942789, 2295617386899137580, 18376023059372246253}, + }, + }, + { + { + {5228416958727036186, 12534300056259911378, 6859045937063682340, 16561718753727911412}, + {9427589074776024847, 4167904055656501509, 10156691045253563236, 17557096561606923049}, + }, + { + {12847261474293104380, 15935635664155479706, 11956861064550631146, 11743590506948225647}, + {15973092866215748716, 8269726904881958353, 15639962392523441528, 15171417818360069012}, + }, + { + {2605212343977737441, 18393471024186189813, 2302707671753008158, 8606549841034095192}, + {3842822953634987820, 3094721493917442423, 6408313759447502937, 13486364200254727287}, + }, + { + {2191808101092881088, 128992526124656216, 738676021426139131, 10157323147642681558}, + {11221959943853120586, 18255489816550713347, 10885231659068427649, 12104397395119665023}, + }, + { + {7707807226411417919, 16609863548699265350, 17639371636697428128, 8755472387723764172}, + {164779854477783265, 9714199241756765614, 3491355372893948450, 17683742455036967163}, + }, + { + {13595758632462338296, 14515163666150177917, 6720823780841221770, 15071435664343609336}, + {9016075014492765983, 16881277609836316886, 6969993988115170067, 15419704786434737070}, + }, + { + {14933348768149415725, 8499210770493553168, 6778840616148281272, 13282837866452012488}, + {12007326272174861053, 11172739862019218274, 15202495365302649711, 8797477675597086120}, + }, + { + {17862558746132168231, 4941846130090682869, 17131557654945008226, 5312800819142473968}, + {5818269467205924209, 13458582047859447022, 2683428091382447153, 12956887954464730664}, + }, + { + {11820752998821943867, 5623379642132478491, 11666807493120740820, 7241997274572162616}, + {17165010508995490690, 1769225877906480182, 3814296306467163522, 1913823003062817434}, + }, + { + {11936813336110488997, 3878433838529606580, 6540053284493149566, 10610279324743393563}, + {14079852809920102066, 9176732841330794388, 14287311909822853963, 7146204303626670196}, + }, + { + {1222343790928490335, 2199405396044383670, 14080919887213592148, 7341303626667347624}, + {11784881532696657518, 17307742911086150556, 6036132721599132043, 12167106497065306941}, + }, + { + {13817073203406999359, 7220729284169210756, 14908407498603601482, 13536224989620701632}, + {1615171540711527931, 2063856048260214664, 10622581435417474559, 16378505765730768032}, + }, + { + {6855676470217754770, 9517149712286624325, 11080380031068971680, 667425509348698033}, + {6136243307299269825, 5326577850303193160, 16120190278345757447, 1982981965726975383}, + }, + { + {15399454106099176868, 3988744407816581672, 3596277710300384050, 15129113714633923498}, + {1554582462382333698, 3164553872715651710, 12729140363982748426, 16366728035709811784}, + }, + { + {11647936211409428873, 14704462653811533865, 10005129575282387925, 1526194796943187368}, + {10906326807488904308, 18256878690674435807, 13093574545395154003, 12352810226542367406}, + }, + }, + { + { + {17055119974261943875, 6266720893662254540, 13102139953381148874, 5249314164321788611}, + {7157525732140787612, 15381277459195914226, 17265025258266710353, 17573500432599548120}, + }, + { + {940679263188661008, 14653357165718140350, 15439920797347843673, 9415587255510557494}, + {18115037054677722678, 8165849408798239027, 17369387099667572407, 17619066457126678815}, + }, + { + {8649149223282317557, 7756351751136698462, 18239772072009739451, 9817506578949224559}, + {18378033667730800420, 16794121140066562876, 5288247581483071333, 12402303517382928119}, + }, + { + {11047138821675365077, 8918121441180891972, 26692501222219426, 15248413052700323978}, + {7305399157133896461, 7065644238942265367, 3949166834387057064, 14178248206708015607}, + }, + { + {2031270890855333638, 16982096442429440651, 16686304398848635900, 5829842366016448839}, + {14111080098472974183, 12565301877743332219, 1685254887702201709, 10638099573980009130}, + }, + { + {9618597135962048429, 4323708363301758294, 1934098864729515110, 12038442338797726450}, + {8373847126955513333, 3300151407444969023, 15888126952439796914, 1426880256839266097}, + }, + { + {6428576619669681259, 7657770350257045071, 17839413659396163406, 4702043961312931605}, + {8200928556018997183, 13282376860743810804, 13005614455417667639, 17419029631791664639}, + }, + { + {69860179712677448, 15464996655458230480, 15095351218136595554, 3792171085643513009}, + {3187131848664503636, 12713332789590787064, 6278731049699775392, 1597379696359884724}, + }, + { + {15673011075664376010, 15519225812231888543, 1336371877669824820, 4354970830277120843}, + {8744720488959125220, 17541792919601146935, 14299260104084112815, 16082554294713598652}, + }, + { + {13540612390708052286, 10213354985487483900, 11366371415587713866, 10334937577432263044}, + {13368390835254255145, 13453645319717588760, 6303196127329783110, 1204334422768264234}, + }, + { + {18221540219239501535, 8536815826205784644, 17328509446048600304, 13923028809228258331}, + {13984621134784540482, 10254983270679630247, 17457131706329229663, 927850905006752032}, + }, + { + {3952205381894147962, 11371446109407143937, 7231851263356642380, 11612512368538303138}, + {5227214975837085115, 10737565048439707166, 6333629542995218640, 12386725921557807638}, + }, + { + {3772067962000745672, 4436468403847408320, 10612599615182677580, 13738755391074136269}, + {13665557786177426407, 14568219921857752, 2691062926825113708, 14666515738377567975}, + }, + { + {5392936538333570234, 10526292103645946001, 14132494129869423619, 7207059073717065545}, + {283545293669631007, 15845011600683983526, 5081287846871250008, 17931854980704528162}, + }, + { + {8364400939527235175, 7959571573625351093, 15849019287994534535, 6982609389731776566}, + {6287382484291579264, 16496145344132275167, 12062306229709713775, 312030175316686885}, + }, + }, + { + { + {17224650011872599657, 11430188086182976152, 12892063618843720029, 5912993124689510433}, + {7069617917494051681, 1298012103142698333, 7943359430865057535, 9329776843721719539}, + }, + { + {9464085603669036454, 7848014338005901108, 2368914226155404065, 11578416111848517850}, + {6323647866244499941, 14399589996703947996, 2824522520842155768, 391310842153371124}, + }, + { + {9948650801233133770, 5836115460383443197, 11404170696974449207, 4791020823967734476}, + {423024247809958592, 11251668387880260801, 5562546584223492723, 578572156618131794}, + }, + { + {13988854693674964723, 10817154032069031941, 3171651998645961547, 5518712225783687705}, + {14706905091132091970, 13960758460934966876, 12141035142079693145, 3149939820435101269}, + }, + { + {2505301881938098126, 9962323478923652140, 9312199523950444342, 12957822502673689705}, + {8060810607849163143, 737408553843844193, 8143568733429881786, 18003168270780769476}, + }, + { + {4460927228453411137, 16058422703785787527, 8016770980039986075, 11450941100964860520}, + {2742597710491507274, 16940752978671801273, 5897441526901650840, 5926672707007682446}, + }, + { + {5772778048593061508, 15424756817708323928, 11842041259277183807, 17669952685051160523}, + {5405007811515938363, 4415223809135251038, 2223192286456742546, 15742105795795272774}, + }, + { + {11809342655313500273, 16822704101813284237, 13097372075606737923, 5463281428453250615}, + {11967866991673525562, 6828790575157689223, 12568831962097805646, 8385980093725157349}, + }, + { + {8090324765778815982, 15997433100218204643, 7771766025433829989, 914551143312324786}, + {4640358803642182649, 17428148208737756210, 12144967737399770998, 15075125743380741412}, + }, + { + {5954807828598238451, 3186352433639831389, 333598278340882889, 8647732331490039308}, + {3706589107409903019, 7338319463305947507, 3829684452513478938, 8551967121356509963}, + }, + { + {16753777599759754869, 12028154198579512953, 7911616552276519044, 789841268294170739}, + {8228995103825761982, 14293958931719060336, 2778055819582565008, 1399082948378499882}, + }, + { + {12492565198527218900, 17337285577296730202, 15088344513573802417, 4272568906387671217}, + {2365541522321646412, 678395397666822608, 437334842774934301, 13443327606166079837}, + }, + { + {1266313952277763194, 11470850617813390661, 10426389264474337810, 2996447663006153747}, + {15218295359022152122, 14634539952819815592, 1775270187047190460, 2942637199921677956}, + }, + { + {4952377176677649521, 7473631065005310719, 7363684030854414233, 12556891399998587233}, + {2190850394642244911, 5458637782288631421, 270926994697866523, 5528436328062366401}, + }, + { + {9497175173535366966, 25345745857275253, 5047829133239508177, 5340238103822773099}, + {3133339556064328840, 666970525709876149, 15575505473500291502, 12769675806855640654}, + }, + }, + { + { + {7669790431656261769, 2776517632462593286, 11694025667665633506, 9533794089008895277}, + {2895611631120558023, 11551410655448788956, 10026541900772270925, 6243136875017000843}, + }, + { + {9434484992529186384, 16435748047660609525, 16190660694150989986, 7083965852434071085}, + {4216306437741910756, 2698742177539497614, 5199793642504009017, 17298424769819019160}, + }, + { + {4041169394784902550, 5699517344009382913, 5306272267462320559, 15846674482556330025}, + {2606351264228884283, 4162585980422107281, 3715151019132039005, 6607223447043258693}, + }, + { + {8168579295855409503, 16727569921530031841, 6182114460261837773, 8940603165471931374}, + {6081572078077526926, 5890840443923124563, 11215305828294759727, 2875117534361804712}, + }, + { + {9045974983664041829, 905036705033699463, 6962033946652121779, 3027264198782618401}, + {13786415307358010100, 3643342525745067473, 13641958783381681886, 15675065537779359584}, + }, + { + {7507377696839752642, 1061259379811757443, 10276590160392917813, 6889137095037822679}, + {16373913505782725550, 12287733095803524526, 5695917172259210496, 6360958736925918808}, + }, + { + {7459854586357006968, 702429387211615855, 8231296036461604410, 628323703857882004}, + {1059802628602873385, 12517208225099517507, 2368172548334856593, 4792344750094708709}, + }, + { + {18352334786472886037, 7096021570596476676, 17045407505128867173, 2467670847537319400}, + {2225663888244226889, 1876713214939672742, 5329943993157142620, 12168650975912182188}, + }, + { + {6639850268372381409, 2284514769224558945, 15390110317831975716, 13933785559694229008}, + {12787641603764341997, 793886210532292741, 3222136169196008839, 11104892506868626444}, + }, + { + {12660547967989039787, 2109392063597767300, 9889743271997754037, 11803327596624324036}, + {6940409327849314286, 1466399127363116843, 2572333022681966275, 4216097356402537802}, + }, + { + {16858757460581672909, 5838407119753001493, 4453405435911954669, 2828665451507432751}, + {13657966632733241760, 6875986784381874300, 2390233934255482553, 17386653779125555159}, + }, + { + {2976756344404126744, 17032556609402836559, 16348907464011574182, 2196781021202618892}, + {8270822867494340805, 4738372358350764889, 6088256422707334932, 17121369334507507505}, + }, + { + {2081729301541563384, 5577186154173396778, 1865152567701500436, 1422284589642218069}, + {2489023909725140903, 276494395149046869, 17420927169263487236, 8292343688801608074}, + }, + { + {7819174654675104600, 12778055482430336726, 14615848543490171611, 17498415175263742825}, + {4785899184222234034, 5227136636239697699, 1570704808469050246, 2858953380860123257}, + }, + { + {4323577007857413306, 10524228743339400397, 5418808897687027557, 5939367271366264075}, + {3569359126353670574, 12961495213964770607, 8906990808988099905, 261084295374207271}, + }, + }, + { + { + {14408045416865494124, 2442199381796557002, 10475326303775862953, 13637445125954159957}, + {3778313603630758744, 9247460369874272772, 17572237597883145087, 11338350096360776602}, + }, + { + {4336697789732072031, 16054848662858822197, 17934449813415035557, 14518380622432694666}, + {14100582434152190048, 6262866632984449325, 18069160441815400774, 9798342103009260692}, + }, + { + {17244020587062193870, 7625407515295016845, 12692919397126044801, 739129074276464779}, + {977900962655641355, 1516169712468716336, 16875961107875019625, 1582931498538195018}, + }, + { + {687104890149081183, 1938816743979859301, 11342071981175913904, 4270322127259097184}, + {4964776270155503160, 17849333582861534767, 15814479527332819692, 8083943565773123408}, + }, + { + {7977186743666958490, 3126199553548085949, 16879636338977836444, 16647578924708995556}, + {5526017172393528596, 11328754652335568585, 8095074058116436597, 14648690727521713743}, + }, + { + {18335678403814425235, 13764304056086998207, 18139296224460762074, 17620705673387523052}, + {16059975647897396183, 14392541906869470064, 13641721532745636092, 6122032872822720831}, + }, + { + {13983401929934353021, 13860725962778449344, 11760533704789481157, 12566657951327299627}, + {14697122142882732522, 1606632877136342124, 7872716135734366961, 18220536079227927821}, + }, + { + {3986890035154628803, 15316660330065019741, 11560940574529263780, 12576851520091035878}, + {10883944418224886092, 9908329441525486205, 11238684990962507809, 12900626758810151662}, + }, + { + {2629393050548942288, 6363222898077806203, 18404650886731368903, 2691451856029551156}, + {5104932743043229112, 1302939624985069019, 11820239270922660661, 16228045717328023331}, + }, + { + {778457530134061801, 4290661013056586404, 12033745869654330486, 17833837257536520292}, + {950548111600899172, 16026254932420015523, 14620989142158250051, 8236598933984161995}, + }, + { + {8828068000936861634, 10901971915827198521, 15635295283164640480, 352740455954411610}, + {4853015383138960329, 2945696874639059776, 7204307993540375148, 11980890732241054979}, + }, + { + {4077800412543228484, 7173833470188867493, 4604439809988262876, 8090706047559948234}, + {6117166546062912279, 15748537214854486946, 16719594636199001564, 563850925691991999}, + }, + { + {4802884399593912281, 13437020732272033050, 12197788481695720547, 2162699662292229581}, + {4193517889478995518, 8610646873096992408, 9485787089338760040, 12392145097158647056}, + }, + { + {18079795516810465755, 15723042000668265475, 12488322519570427659, 14012836221417650412}, + {6534900133691249330, 8115921632235353076, 4093907116172233459, 16784728000548766561}, + }, + { + {6262200118048820167, 12719453838344002789, 5526427573572313315, 8520226123932607126}, + {3618116539863181413, 14020033065434801713, 15675496263723836857, 11987954535452978647}, + }, + }, + { + { + {10847249691051757241, 13332329214721571156, 12457628412284474075, 17044657510482764070}, + {5218221397478351943, 6922630493693541156, 6207927102810766143, 5644846665334649748}, + }, + { + {6506371904134856034, 9541373683805144018, 3149037850125132851, 7111810601994573897}, + {16732445693192247884, 4994069681898274622, 7223719243730104348, 5649174084086150712}, + }, + { + {16562962997045986629, 1977585352264948582, 15588655103333244279, 253344970359156714}, + {12939363813291366775, 12548224526376199974, 14450582788883748364, 5869541533939881460}, + }, + { + {13970586842647892965, 3680317572634289692, 3416494470839852757, 8341497967750607131}, + {5522860734580749818, 6847292760525096386, 9317394708872196559, 8522252330730808934}, + }, + { + {6838341670149165895, 12326189699069923388, 9258908232339348843, 17297038041466207989}, + {5242182985453021593, 9648294165629935142, 9715128265517308395, 2662662536493743894}, + }, + { + {6790869670806738567, 4499989093713728199, 17496748050437205626, 7194829324969293638}, + {18432532588985091708, 12041300075343806904, 7788543067151959941, 13703334460383638224}, + }, + { + {5996381448168274884, 8108757135223610234, 8067369725584584297, 7184925262427750366}, + {8199341143188441284, 13031376443169557016, 16036606349050125404, 11958720833222295864}, + }, + { + {9293668142017263584, 17134656749295164870, 5879480323258506465, 4788695233340705697}, + {17809277710857366810, 15157733645094688870, 14143869691462709080, 3162286338158090229}, + }, + { + {16056959590901591813, 1082823161154599460, 10221040439441372421, 18283403891485112294}, + {17582486701671091218, 6489397700174053547, 3952499348250646760, 4381145145005361247}, + }, + { + {464321249842430028, 11444362575253049653, 2734975360475017776, 4746579078625212558}, + {11326126526565916100, 7840007639237722362, 7545779893877671555, 8952053274372957788}, + }, + { + {9171324502111757965, 11245577625425383295, 15294815109909975990, 12306264653913762086}, + {5906268309303228662, 2685370982867857233, 5470203265560800284, 1354105134944127233}, + }, + { + {10610818607308010986, 1017341076592473937, 13259969743043862138, 1850907007366751943}, + {7689302552902672401, 15375957693502270090, 13877050204486881614, 16441247744335371320}, + }, + { + {18161720198110725057, 14887135440336057963, 6790952723850964648, 15120775513153544155}, + {11797493458812299470, 9090758778610315656, 605835259544633945, 14755333155432393992}, + }, + { + {14967102006962978091, 4301508725220174920, 11299977101982031802, 14410789725331022027}, + {17005709003661351591, 9843840931527318478, 11917612896070173894, 12007179364072802553}, + }, + { + {15913542135925395264, 2830138374220921671, 6395020779026969444, 1239443258852925290}, + {4519359001030231260, 9606729174209623750, 14291346135557028396, 16179513817501558495}, + }, + }, + { + { + {10223936123327786454, 2321887803300626936, 13607747528117965743, 10456421630388400123}, + {3266519591187534953, 1053691207967834494, 7151443045753788549, 18124688636664828399}, + }, + { + {6946488664257064464, 9775328903143754150, 58700362449753229, 7901817271072273406}, + {5074738678159003249, 18397239731906005785, 15911102965988125888, 9277654580204145348}, + }, + { + {1874700306906525099, 7337351570334852732, 7954195906114335343, 17230226427261850070}, + {5181329498860909261, 107167242193237170, 4364856176182710332, 14611171841443342914}, + }, + { + {10990327814895720476, 16588412771027628390, 2850177278998422188, 11569813740328484871}, + {3922148781422941186, 3581659216490446242, 3646872304052351376, 10887870617200051198}, + }, + { + {8175121141368087217, 15079393830876652065, 16766987879267543828, 10582796406546815217}, + {16832256009371376870, 10042650470778064892, 17867163453935683780, 7123418345572641116}, + }, + { + {1782651072016504775, 11033882508408412333, 11105300284232190625, 3276372405089292929}, + {6399472468041061588, 15319690780388315076, 4928530863063375966, 11596222198340277418}, + }, + { + {5452424185619067445, 12050433097586021281, 15018766900844679217, 273234254926088220}, + {15426383635547379531, 5213762666043737626, 2829185842069118470, 3230799283770935127}, + }, + { + {280030342772428106, 17354882606189694746, 17455445295460080284, 18076709382926018941}, + {9895982528034548913, 13681172423928175330, 1656433131309057012, 11935757350437721114}, + }, + { + {14437472586336929440, 17387041914242263390, 14861577074379746687, 5146556788377906297}, + {13036814755814090195, 15108836859245573802, 1667563994642521213, 14722845469958372258}, + }, + { + {7781061995240980266, 2066078418484154391, 4089376589847114892, 2434843609506038666}, + {18376509832460312721, 7187709121160627756, 2455436656049651823, 14419116837518875372}, + }, + { + {1270185079976403265, 9214436628411717184, 15450450827683432913, 2880014804806096082}, + {15448799931519826757, 10080240282127928735, 10673974088219619287, 12998944469117087518}, + }, + { + {18028691745165748687, 8931519595829275195, 18379893031942930865, 12120980098075498008}, + {9596371470855895261, 4133427878071274570, 13159312399982591699, 1639865074052258019}, + }, + { + {1661696187746428348, 2656198437014978712, 13769477291975851694, 12512848714492869444}, + {5980926616932344693, 15821983893144953005, 5816015630031200526, 15887565799959254415}, + }, + { + {16463929919291729278, 14920112063826664828, 10056471508435050704, 10696267144984026763}, + {12049530292963090991, 11926086636123189182, 9464890378472966538, 9719194510330239601}, + }, + { + {18110249193861022779, 5612784685592189906, 11360454032996393150, 6795401682138043705}, + {1961398978248902107, 8999847457729547905, 8941741619641401180, 6086938661427918241}, + }, + }, + { + { + {1119490156854665483, 16772836556735128526, 8607715508817325509, 9931017263385440911}, + {8799481055779587022, 11740562709785257943, 1956849872282864970, 595288629437737005}, + }, + { + {11601570184515356415, 11247678357869162156, 8415095559389686315, 9625816053586466047}, + {11807876143163335372, 15690209134241397733, 8684637224468015605, 15974968144193406020}, + }, + { + {6498861108824484382, 4670555282769381189, 6606014320886832914, 17078765892830617318}, + {546267528591230105, 17808649363082080722, 3219358059129920687, 9180845247506322192}, + }, + { + {11275984449259340674, 14922638629881602958, 17186426309348732477, 2094500549052461127}, + {1245672419927595636, 7529921141299797945, 3181089597449057707, 7749529014968942143}, + }, + { + {11277133910568934671, 4278895672933635880, 5062049475469993812, 2827897582327968966}, + {2992831031801695571, 13244636528396736375, 11509629662092358067, 9385849226639579800}, + }, + { + {8454236707620433029, 10192313737667573051, 18232259474515025711, 6196538652828521245}, + {6326999652188467228, 7611130140249634596, 5729331023083628955, 9386297316005425714}, + }, + { + {7621274909358193632, 3619625095597194913, 18038386254997645285, 17262892689028255302}, + {17953989125460428814, 4571031913557658215, 12218524221515562809, 12016327352942264220}, + }, + { + {12842581296013847382, 7845624487558348664, 8747439372999364825, 849305823897878133}, + {2217292264321907974, 8173534404179332054, 3588643190593022889, 12047811416592660080}, + }, + { + {8121746263843271081, 10363835147942471345, 312023379108980148, 17191823034761670562}, + {315776409136454719, 8322002171533871918, 659256727451485128, 6073539214057006838}, + }, + { + {5999134638957620752, 14196265207258829507, 5400793612736232063, 16259338359738368573}, + {11179852704740695306, 3486799782309774463, 3060529319750906379, 3540275797284687957}, + }, + { + {5485176043812882513, 10727553589889164848, 5617457077214333092, 15937493816713568462}, + {6287330459840726949, 5451240171054977850, 3524414944972920777, 8740440597273129486}, + }, + { + {6959527445237219799, 17170778245769606301, 807762173031474321, 9151445233487017286}, + {15103411489939446333, 7976669669591851659, 14824323986579638641, 1535817133122800221}, + }, + { + {13993486080187419934, 14882121651768660644, 7947881871819932407, 1364312030151957949}, + {10673187305202558690, 15038997055055408315, 9268330880459316485, 4319340556575124142}, + }, + { + {12846922591360496097, 15518450931549829779, 3843880753372237176, 11741559986398913430}, + {16974382348775305594, 7085384294841794242, 10278478682851578175, 16997904984485898637}, + }, + { + {13670930062027115328, 9912297966339314023, 17061419147322177635, 6220676237879734303}, + {12723388668517709225, 14967294924815531226, 7286002704046609276, 2105494380036834916}, + }, + }, + { + { + {17955247196574331290, 285928599571507431, 11902987704297070981, 2841167725097799100}, + {9281167410796848363, 16444340476026142274, 3423202423051178709, 9101021305726472246}, + }, + { + {8869273893561412239, 10349812081309865197, 8913824872487209090, 3148808685596180274}, + {530908416884501807, 10284103744075805979, 13606889938905754722, 2418062398586758364}, + }, + { + {2298603653884322501, 601221199968240092, 1285112712738261659, 13882709760355308533}, + {13563254433762438170, 13447718334658435053, 13493687958886238103, 11032778298151679283}, + }, + { + {8626760324117733843, 16403951745962159364, 5837394731212322914, 6847167719031297053}, + {2888142337636247281, 3409818743436360750, 1677113113408664401, 1222157560539217476}, + }, + { + {2294668553308381923, 17165287249067859297, 9897724011823072967, 17409851874231284314}, + {13888575318617508639, 12092766090379658603, 8412268183255186961, 8046572777745318483}, + }, + { + {13178439025428734594, 16388038968589028071, 16165750006742628176, 17903639397633243161}, + {9560319088110737392, 7888974492854359310, 16116323630343158496, 10177829649622711030}, + }, + { + {2378363646789710539, 494954399989334038, 6915496914984330558, 757197055392642378}, + {9097171378505823650, 12104288338329241488, 1905673690814481722, 13011078677095066032}, + }, + { + {12712274459771886808, 15748114764509451764, 1994630377849062253, 564390855806287868}, + {135493276425567450, 4305883520257541088, 4842008929542073044, 7035106970720249617}, + }, + { + {4772079965696324995, 15925041062593990538, 2818172089014580505, 11304215074611546986}, + {10130691823118346040, 11796228810049908587, 9262801389703476249, 6629344122525229781}, + }, + { + {11045983914861167112, 14106148195606833916, 4442596873181225087, 15627975325288846806}, + {8173496855557146242, 6061080385918934423, 5233260187121969538, 17554093556474728494}, + }, + { + {12122792368758575262, 810814789452398299, 6387727669765211854, 3304731719391402237}, + {15296845834923103160, 3685348582131767195, 12636335057478947340, 16971253767099552987}, + }, + { + {12345454807632743424, 11546569651702761483, 8873100774001529421, 7001975923028025552}, + {8129283832066039281, 18147888225504425296, 3510907297028745651, 897602195837260824}, + }, + { + {17896345382362222994, 2167374959533815311, 5029128091600127895, 1770543276160593316}, + {17234124146043512942, 5338191548265818047, 15676046602975694398, 1943153641089805200}, + }, + { + {11084819495273800718, 12966507689731825252, 15026437832429189138, 2506312683689776139}, + {7417463323869895004, 9819555221238697390, 1250200244896601539, 1394555910521460172}, + }, + { + {2221512141494043286, 9203854585477888176, 12171379127551511504, 10667358469120985695}, + {3795093165005123272, 6129005969593025264, 8738204659003189419, 5273583671698415302}, + }, + }, + { + { + {16549155412115374305, 75977962737081600, 8870825488941031605, 7403557657089993256}, + {5825394234709429518, 11978746413791918409, 1876293130790608838, 9416631623519692610}, + }, + { + {12346821858361333862, 6352722970730511156, 9920942104315084988, 10492373916708072181}, + {11163323626947992791, 17035282992056675772, 835685192553490421, 12792459312570503983}, + }, + { + {10447922451077327640, 1515090998837129975, 13498807582085718212, 1212623301098019779}, + {11573518650162536086, 4823461685803772444, 7289704908733783271, 13167881392748327839}, + }, + { + {16959954449957105311, 11051594981465026138, 16062472412226411858, 1976004115345602080}, + {3630495248560019222, 12698191555196404138, 10107923614229901155, 1597725222698864118}, + }, + { + {3416019089997140849, 3011417601086561495, 6275242351124667286, 14197557183081060761}, + {5633711018871057458, 9723496411345030748, 13910057756335530832, 7285051335492395815}, + }, + { + {16774605620279328247, 10223834398868957807, 15781733027568799739, 2607095622729296315}, + {16499590296954181006, 7576646116121533069, 16638313875339315529, 14296194207652471696}, + }, + { + {12874411821611501068, 1998417862388106640, 13882642435422318946, 5791129521978463837}, + {7512934139125398199, 6966283273373526248, 5475728301311080129, 13542211842758381589}, + }, + { + {7798993150530415596, 3288770257171840452, 13373286069558329631, 9784279046496345014}, + {15725032660238528813, 16038931923358478835, 6921788930154218900, 6093507035435214187}, + }, + { + {12194839527972802101, 8376199250979271449, 9055995864116790217, 8125030124567662718}, + {1070812422878398727, 3950906148308170707, 10121516919638719072, 813471384549762068}, + }, + { + {7610605259962047827, 14617655900985224117, 16089669078196617440, 10594009761533811214}, + {3425971360520359121, 1245021768718221594, 16690372892586114152, 9933179766195044175}, + }, + { + {15142732720676276463, 17435583143726694663, 6030257647680338377, 243683009289621849}, + {3064238900429394982, 7655019927497549159, 4484400084400458429, 11650860345018651068}, + }, + { + {16203650576183697977, 17614744533772112337, 1119292890050870301, 4574885263986729787}, + {8108207498737924504, 9708434439316056191, 10676823369888368482, 1078311554675991883}, + }, + { + {6876202174636220158, 18057502510666060150, 7821730895845187783, 8882321799602877790}, + {16220624224336230256, 15562800387021280583, 3043825293109091520, 697130162105054983}, + }, + { + {5394549491776704087, 14795348078061113966, 14206080764200897220, 4623073019242398493}, + {5850602047109930316, 13783531993760979209, 14764346975698048641, 8951680172224205890}, + }, + { + {7302725075484262769, 12572584665857403749, 6499691362933905099, 14476353114356185371}, + {7381716148644532401, 1573798302334388880, 8128390307766282880, 14547454176248589604}, + }, + }, + { + { + {4477325369345373420, 299141931133875776, 6787652129916359301, 2498016036564260464}, + {13342319943892943548, 11124287719737492205, 2456333599771808442, 5084719026388755304}, + }, + { + {12246932755942887931, 10842213418139067847, 1827392608284960926, 6961756951208563550}, + {14626966634382828071, 12653808277900379805, 3359368990539585596, 1190255644328095727}, + }, + { + {14845756090430871381, 1260135108359348096, 18373249503604334230, 14931345532671487262}, + {8304897926217252744, 16639705302116302354, 14578633917159176703, 5624357498623418462}, + }, + { + {10836955050615624183, 6228108794259714192, 3769609579318360527, 1481673673659326756}, + {301329772189110029, 3574710782304999603, 3037244905687722509, 14442941761397229485}, + }, + { + {3863379967423475252, 4598414140150397553, 13498347034161095546, 5995458763090398343}, + {8994138995797612256, 1053878477247308872, 16525881906724873538, 16597989933510424042}, + }, + { + {18195618552940791509, 12801347400921689158, 13372055618013067129, 14929951832730936581}, + {2563109394536979589, 3392102243539970867, 2978145866937578695, 15809561751101461921}, + }, + { + {6470844231261685519, 4860920111547376221, 6133864928365904793, 8914566156785557227}, + {8258394874597607714, 4464810914649217913, 120457844518757378, 18209291810039348360}, + }, + { + {7739110373965523311, 11019153332996240080, 7346010155518751797, 14853737521111213548}, + {2542883237207113209, 11015136828834421504, 1998601666328316353, 1540417751495800469}, + }, + { + {3376092179741497360, 12221254335784366861, 5282973200516004163, 11372960528472533628}, + {8188139842572259074, 3946305224334575645, 16643338862665650950, 5859492058050333909}, + }, + { + {14916042081488114271, 3303190861468284762, 14234546272335492538, 5776190344932209905}, + {16339988209459724195, 10022514953301624769, 7878363685856556300, 3127365206552843780}, + }, + { + {8340102858481562978, 5401806343794775245, 12619159636229742566, 16221085737347795155}, + {1241298364136442056, 9142635103215118982, 14403222699038355211, 12145678822325215894}, + }, + { + {599034134015360884, 11263317530774995092, 6667501365379084069, 9844276013103312691}, + {7566306886180438990, 13702768345615509363, 12525031963170717968, 8463786212988210464}, + }, + { + {7279390679700007004, 10579602100702377479, 4366146547587324748, 6962092370680728424}, + {16372420580520124739, 4597019194685908384, 13217149760366044828, 7222487257194391332}, + }, + { + {8454830421421057736, 4100731209937375984, 18348214289895908213, 6778376865226169852}, + {12945227893790929647, 1818657910008686277, 3629900123705314093, 2861658388952811590}, + }, + { + {15882969890737930334, 5849157078791136995, 10068103243390577755, 13131421240079433547}, + {10404642120419399290, 8199866428750316037, 1032443962738597455, 15582122438927179496}, + }, + }, + { + { + {6390361653475754940, 1093882175267357438, 3784079074949811167, 17343872969822169769}, + {3359715652121662979, 16808529787251986583, 5169730697018536870, 52766949850965558}, + }, + { + {13147212495082910072, 5628914243538540648, 439989514095330941, 7620472329041817834}, + {4272251824771633288, 16564977601507013119, 5441117136715882317, 5622571730905974389}, + }, + { + {4207421531032215145, 7924589143024019458, 5496622772676523695, 7061817399179278712}, + {7371689806847905735, 8282663810521090335, 11422487361383982601, 6397294642072086677}, + }, + { + {960381383357168877, 16774709963697143275, 17896181076874992240, 1150415168189819777}, + {5498481130530161530, 6895900060791069290, 2079514944189747822, 3428689507902936354}, + }, + { + {12056920178557394302, 5131253251712581899, 16251877995882633963, 10883064494054484051}, + {9473274815269607947, 8874308005470196739, 4412709653190846630, 16469366225886156991}, + }, + { + {3547198835521135552, 9940690805769919242, 15170549880149605690, 10701681269101530298}, + {5914809102954412895, 15790219349994701461, 13664049285300230863, 5735249081148743651}, + }, + { + {14753645881295168970, 9410794713982813264, 13485977523338061503, 14267793994973767571}, + {15813187206361118954, 16449603969001878152, 17705410933007144731, 10960511750491378082}, + }, + { + {4669722990542640772, 10017368027073540045, 13392819319228640800, 1070815632453829996}, + {7274130058405640448, 4460835865761538026, 15283885107956150892, 5815884817303156137}, + }, + { + {3469614802230980914, 18060080625283048965, 580464295809221798, 3338153928139206412}, + {9845192339392693455, 13250323899168115720, 11058696855422647818, 9665232062806155902}, + }, + { + {14461336556325939926, 16946363864290460645, 17546878353664479567, 17949437676666656135}, + {7932367178689988878, 4806368097560008659, 3460529608269790679, 6065321700046177254}, + }, + { + {16883816924971606835, 5486714189826473375, 15204267662844332028, 17199232837602035696}, + {15958749676770074119, 5540664038667498053, 15914281753951743318, 12225053486711127081}, + }, + { + {15346266095840263783, 14129675453960658911, 1781465630073142581, 12398710533895277470}, + {17697074063253841985, 13826156613321578228, 8855030685964401164, 3749659313217692983}, + }, + { + {14888039192306165275, 11233459160096048886, 709252573146299872, 17614748022803380926}, + {10853790173866038588, 2988411430602910678, 1343284586410250367, 4491892393582674365}, + }, + { + {5653853395031137185, 11847098886335071270, 15046954358935848863, 490763079643421287}, + {3113500211585712650, 15997550469331041114, 5281575885072775975, 2887311255648554506}, + }, + { + {5376335754670737023, 13164671289498247151, 6846569847526260467, 5496656304894178122}, + {2009132493403453913, 17250524577747091030, 2315376314333653245, 142024984008484689}, + }, + }, + { + { + {7237168574323016859, 17908810107504968137, 16225708127838178121, 11127095986977103648}, + {9346291308317410251, 7381283458277047010, 15168602815371846943, 9193719743691734294}, + }, + { + {9607254959726458411, 16837156817186931862, 16178143308706847393, 10970721795101931539}, + {10840376278605273092, 8298765077094727469, 15520543037910966843, 11484620381947762562}, + }, + { + {17395070963094117711, 7608132718922490881, 6531178971071758016, 1302814667007331361}, + {4002629363862769670, 14649492495298089937, 6868174210142585697, 15456170652716048683}, + }, + { + {3688308493559609536, 5123828159813683938, 6245436817220183971, 13062234263274605325}, + {1313395302496832996, 4961840797708687855, 4990192311341859196, 5283131006216350959}, + }, + { + {16952735659396950704, 1249482796824289329, 17859504101404809981, 13260403650830168625}, + {1583343855370236084, 11389120333403185826, 13676599385745755008, 5066667130137739346}, + }, + { + {4799264864906918301, 18347145714884655971, 17034125441088681346, 11828378178487279470}, + {1759038296522081901, 9582407833575609381, 4195817009050503354, 12618256395967210055}, + }, + { + {6486755100213398364, 5270923715575268322, 9268255346880651103, 3147724493117082267}, + {16710318779269985633, 1240462642985509644, 2400811796254219369, 13670743068809614358}, + }, + { + {11437779990773246594, 13609113239383378152, 31268927496646090, 11618772705165035208}, + {3078024460365036167, 12138983306908962712, 4779157919015181380, 11901698850260672002}, + }, + { + {14642787507945832432, 16258081639927585935, 2560321462542164242, 16286882196975458174}, + {4328159372518768969, 14313553865397841147, 13769372656320240568, 8950675126435331579}, + }, + { + {1309709344837422378, 18403288028608342631, 17102350491414677993, 1133523394849437315}, + {12526496222782003755, 5447309058259018864, 17311120581405946631, 3760058661125144368}, + }, + { + {17891474172606596407, 320094264574086461, 93927075222964142, 14355817838636249140}, + {1777882427773785068, 8237021421587560510, 11520559469641852991, 10567910693910023157}, + }, + { + {9164300764173563614, 12322279811717869943, 2768902015676238485, 7761799112151133995}, + {5740162933856370894, 8043946608495226840, 8923704438836381869, 15189322655373943849}, + }, + { + {12046275966378825708, 5909386969214935556, 1201990704907881028, 12128549009950617306}, + {10773478878317625320, 4554854625564648958, 14029736945871573056, 1353247251064221090}, + }, + { + {11909123603272307101, 5517949035179831783, 3295386484950432959, 5605137795524476293}, + {10718654547602473221, 4984952409581272095, 883267724006996723, 17328431094026829348}, + }, + { + {13671210467347025770, 9980617617519781731, 8339868735163579231, 2150724314757661915}, + {8571153021065445899, 9146903697769397191, 9122246102814640373, 7744779513085605450}, + }, + }, + { + { + {9508384588323002196, 4786531415304518048, 2690306308552249535, 12208815515689370850}, + {5145548243685871201, 1536915039528215765, 709289946127949333, 7152734178531880864}, + }, + { + {9627905753364576437, 12776456422166281355, 2851899644189834214, 16998174196920379994}, + {9001602524188761177, 8960294999163663712, 6580949973363012183, 7568306074815116797}, + }, + { + {7686633626025788546, 8110394872630496906, 8482210436161892079, 16882855163559885891}, + {1154081680627148904, 12804224766760790394, 1850455828762691082, 14191115350906359627}, + }, + { + {13345381996769253014, 6278048669175242345, 15990349685835870151, 16358261962292186792}, + {8505261070637963021, 9396725065098564446, 15331953351049782155, 16194796339208321205}, + }, + { + {15505898598362934929, 16825210854979603981, 4697782190623959274, 9370503401456774242}, + {12874840227707962403, 6119547445810629810, 9764164009057494220, 5416853666956021065}, + }, + { + {7699498684510298360, 16542285627069734869, 200751785530104649, 6985944962584804095}, + {7365545959109847649, 14865387755379324112, 4167319688751668987, 12162483513847343974}, + }, + { + {1039980316046001816, 7207503221801597145, 10591680158322288825, 11266400320575557454}, + {10706275395641440317, 9288394947884616208, 10167533985006762418, 1456585988309878747}, + }, + { + {7076257175157660597, 13221730879315432464, 4499548735964119085, 7559253754663705944}, + {10196808438730350168, 2391718471837563931, 914409564589897387, 6649744842278078706}, + }, + { + {10039057354622246685, 7195562849416781100, 17696866082062058984, 3668253949076972503}, + {3291647709604288622, 14581068695089559804, 10104544037456163379, 5446494334499941155}, + }, + { + {11083442423555675697, 16463352501129765262, 8326106600927169880, 14461723217830443766}, + {8960039240507947123, 6112452535158412156, 16298251376476091126, 5185774007776019173}, + }, + { + {5801222283949474418, 13946418525037992779, 2275515160040674505, 3244981365190546382}, + {9460698310301428534, 14807942233170768102, 6180104492182570514, 4695926909096500015}, + }, + { + {5502356275170104522, 12750322860129485966, 9581277511584938955, 3872282844937972630}, + {13668854758739140874, 15020438121087800965, 4581631138384430657, 13296613956093963588}, + }, + { + {7394309355461523862, 5374161350639568117, 2763783634295242959, 10215168014269656712}, + {10862202275249464165, 16813773246956503013, 4644566761082532589, 15300517379307655907}, + }, + { + {10894319502247195436, 16018449015752583379, 7936971022695592164, 8273950599391165937}, + {1130484969598457981, 10652972605389048300, 5964985167476071140, 1178111465674979168}, + }, + { + {3215460690308212256, 13044009109542950831, 1248575312568743704, 5805472854961471970}, + {16935262056111009166, 14323719510498371522, 4137201278518680629, 9262447671880633672}, + }, + }, + { + { + {10228366644420455452, 12084265406352277347, 10265869676493821892, 3560143954870272139}, + {14368775225608592689, 13173522067191372913, 3592475039513249949, 11243554718624931135}, + }, + { + {6543255501112359319, 6063422531520498671, 17228726254778244409, 7570754775709645369}, + {18222396492501523182, 14903937974816691813, 1216646642383641441, 7602781158453005929}, + }, + { + {14568782576170814716, 17582848432122737506, 1079387064102681806, 17278567874821675408}, + {3094302191119669899, 3730448048895347901, 3508894590334961422, 14091660942919228106}, + }, + { + {13329033749048978810, 4765695903433858377, 4452680451529163940, 5638854187414651620}, + {7897503022043776206, 17187635538005569019, 17766753195497526986, 13201529234556380285}, + }, + { + {8934119620399766972, 4226481091885914732, 16000709195004445297, 14687868180928846933}, + {16269913392757896907, 18294005838441325342, 17625669613551023126, 10864307042201644469}, + }, + { + {14722530431277419104, 12333728409662476827, 4162946257347548625, 7052045338975163666}, + {16435875989376103923, 527141841571514699, 8480360258792897962, 4322786951393806781}, + }, + { + {14380803034817149259, 11042134597430846555, 9992762805140200547, 9895143575678511242}, + {3228768306004664915, 16153114680219541243, 12036181641761325912, 491369524302296324}, + }, + { + {12320933424684960076, 8906954611339502145, 16931708732547376267, 6446897311644431583}, + {13749563256713530203, 11522599770043814384, 14455556215959342791, 9022955938835504923}, + }, + { + {8738648866901281761, 4688741093801776285, 17069682640810525423, 7158141773766072053}, + {11460933790638879246, 687134766504463570, 7796313120876518884, 11150451731319135164}, + }, + { + {13652684811535265600, 8494726433844453583, 15999979552047212740, 16433235792902853942}, + {13641303900302396790, 418630713805776951, 13090797093697365883, 6529658430803752768}, + }, + { + {3944614182924380177, 9542495129087581473, 6699683662731923419, 5017219913619823514}, + {17045736494588140273, 3578045824537114332, 15234910011456151711, 4392310298224006475}, + }, + { + {13050963220563520130, 16311879939705207639, 12461297624582251388, 9677731599265769222}, + {5160679975931966230, 3218707041599533629, 17098083534384492023, 2330141721984719029}, + }, + { + {8245975647138927146, 11496799090887525271, 1709462103065191917, 18401529677683893204}, + {13971543411749700717, 15107687167816783802, 7171906080161032790, 2549191081579169610}, + }, + { + {17251496610557148115, 13056982918233222110, 16321077587645226911, 15873643227887663856}, + {7790198561388957118, 9539520576306975575, 15234893276112958324, 12999697377068360422}, + }, + { + {16169560456946825943, 18091964243071526492, 4341876361632902705, 7532668331381251135}, + {15346381760818990405, 18301333564088079147, 6565096728885044125, 2494845330727350075}, + }, + }, + { + { + {16319476863352440541, 10283930715856640343, 17675054544532098447, 11261132162985242084}, + {13712716897981761400, 2681907143459288706, 6930256922080133347, 1445069157579547822}, + }, + { + {16928574868467385886, 166417019993787654, 5882811520342817815, 14106304179344008065}, + {3747123724781081800, 197109533566874475, 14303280595714789450, 15457633026018307066}, + }, + { + {10773597511592584859, 12552868588431074640, 13500771767160426835, 8002499270056378440}, + {13792839099998553174, 12949371255843262119, 1713974340992291550, 16150173130483658061}, + }, + { + {14745984256428057001, 9333707338036985191, 15365925315303462, 11789129028059619744}, + {7873100217437235208, 5289763977161829145, 17731215200358323788, 8876377479309635703}, + }, + { + {265950821974454804, 5047467530470542278, 17523044368516619801, 10054436503372765176}, + {10321185867287373431, 1212061937729015591, 15311258419138633926, 11236518538207084768}, + }, + { + {10904693956407098222, 9013418755007070130, 15510005599846320670, 995378633446250700}, + {12234095025518917836, 6689106237771514188, 2809193993744369126, 548124799387888260}, + }, + { + {267350765778774337, 2853877351938464055, 3677119082593358544, 7685335121077514739}, + {6491980094762370981, 1384870316654548002, 10568872345228996498, 241629538659623878}, + }, + { + {5839400175629113441, 5238299193248381245, 16787876416022887315, 6051613843621920008}, + {9219569873668974552, 5916753090530931032, 13390630214643423749, 3265335490455191268}, + }, + { + {1507475744849985303, 2597075068965622770, 14968669113917266926, 597606442423659891}, + {44293923912414886, 3832651144752540816, 17438860065613195810, 782112340603343331}, + }, + { + {9050896199196733903, 6427608033444590004, 13787696679536621857, 9682087046920409188}, + {4519093754155995429, 13564098392055667371, 10512507082236058799, 5289934424008191746}, + }, + { + {3477191607403300916, 18283244229745029067, 8462159792484018099, 3056576498976014760}, + {7259283167233712785, 12530251965039903998, 10232104933720625111, 14190745998092156987}, + }, + { + {15759362035410895911, 16075598437961371531, 4651513528876405575, 7694151626503869614}, + {14468862724637972284, 1838601521755586245, 4168957446435305706, 8694905613027663664}, + }, + { + {14825552838983151434, 8639609968952840931, 15547914584352392016, 2313507499500708287}, + {6902543375698033684, 9987468886016348918, 9068175779860656258, 6899641689193116297}, + }, + { + {7449110402827616954, 5689206471789540768, 12722069021950813669, 16017131401246233663}, + {2240977975275954837, 4794705713606614946, 5734937900461809607, 118285984764445639}, + }, + { + {13917685647531721740, 2432096911145792817, 17733637484624159521, 3848601825403209903}, + {8192433211051054683, 17388066421914150767, 14336306308847565282, 7501625553608785022}, + }, + }, + { + { + {9194523390605857831, 2335161171394626054, 12290490336543843159, 12464172604156286188}, + {15842196578033029974, 9081285134201585379, 6123406461662038242, 5504260508195082396}, + }, + { + {9599159247384506427, 13011559959971256245, 6331802547989957841, 2642320882309956905}, + {9140255367820630480, 6883541786494880896, 9560822438260750771, 9273862677291701694}, + }, + { + {12578940088863451089, 4698579870843180556, 13634180401794570924, 15763130743395284022}, + {7444441842547931942, 4944622454458561492, 9589156490791486440, 14762328488235724618}, + }, + { + {6185067974942684922, 6452325785873503452, 15247257292915812252, 3689324664200339196}, + {3264129576054154137, 14977721630214750038, 10720913377937894256, 15914487080763816378}, + }, + { + {8926126498606164569, 12956394005759769716, 16902149488499586013, 7841840983349613625}, + {10587053251468526108, 696362153501209498, 9784750880259098186, 1207696323194229080}, + }, + { + {6366297849225708271, 1653728037493780302, 924103820671018926, 2050213326049184692}, + {5527413390519421127, 129805527414320490, 11550889572378802302, 15667992622431666977}, + }, + { + {3759028419971240833, 201899490644698259, 16787882148977818573, 3755266958958128460}, + {16997526157701685291, 6920710029293447897, 14077301651040071328, 10880144992445166875}, + }, + { + {5498621600689515064, 11498885804037952971, 12697073118321478539, 13999008478737234463}, + {4324885099420360642, 14021182496192299466, 10763088992583373843, 12898585157666243299}, + }, + { + {9367059860785010847, 15787147891143727655, 2519720658767337732, 11593809545681651942}, + {11966083811953753216, 12761111316475086277, 5681625861426437827, 15920587591610358813}, + }, + { + {390729441391219522, 16780558466241830343, 1374488446906327562, 10865131913700232628}, + {10115076211715532468, 18184016780675566832, 8365356477197603014, 672096097598251136}, + }, + { + {2393424067712509928, 16879911507754196299, 6441307574161100589, 2818743579517374412}, + {7083174841445248189, 3410683030590349702, 14697584027599531676, 8328975445543175696}, + }, + { + {11622402383521841588, 18271726976204770291, 4805501248621435402, 13483122453682180759}, + {9288143526654965614, 4688427612851085031, 3280806057528512375, 2249349779106893174}, + }, + { + {6807440366000180651, 16399452121226315247, 5098169947999459087, 3558234272787006753}, + {1792969085845015294, 5524357634740353242, 9429244535996516945, 3937357214017147760}, + }, + { + {15504868609044485967, 6752328153557303622, 3778610801922734369, 13830970685441980645}, + {8715733351182855585, 13970559751738714496, 11410776131378170826, 5487441016062951646}, + }, + { + {13162254303511925286, 1500183854026947752, 6344593292969383689, 13968537166293685529}, + {3100593991852309751, 464141462036312207, 5107705843278430088, 1965835506583809167}, + }, + }, + { + { + {12081034000518110752, 2773740877021737013, 6429475399936543899, 6804412599792308979}, + {16082860502313571182, 10013838454082912732, 7176778953927883654, 8065751639278576331}, + }, + { + {17741525051518363144, 1374267330336191942, 4677891169679898540, 9639823611685431337}, + {5482431056894095950, 6629146695374718376, 3884574854221819712, 13266790928096813258}, + }, + { + {17505459029376928465, 14087658194607915364, 12240552390931686885, 1809009366037859941}, + {9468395484396723291, 9446052656478984520, 3720796795453397330, 18035355127900871187}, + }, + { + {18221138344920380175, 16761112742545021198, 14421639991115588619, 9419167563943683547}, + {6237248361283446238, 889754338720059891, 2289880386545166424, 4280148734121099084}, + }, + { + {5259165122317589354, 6306061166879114159, 2622163270351284906, 15212813592118086979}, + {11497359168652342849, 7085380391293263482, 11799059272489792659, 4912160901181298022}, + }, + { + {10512473611770099290, 11735037909076331019, 2922606398008539984, 2599799834378751770}, + {10226702495047936424, 6109026252412854338, 15572556822827169237, 11993701786788749663}, + }, + { + {5106897453764491321, 10540479232768400094, 3938246597140945859, 13156157265138481529}, + {4932443191001849637, 11374218582626530502, 2907557293167002437, 6807344711257391317}, + }, + { + {3993197157612782947, 14810882170056329119, 3476738916713041107, 1512933700383846542}, + {17820889751141311776, 9132720567660500233, 17598924894608972696, 9704537908665702455}, + }, + { + {12121941964759747109, 161674837074510172, 2599887134944602725, 10582301831176576187}, + {17746858667522793487, 10735346620578591475, 90382511151212475, 8756617880518165297}, + }, + { + {13269854730742674802, 16128423099443070808, 3557230428644480193, 9637953317416090984}, + {6295039911768726240, 7019479692290635445, 11667616931857432446, 7159479331923350611}, + }, + { + {14416651741118525418, 10180867452897498870, 5073925566889872021, 17399294023945814271}, + {2042657564518230341, 3364886656428812718, 6324877312192616572, 12778324589036538810}, + }, + { + {10574237360751578123, 5116798422805306054, 14491722292795290218, 10799156134310323684}, + {12689926633011134844, 2658342468671191169, 15293758403109373386, 16248058473163364262}, + }, + { + {17412396133163580666, 6474892296180387693, 3334160446575187305, 12749216946172573968}, + {18160154520597666127, 8818156595950176943, 16077267238396508593, 12651459389529897136}, + }, + { + {7837268594975894598, 3733413917041538879, 9408433334074005916, 9807113299110084489}, + {673053561909802023, 10235823672366472244, 9197803481286702511, 5670973022205283920}, + }, + { + {4435804333677545569, 12530066828083700918, 14652119799285589695, 7610189145859517535}, + {16049951379406478991, 1895939661259683634, 10886955028200106760, 10575752015672416378}, + }, + }, + { + { + {7454214833719424418, 2128900810399984335, 8254953962723841408, 5341529923812819418}, + {11486532916552139238, 4528331821405917357, 5048485034448492541, 4189495710753944825}, + }, + { + {9223539587116638677, 879142711399260546, 2878829560233905572, 13081522393987952773}, + {3067261963348061547, 16008150780594711643, 5466468631453287640, 16659147898971349582}, + }, + { + {8047766502132608624, 8715815570878148809, 9093649079884580138, 3437267783531715968}, + {17562225708466062266, 3512667182749067601, 9223059995161026858, 1366690634827047376}, + }, + { + {17929132376737482163, 5565926714491294456, 5252303555134107501, 8169975563698132305}, + {1829326230943509100, 13780918661853274468, 17736665596871232627, 4246797342334307384}, + }, + { + {5113556452592134569, 7304867793218750141, 6016631926489320290, 16471860203547627727}, + {3444471410714850041, 16571738096215232488, 2003912224952639024, 4203884000388032492}, + }, + { + {16858425223672505353, 3192567884201479579, 1688923188642613263, 4159042130811153987}, + {14900413503869744297, 7521485042788722327, 14038093805562042641, 14713051866364662650}, + }, + { + {3738774192924465076, 14037618828827556145, 12882915396530927286, 10882862194263941815}, + {13115222579444494605, 18244214260845794346, 17217867059738274194, 2458870331386500577}, + }, + { + {8768788172344064509, 2761897497254272960, 1400167175024837359, 2591319596670212133}, + {1499652044223484974, 6820326453941021707, 9701009499879906773, 6897435972338565418}, + }, + { + {8314355711464256163, 8435944020779763783, 1814803522962187872, 1875253356755380905}, + {8214588085484192137, 18062045700553127821, 6649947905482043494, 3119726140944397531}, + }, + { + {11881571666857493523, 6300786026612414187, 4928573492087752294, 18343550313462089203}, + {6770642120472453960, 11296815027803718740, 17312916793783562794, 13028515123652649961}, + }, + { + {583508939637547757, 3195115082527873085, 8497784022800549923, 15135719419829981016}, + {1180291993378114150, 5447281494912347899, 4710517655176242215, 606503081693490000}, + }, + { + {17732293765863716052, 853971165248416821, 2022886284923413326, 7522564752651732633}, + {1417954193520965954, 5046659528429172066, 11426939225844711305, 17687206690616539318}, + }, + { + {6518552374736169438, 7940416740434530770, 15228615103587329007, 10662504584317997513}, + {18370800756791469891, 5564085264882124489, 51043856061444814, 11996026931884728651}, + }, + { + {7009195269496826002, 18330778751427846129, 7903886241001925539, 8198930484643879628}, + {5453546027419466587, 10378692433982210944, 2242412603379120569, 14762161396393277464}, + }, + { + {6146718865488327808, 8559779132928137805, 14001994895150170346, 9915701789711858841}, + {17119408219089522083, 4345363585985782988, 7559492126634131602, 17074565022279033371}, + }, + }, + { + { + {9262509587234749312, 6377906816499461739, 15415592259881792841, 6113140067088447267}, + {17505803833889144731, 3922849788840338823, 6180172597177093790, 7272741317181956640}, + }, + { + {15620168851912893400, 13762314693487747007, 13577625382054330775, 4116976667540664996}, + {712200332640207605, 9098568002202933512, 8905476951567380032, 7075673514150314660}, + }, + { + {7724870937269356050, 12054277107553403808, 1881284905431205309, 14429595888039183277}, + {4176419490283315185, 803567059653412279, 12138878637145159139, 9651152331113389250}, + }, + { + {15811459837282651008, 4038049993244767161, 9054218236388056577, 10807376403937048775}, + {11113869110590438959, 10336442539492421506, 9228056645601479672, 2983388754829658480}, + }, + { + {5272549712777700740, 3890998652469537324, 2338530655383446899, 13889100994494825258}, + {2605827345546331653, 1946537408424111099, 5960128674616374312, 2996461229050766944}, + }, + { + {9235630643187100528, 7874836741106774683, 1509645736063284557, 1291934408179243533}, + {2170879231846765016, 18243888082459973651, 266993053446290594, 4551583084211481457}, + }, + { + {7680050744092380106, 10728235076013009138, 5020205498410121740, 8174117988374987111}, + {15823303896577313648, 6268651341788131847, 16646239256422284672, 7277830349937654337}, + }, + { + {7189376137127712298, 9147574701720272724, 3983921661449444789, 12479790317447783959}, + {13221020976679959405, 13001868979553711359, 17918176319017234744, 18030393246529651080}, + }, + { + {1277346094474678251, 9498303380775859142, 5384923668452161486, 1780647986160100011}, + {8642790494747200341, 9734232043260261391, 5142834828615817260, 13851307413031336094}, + }, + { + {13856162196947802633, 8991033151317963811, 9758143338284799726, 16669930361261935141}, + {2769693485089420097, 14961618614592883242, 6027973048684521312, 339045855685213514}, + }, + { + {4705473345956039571, 17384553086897199761, 4490030246274451948, 1509996255726148943}, + {13542663230247432557, 15148026535112827520, 10014941605271261089, 5488071105468657298}, + }, + { + {13903368497828271814, 8050546449078305498, 6932373216915935575, 16010012759059004304}, + {15451708272653450375, 211711129247219149, 10435723642185827585, 17790507800712341232}, + }, + { + {11196283625212661460, 11223173364796389182, 15927254202510526683, 15939111530538795368}, + {3486548927974609940, 8233744837082586587, 7138041412908951164, 12863368836600604627}, + }, + { + {587498550288996803, 9937849083717302378, 17460580580397185843, 16850270092759302710}, + {8661654791709545973, 2350686583325065432, 14816283856648791595, 13021196930055398267}, + }, + { + {9641099975481205848, 5936405208377074167, 16926315209235053832, 9612898534540818137}, + {17782980290875306043, 4118599702370009503, 5379494204096737612, 10529123509904334042}, + }, + }, + } + + @(private,rodata) + Gen_Multiply_Table_p256r1_lo := [32][15]Affine_Point_p256r1 { + { + { + {17511864284462479051, 4391315454785363822, 16633389246499252566, 4290325975494843430}, + {15912670649662225191, 14172733821603328367, 12709802627494541709, 9648238681838878635}, + }, + { + {12840624483048662115, 13614226123606379619, 15087571995173849344, 1395488309690794621}, + {7173958427217959878, 1198561064176820332, 16821886260165681626, 10019479169661217935}, + }, + { + {9901328250515532535, 12796305315632203942, 10819069447660403847, 12542238242508661240}, + {17077777737462854238, 4364294351375777648, 8335244153165894685, 8863541604979427311}, + }, + { + {11029520456752683158, 2297291237551781454, 7934683676555855479, 1563954733146546128}, + {2252805128528536255, 10523375695822939112, 4598652721256818062, 17493379105069761435}, + }, + { + {2747551692916263132, 3151123035150683281, 13938314333309683791, 11970864255483579560}, + {7894236725861110998, 10515613623232567716, 10445557830757066839, 11155097727742050955}, + }, + { + {9569762631377921701, 10341967309273270300, 4697570564829842013, 16684762125903667303}, + {5281929071085172097, 13027961546412671127, 18398764602992176314, 3872796039504642974}, + }, + { + {5035609627965208105, 6338722048255995169, 11594969687968475335, 5639340633771742838}, + {6928934109570365590, 11589609913085167707, 18353534295019770247, 6879412911232288750}, + }, + { + {10042008593756684008, 6713471518385846030, 10961845838926538977, 855334359173719954}, + {7598642325962297361, 18006511265377032901, 6844179774752820363, 248341098560552116}, + }, + { + {12797853895127133352, 17314687680589848148, 4801569699821499927, 9711604734594547217}, + {8212610645535363590, 17221681508724305642, 11398663136094709935, 14918164175449979798}, + }, + { + {14940688064094792027, 10874356086032303420, 9942334156288812894, 18314945846365913248}, + {2026773265909278528, 13079907189666226787, 2413436844382479762, 17172916412715413729}, + }, + { + {6906211734178583215, 2568977141255648055, 12122130143181371713, 828440041422552532}, + {9361946962651414191, 8982763378443381215, 13842936470438971226, 14726899303190381422}, + }, + { + {15233793159839573220, 7091365221489488397, 7026505041428577564, 7614138360854053029}, + {5906758210005848219, 18266182645583974519, 15465977441750183309, 15365799046100584430}, + }, + { + {5523310814149808824, 11103439607538154330, 10292039577546071548, 1169663949743807030}, + {902203905701917473, 12346725749938989079, 17633270407605278415, 6960688675023695455}, + }, + { + {4505161139988645144, 10689463780805884897, 9379083335142738351, 1333253488693735633}, + {16044931735888519844, 16145584549427855743, 15405407720239538978, 11239573776554839202}, + }, + { + {6975554318981968975, 15982286720404911512, 1685931425716796252, 17715405440768877495}, + {4827607732096558544, 6375626601740689475, 3502039151843227915, 12085565714635174559}, + }, + }, + { + { + {1190044221726873109, 732025666411072563, 7781096808432277694, 13079879637655900365}, + {9048680577986693793, 12528346194104542124, 10575369576322629835, 14068913038053465964}, + }, + { + {3297775431071502652, 7947266993949467566, 6161673381820779563, 10604626734847205996}, + {17669018066064502925, 2386071939136502354, 1076023928806956187, 16075459682742916440}, + }, + { + {12387028018538599950, 5791681577936683396, 7536922194386052138, 15377770247350254336}, + {6564316170002440575, 10629371267149545956, 16125760269901494382, 16051398044897962024}, + }, + { + {6237354803374899565, 1782400080026955610, 16115027077529639342, 17907259814836219524}, + {13179234383592426160, 7302978467158243198, 13607720993463749225, 6693531817169120736}, + }, + { + {9659467198848065929, 13765104107473534739, 820057324758632016, 16604163594878267405}, + {15321524555426147294, 14524167419333362957, 157291234996957911, 3689488130722730671}, + }, + { + {13896531645245568605, 13598412639648980920, 3875086557856143664, 9242105512956135595}, + {17410265178284161091, 14904754836127450463, 2354327747158525902, 3858493849578874654}, + }, + { + {17288438225198818690, 15275190140700748774, 14532856272428522409, 2192294551011758591}, + {4275966798014984695, 13252812474545742114, 8604705074440591847, 504054699541924162}, + }, + { + {3623027910997185067, 15957466839356832933, 3504133700071704955, 4135728439139397021}, + {1160600455691338871, 4431928072859292239, 1542956305318065546, 14109181184369694855}, + }, + { + {9135041378474229537, 15626265487594878380, 2645257479784082878, 8105679948445763432}, + {8579715781576202730, 13437359533149316300, 4344754720520585005, 13326372852934103673}, + }, + { + {11341622086474305983, 17104958945811183278, 8154944722722765678, 6696975609844549775}, + {10895966360082878017, 2277686037575837054, 12236842881540344526, 2086470279064067791}, + }, + { + {2942668817124399651, 11439025398519255779, 17477264434671471242, 9606507094132585461}, + {1771475584689465869, 10791261379080046759, 12901998265727968789, 16423426725595035468}, + }, + { + {555419805011031621, 13715683285513290290, 15526654591995532751, 7023761423093873354}, + {15093366433178982304, 8625749648874372840, 6412297471587129206, 12161114204724955762}, + }, + { + {9362623422820895267, 6491356159483508885, 8543224082493101588, 17290929683278258587}, + {17348088672546490894, 3323350644823701753, 398525379151271104, 17794417664139368677}, + }, + { + {5880914635028486784, 2898124605786107494, 7953506026198179840, 2189477357380899574}, + {11207122442953694293, 9288539232660208671, 13527697625010979453, 448462453367651162}, + }, + { + {11262205719433170585, 7539606872920196479, 492385789142086954, 16036594120332851267}, + {8084547797138041354, 10063336189771527714, 2484395715469739911, 4879298610504146231}, + }, + }, + { + { + {10457697409306668434, 7830477435299250296, 7772379952622394912, 6109610138112185532}, + {4382803614711332911, 286231563340803504, 14408860285425706036, 9445290615796219321}, + }, + { + {8838210194055479741, 16190279688839291456, 16520121358582757556, 16768959728701970634}, + {17279896910204983538, 3582816187015369256, 372137484481226748, 12972230207718993241}, + }, + { + {5372953569411270487, 17808033035436856194, 18122397266105109983, 7100719381161799491}, + {14789750485957107776, 7797117101197801156, 3512936690589352328, 17020065099624467120}, + }, + { + {11480031272463364121, 2525856087688686375, 5875255653057452580, 5606696614467440464}, + {12094715534218447962, 6173479337351577758, 18244015404482482803, 13199349349511499695}, + }, + { + {15137716704658930971, 10986987873306909694, 1939043496821343401, 831824210330752494}, + {1056638569496361761, 1714583153436391847, 5183439003162975519, 1665087783666164342}, + }, + { + {8618628902870211609, 18064648431799903596, 7274877928823092285, 5660734703123876155}, + {17178150811821260605, 5485275535084805985, 12607767610318589165, 2215859519135800862}, + }, + { + {14525253431314563485, 18061438239992695424, 3753059877845742067, 6434164734885086330}, + {7925955539869645215, 5236273722884803492, 17135463959633855728, 1885217581414238490}, + }, + { + {6097225965006328457, 2630336000831717722, 7049638698786526134, 4203465038263485233}, + {4677974565964393904, 16044036678123636261, 7266049959100300634, 11339674070148504929}, + }, + { + {8932509163442546090, 15088719838810504543, 16380598316811388529, 11816509227456545305}, + {16117098651837966507, 6506253137957995237, 7842840841723336777, 14854630695614255489}, + }, + { + {13319400996902371533, 7582870533150862327, 3853021819016824068, 1553148791440569506}, + {1383156799113954152, 15192818247458559870, 16096167687117464686, 6356494963887209448}, + }, + { + {16159738883836847557, 12797888767862801410, 14516904553705186948, 13070086184381080434}, + {916885380224317954, 9486576895096666538, 2320292919516422975, 5019772534786350963}, + }, + { + {1979992348876614621, 7494083465935166973, 16035723662722831744, 6820849908885211777}, + {16740735239901023053, 2017530162004533409, 3087262288875984227, 9072904925376793991}, + }, + { + {11716934526135332476, 433379719600995157, 14981324743710487461, 16580162143428931768}, + {17678216037230646787, 2252837520490636634, 15914299694597684738, 15253999728204986937}, + }, + { + {15673599333229961794, 8862902775863712472, 7565222536246787763, 6724910605061440481}, + {5835390808530098179, 9647776340035782792, 1038074137838521743, 3352456378381259564}, + }, + { + {13166325906224116930, 10408481058915151795, 13583679214409957982, 13238337156927685694}, + {16088785436819834700, 15860660615594092228, 6472158593272826810, 15600310172166391652}, + }, + }, + { + { + {16375505785562641226, 4903074653735993511, 10355787845763031761, 3188849033041803587}, + {3145147452182864049, 13878747873108378466, 2798650520315922121, 2325962694441538199}, + }, + { + {11530583608023224967, 15979155166527001287, 592931868138800645, 5361781029549479856}, + {11246418752830406096, 11882251984248471436, 12026389461944629423, 12289077922798223820}, + }, + { + {1328339467113622233, 13374824154992864223, 12057132015324007824, 8507647484414695512}, + {9286016370798146986, 9083798709648036612, 4312959727577073260, 3732271624824420608}, + }, + { + {14129872794455315922, 16354810591314135702, 3177417010197743958, 16494351130927698692}, + {16557765056328447818, 3139394196704738651, 16891813998271303650, 7374470997276173905}, + }, + { + {1547814412223404746, 14194709348405912167, 15771028929623393801, 10945048172868684389}, + {11234483878611528405, 9542605377580701681, 4555391547268120796, 14916872217451960022}, + }, + { + {15490131882364039637, 5140304620645573547, 9403655757498826823, 9824850954989176893}, + {6366139388903157264, 1981838834216345294, 14659870286877979556, 12091578124492612524}, + }, + { + {6832171775190531128, 7903951882621813138, 13717573220828409267, 15400575122727850054}, + {6101307565293576434, 17226772767105983314, 3485283905347036760, 18439321272895583847}, + }, + { + {6289130721434350290, 16129337673129720846, 6648351866142453445, 7705983837166554199}, + {8120136556582544814, 7924417299222764443, 7821995671300500892, 17697662726179084739}, + }, + { + {6669506511185916061, 7036555931205961476, 15471324228012955656, 1075869467462424743}, + {14834182808856841386, 9481869408708862398, 193651363902981365, 3496053494343565969}, + }, + { + {15198290782478916101, 16205293865829644684, 2104596565474767471, 7783918193658109501}, + {1567469099169331732, 11324634977690198924, 1374141643017900909, 18368642394438425630}, + }, + { + {13389638006727712302, 17518324493263447682, 13178832200681259657, 8955667391164524441}, + {9331759525815425703, 12920722511913101049, 15807602761711044426, 17873219821625976662}, + }, + { + {12103811390374960600, 2801185238127939998, 16289223959107648345, 17243660994858386104}, + {14818957729322960498, 10018491794651971206, 5502065678180783560, 4158378425043433526}, + }, + { + {10278921174996593635, 4630624563386647486, 11179643216044347020, 8701826069861381281}, + {5839989039471676569, 3060138177923841885, 11279648082143612852, 15207786733412131883}, + }, + { + {18277950978951138342, 2577918906618404946, 11684553042740786163, 3082582313241836872}, + {5222056779189126973, 7794579876203167869, 8527673475629739407, 9851790541007784515}, + }, + { + {671618501514350673, 3455246317052893537, 18161533457452722900, 8968434886308785175}, + {8445049055511813064, 16897132794064300993, 14420937999674600470, 11110627336577683437}, + }, + }, + { + { + {11535283160083833975, 15102917952496589829, 12909095696891909745, 4611119212602854744}, + {4195756524232932570, 3754603965149529000, 11539276962358607816, 4401424391553230481}, + }, + { + {6842993463058627120, 2708745114617181146, 3832382691810282630, 10333834458057320812}, + {15028197197004077388, 7681293343255119354, 16227537691626587485, 6703363869832495607}, + }, + { + {17567108285065737529, 8693245930330183070, 4025672038042952121, 3491067119247522844}, + {2100799837993193702, 9579542950705774054, 5091525285265581997, 1806757015709820088}, + }, + { + {7757354840118131559, 16227348978414023262, 5800861674805516343, 16486235803248700961}, + {15646700163023677309, 504258765210816549, 13724147899924699697, 13588899538317277096}, + }, + { + {15895596198730294923, 12513494396374459899, 13552575153453342654, 11312160635199213507}, + {12446618129881485796, 11286186116805515445, 1584191291800429567, 10188741008566636830}, + }, + { + {10157626021970320469, 6580688164585715207, 17158416694471177787, 2873484006255074946}, + {14852216457444863041, 7463041347566136496, 2190030775722958628, 1116223035803602728}, + }, + { + {8598875756176012541, 2146658618778432566, 17575736667490551813, 3602654209723135985}, + {7223347129734689099, 7256921024940026570, 12249118963297692963, 18168532365040819099}, + }, + { + {7585174044375463988, 2491923406404093282, 9355733262044036112, 11484079611349577325}, + {13145030009254943291, 1234932884591406048, 479845670619308618, 87735010308690865}, + }, + { + {17307641427543377277, 5862898330718319545, 485176909118483750, 9845223919324484076}, + {4293549583740204024, 12765124043303931186, 17870894781132657382, 6508172378961793849}, + }, + { + {14234156373312856400, 16210939788814051708, 6478880037923038392, 10435512103812909561}, + {18142844321802359753, 3243996803126554757, 395603619159523019, 10213589535656704607}, + }, + { + {13256075137060741204, 991285459654295161, 7857174835799942102, 16201105040554625727}, + {18398612085349994216, 4512860776717176840, 3521452275695011919, 10622137733045360311}, + }, + { + {14993897771652736376, 3320388672992783302, 18421556740970114213, 7438967127794745135}, + {15048397725789819354, 12721899159423777001, 1135125102123667189, 6637485660805148630}, + }, + { + {205606553319362431, 15484041062449893984, 12896720585684759529, 16675624014916513672}, + {7579112430564108390, 4602460356900251082, 2677787525524280838, 16723483619407414479}, + }, + { + {17981939084373319995, 3989926231875116241, 15342509934701840045, 12999252495311233519}, + {15389919024942778009, 6136335679373143315, 4117381415379544275, 13342256463740646775}, + }, + { + {7622769999043907199, 15227992053145045634, 2719412067263856950, 17811161335980566241}, + {15036003689029442301, 4919601685231030712, 6756893600905532338, 18029567067112075531}, + }, + }, + { + { + {8492025373682814159, 9341562763134230960, 10104358220305514878, 17545404790574939459}, + {15737064134098795026, 3880597485411313924, 388663918823974597, 15032915458906101183}, + }, + { + {9452334891928331309, 15207477416486363718, 8081596400773698461, 7528187414539292243}, + {4773782664413845594, 9435822414884353799, 2722451711480791323, 13642248100035410269}, + }, + { + {14202843175914986568, 9421566354325954710, 8667368258699634314, 8733557788892402517}, + {331451278037425751, 1109013653863287548, 8802742738207038150, 4667769857523050796}, + }, + { + {16570512961992288509, 15784840936011612960, 17797638261217375128, 10589124475671334830}, + {16848440972121709899, 697679021479737566, 1456738239410270672, 7214966028857473701}, + }, + { + {13782421991242364698, 14661156263311647121, 4726455119103158850, 5026680986111581594}, + {15610213195880130268, 13703306863846075517, 1371700218221235399, 16792392307217237043}, + }, + { + {3250188629442787152, 2728518744775098354, 3140694818026767341, 17566141747707001105}, + {9569291890730505101, 4439949820491175035, 13751802166620923317, 6602549032413906269}, + }, + { + {1067242659333881602, 11852011445832610026, 10644339539182752718, 15519552867360295119}, + {8817864336906465495, 8844034637292547409, 8850766994595652906, 5299330403389585218}, + }, + { + {11434157439953722433, 9090860151661100670, 8407869262026581159, 17882547383849407986}, + {5277257988019769029, 11463853580825342183, 13607489835500075467, 16878800997498950751}, + }, + { + {11526703690786988415, 6919770449526881259, 6713486711636442468, 14697284704991333147}, + {5405738839499060129, 4737011393825878948, 8707677918280383477, 16881185094380241198}, + }, + { + {9056014389564242176, 13179419520216397988, 9815298409700670396, 15302091100015307530}, + {12552178314548371153, 3975519917079954227, 17211203317279781814, 17755252427177154090}, + }, + { + {14056502343958951437, 9570378325961888046, 18335930130582329417, 12188057598786655680}, + {605832426765150582, 15265028749599155713, 4881763628803375168, 425422732543303669}, + }, + { + {16059297404709367406, 8426877510924536482, 15269952608796785555, 6256768900860981984}, + {13142655793714702073, 14566340391957173918, 17147065283704191109, 879106195264399}, + }, + { + {14152733561556558931, 6788431167332998309, 2303657738205239031, 12712406085467592411}, + {1740483284496903693, 7206807366776489586, 13420608648010812358, 9180900918550128115}, + }, + { + {7193311017682954852, 7916342489073401148, 7990830552202175554, 15066065171478273830}, + {15601436495559985484, 11056245839590890541, 15963012082312968312, 7270947051909344657}, + }, + { + {5010740583028703301, 15413348048560455978, 2028314374959411194, 16685660750422250777}, + {14284468905357216559, 13715859397068327775, 400943255937053645, 15390787503961331119}, + }, + }, + { + { + {2707032230021934480, 14943945588296447659, 13333962501998857701, 10603744732015256400}, + {3386903941135274495, 8507451908469049716, 9231176235773710950, 995464562185179329}, + }, + { + {1497127512412966214, 11292269970549257426, 13920714718237672232, 1363993524078475237}, + {3687544717271789391, 14097532154250414203, 8367320351336033564, 11089672460564007700}, + }, + { + {16993953276024768829, 12025590727803527383, 2672535181364381995, 2183111709986676538}, + {14822521615475063339, 10618745739454592027, 9957515072444869664, 4797521918890127374}, + }, + { + {18097777493026370528, 398882723487597643, 10462164796529820357, 7704526739683689547}, + {12438059168025171393, 8163001730991802064, 3319372757738711275, 11518015261707325261}, + }, + { + {7809927122217534998, 6003738786706135597, 16541272992243715653, 11352602417510156921}, + {6070703545889058045, 3742828100079104877, 9416263310824977145, 1406892456840131842}, + }, + { + {4005088727670892586, 10215872293486093012, 7634075494800881158, 7707144163086802537}, + {7085702388211248163, 12168208652772836726, 16347414703478252736, 9386623607672009940}, + }, + { + {16530167766100505402, 14672843572926881623, 10752276706209340624, 6888427606311779724}, + {9060900993058482991, 10439396339124215720, 17640982730425880863, 12916411341252677116}, + }, + { + {11776245660806714247, 18129100488268011560, 15389929343761297429, 14544292652959164154}, + {18063319363114104433, 13433144948667100183, 462314076175867487, 1862686058702915115}, + }, + { + {17306422602774323327, 17272002328208118653, 9314885036861009829, 7485631191912561636}, + {1933835651414138452, 15231897024969540970, 507247317572839552, 10741595984991150047}, + }, + { + {18297797979313130180, 16976628082093243813, 13059060093619519046, 6865085966096869228}, + {15021840537243000183, 17843637254308940381, 13122764022765250336, 12556030904692962295}, + }, + { + {11175787671000337381, 17757097628648374409, 13408571223487217321, 2720103532070247452}, + {3237822932023459208, 10155101091021157316, 13910068101949253623, 648579517754264097}, + }, + { + {16597587101652675879, 3941450686064909756, 17635514250964078220, 13107347044039852240}, + {8910347370050088758, 3114023981351548745, 5209360756412143979, 8990623441581200588}, + }, + { + {7692284195082081732, 15977071788000084350, 3594719301791478282, 16545490512039598136}, + {7629535887569375952, 3241949087900065139, 170526822997903747, 3422990592513330514}, + }, + { + {5473399325468482480, 2511351254139828397, 1124856552206019504, 210074180589003934}, + {9693298849967626723, 16185054013081266938, 16070865229793723400, 734500463998096984}, + }, + { + {4895849847827915947, 15252720925614851036, 5944268852782996266, 8171510665067151601}, + {10594809041696466609, 4377920841124876663, 3816206760439007336, 17150624011379500381}, + }, + }, + { + { + {6266830413981331818, 10890859480409122410, 738708598357264321, 9241173142142102299}, + {9152169484987657321, 12122430118903337055, 14270062735458703743, 13877635605034675649}, + }, + { + {4572419849863661964, 16330741525817240677, 5456771007607263420, 8798510164381810403}, + {16547183593064549865, 11355135595370359779, 17581910791451710925, 11684604415749005488}, + }, + { + {2766130068233451740, 15909689412657372214, 3272828023364980896, 12907534005596438003}, + {7065629942275705493, 10609982651084321649, 17330343421617897811, 1746246157222856918}, + }, + { + {13168953859078137190, 9072500190247791267, 11090199374278127099, 3503847851309060744}, + {14395788825673846582, 15073993563711333791, 12879874391706003251, 15417028700542288171}, + }, + { + {2686132933630431595, 334448852204016400, 5636563341880055087, 3897420469445246068}, + {10569177829735084588, 8244586887721364305, 17973493209847502315, 18083956436923498083}, + }, + { + {15514509130323617046, 9833490355170899102, 12028021566105512521, 6349458533674010018}, + {13470024118569549588, 7867188201997717819, 6110792121234766402, 9917858515766574695}, + }, + { + {8273062939911446888, 1936638151089648185, 44602505720759914, 7839132833110815763}, + {13045756168264521992, 5375972549477973022, 16964151563535745964, 2871770426902555432}, + }, + { + {14164643693563803212, 6386904235704679249, 931435629437735510, 4496152555914735639}, + {820099532545743339, 13419988718062417698, 8948965620484833159, 7238410427920554862}, + }, + { + {4387941928212462673, 8023190031094282215, 12322462122895470016, 17311901330042910195}, + {16445894183838823370, 690424095855074674, 12820742226551488738, 227935274674223825}, + }, + { + {17437729542205914525, 8439533239207225162, 2862942422640746698, 7340866642549630610}, + {6770451500989398335, 17262212260581413381, 2156505157624055602, 12195119268846383898}, + }, + { + {13685370053507732180, 8304030489296890211, 7042719123662732989, 12115154796394040286}, + {10496877583013829980, 8909625177349683785, 5268451666475070682, 8910488385056259560}, + }, + { + {8874918984373509240, 6652428549855789281, 14866714872885601270, 12093494664302554643}, + {10149999253136441007, 1611873554177023520, 10271627298853910516, 15171882630355491729}, + }, + { + {17085353800722834618, 3271271583189511718, 9338466116389304614, 4685545953421459012}, + {5059702655119414343, 201476627889215522, 6388612869673101372, 8357217932305360896}, + }, + { + {1836621694151238424, 11438765101326043062, 5537182303007083642, 2657011195641217678}, + {15370176245454161308, 1478361893117141052, 8729368992402422055, 4807782542738120272}, + }, + { + {5084555197036037383, 500829604818691390, 8128181767026348964, 17895639808733462562}, + {4138748420878083709, 267892430674902987, 8954358455330696651, 1946224964877667668}, + }, + }, + { + { + {17561670470565298976, 9524122142014309347, 12619871254022879995, 4098610542031538614}, + {8338691110372464881, 4378598564044777665, 16435680634249352743, 12067828180476756532}, + }, + { + {12574920924242276218, 18146097977073890534, 18281543194137545725, 4432773597060264867}, + {797962164984225968, 13432184750641235201, 12394976215803938078, 3054137600383896411}, + }, + { + {12910897300898239001, 14116919300756610521, 9737100313909655285, 8792063194563201934}, + {924297264228895146, 975866810375743708, 14953819883516375119, 9992561966868201517}, + }, + { + {18270562314314829224, 17574550722906577917, 15522987576586641271, 4200899284963891561}, + {15719788437321868967, 18390235318178988753, 17371818886753265385, 4583380351670429228}, + }, + { + {11290716045321163897, 423611636875887759, 8716385793549629027, 8029377844845093468}, + {16573848460451650185, 15094868140191104543, 14624483608434776103, 9086586764934160662}, + }, + { + {1320522168839874087, 6395673054871725696, 7793960979093413321, 11402054451286901177}, + {17278080290632229040, 3823680337747309837, 7840042035002848151, 17839593774203285281}, + }, + { + {10024545625018137606, 3780616370895328213, 1516632588067435378, 13846630703933575818}, + {14323905768888574358, 16062987352815864444, 13444338098535013457, 13400662018607341910}, + }, + { + {10102001197913431240, 6211688443233768420, 1986665099237206297, 9248907879269017005}, + {3081890249882755206, 7828527646248386813, 12676034092230326487, 14655968027461080131}, + }, + { + {3763532248936424432, 13507960710132312440, 2003243330622949364, 8723351916784911918}, + {17411870179533482591, 495549359712213584, 6958432541445845486, 7674356092204128350}, + }, + { + {11814337248412299972, 9347461245743305200, 15456560932072269534, 9579754357941936175}, + {2098168907840746456, 2063921976437345588, 9267808714920405578, 6482702408130663270}, + }, + { + {3313415711246730386, 4607422129142883607, 278072683866121896, 830840258180061490}, + {16961959739026004139, 7896385585906900106, 7610238284391475173, 7231671772874233939}, + }, + { + {11464797300361906821, 1444449385286554508, 12433005157477847389, 964895564896662942}, + {8457290958728547067, 7044433897330872257, 12292673928275053405, 13679355097865192207}, + }, + { + {15352304695586484723, 1527883079108513336, 5890042963344522083, 13407971103520766077}, + {12385239629152188662, 315706510218287516, 5361117161753711484, 8824676525356150938}, + }, + { + {4555925933619499493, 14889603365479712329, 15898222225673484215, 878884802170861101}, + {430001626591485427, 881428142547721183, 653855015067704092, 11378990354467312809}, + }, + { + {10219225570653005145, 9205374019534090202, 16828986596058027743, 1089575570166892706}, + {3079144130112884386, 4682944567048139400, 7674497449298779575, 14137535283566239898}, + }, + }, + { + { + {13266892287530449189, 2232961926857263527, 5934654989155432442, 5415975493246016158}, + {17117784386882463158, 3875398271691758986, 15755743581177209843, 11380746535012415659}, + }, + { + {10162459499000477259, 7534168794800651527, 6320985751131807192, 9263840233901040421}, + {12178625283764017250, 13143797113231152006, 13089053551699608219, 13480464010111258056}, + }, + { + {11426681347395118622, 17135867298562042628, 10870734720453621112, 13803364322975322217}, + {9740527283062276630, 13765238480893165263, 4792349632705804116, 18359029140065847048}, + }, + { + {1420251412241033168, 6449255753238336368, 7468624722117319576, 5716072259994197219}, + {8165015263320602150, 4757529151848960259, 2040364517493350115, 11069642333484542749}, + }, + { + {9434687670958330812, 4808705744496679962, 13910334628239183613, 2628594509406050235}, + {10055911465166862298, 8069256921143792190, 11886968715847498191, 6351594160398684406}, + }, + { + {5472832021993175857, 6120966193470238758, 13156950075464061259, 14833372202848630444}, + {5760885723102571027, 18022572190906170343, 9870918995920897221, 9546055667466056471}, + }, + { + {17124591880405051324, 3379747334483646957, 2084957978131092947, 2413497199486596627}, + {2867893699156486423, 1357836849049583382, 13607307985344221035, 18039194570940763745}, + }, + { + {13230815692170010235, 10662664037814374845, 10120384214921531334, 8892863196093018212}, + {4443096401408136417, 1896901619181196514, 739574867683694091, 11233952771600927581}, + }, + { + {13885878918475208407, 18415131106660406656, 14362601436612948914, 5740711586144226035}, + {220574937152712384, 16774016249557318959, 4658351269477373440, 7890975779439252404}, + }, + { + {16628715286876183012, 5300385226682547206, 4493053153469218188, 6690552861098862065}, + {9359345201611660030, 17390357193161728482, 9283655448484665614, 13747647357786913441}, + }, + { + {3101241556869117917, 4731590937333975732, 8347709942856514723, 580858462407103829}, + {8937550160715031857, 563888416351720575, 6928865729903641398, 8295908905021542009}, + }, + { + {2219303446125808132, 7766409607764464233, 4492816761527421087, 1687012079818776091}, + {9967512906892097592, 8099397263797608226, 264054732854154094, 14515622825083967497}, + }, + { + {10586626338424063837, 11285305220583812031, 1552873676034063335, 7108571382532772330}, + {12077600502438115659, 4925647731241250576, 887903929602864140, 3575833277214438245}, + }, + { + {14685642695197717757, 4830460343095831969, 1748938116371486214, 3212377924501398108}, + {7575821759023381902, 4416593227203343304, 17810665332121047202, 5387420006905173437}, + }, + { + {8644732068940188724, 17116805484232699355, 6611042643736763845, 12686480611232016266}, + {13422256101258226329, 15901664205323922499, 100273141428472746, 3184681836469139902}, + }, + }, + { + { + {2754563581284692865, 11257360722362829387, 8254261291934606879, 10023569920325096229}, + {7980898855627864603, 17162063449612285703, 9275759455936104363, 15936804738099638644}, + }, + { + {303387668469489035, 7978391052264888020, 15413722057350324494, 508608987485166058}, + {5585753287556892522, 1344134516582665443, 15144279405777509214, 17014353449841567149}, + }, + { + {12518577022215294774, 11347384788122950558, 17122718824958020364, 5431993665805279177}, + {1445831254446028321, 9845654210244803480, 18315778529692612284, 930563922336183289}, + }, + { + {4894710987714215219, 15704993603878996107, 1606204036324478223, 14308635149530198932}, + {5026736228773269251, 2911689442372084137, 9004077539360196849, 7770049130277452000}, + }, + { + {2745120518194234905, 17255944807561408883, 7371907591838942770, 11781525288383871227}, + {7814952754785494862, 15022715213812536212, 4112388658963418656, 13703771908397991335}, + }, + { + {17455440140812341569, 16738670164475421762, 13259904130186215994, 2168106064304872507}, + {1969289843772256992, 9025317999701057831, 5835661391798891929, 3826587698101558069}, + }, + { + {9149648374608464235, 7248346993716635643, 17283919168525322365, 10107681064815728795}, + {12176813938029507719, 15110337574289033068, 2436453685316043712, 5876967059744625564}, + }, + { + {6197919059881189313, 3300993078638782623, 9357667752372201437, 17688129755135009447}, + {5477090746558113696, 12602024521188880300, 15889961935507293355, 7135039746373941272}, + }, + { + {12561063426893244305, 3079971284510744316, 15695857190375815873, 16730673956207425338}, + {12065477821845465116, 13846158368121919228, 2126156187526559500, 3005167441915916768}, + }, + { + {3858987859895327040, 17043903959888117395, 5861237635520080595, 3292646198413575902}, + {14286644557048422360, 14346409530388980974, 12583555046601155161, 4665981927428063991}, + }, + { + {7657686120974201842, 2388299767028319466, 17934808017791217639, 16708640707026372313}, + {14122341266134976486, 9547124998857374491, 11194069918436025923, 14657538980930727877}, + }, + { + {18115789712912297420, 6543740714573413570, 1955886376702349613, 14736853369719086334}, + {3914330395250768396, 7607848156418885173, 18220633528980056514, 11930952850158858930}, + }, + { + {17010681753474701341, 6961088634819162945, 18395881317121515295, 11611411242007267179}, + {7996717433149311639, 2687736005475404867, 15340214362731923149, 7116441414289074727}, + }, + { + {14302198697220662403, 11915041511943922518, 12363437164440173650, 4047410026894059083}, + {11439743031696133447, 8776097395071907030, 6851061783357383945, 16484733576581941012}, + }, + { + {2861660066704264713, 16453202148771053225, 10039035813504063627, 6275446616881871868}, + {7150609984920482782, 11100941755544354363, 6219760433202580646, 2875377482232912143}, + }, + }, + { + { + {15290817014272444879, 8012864091692295774, 7591940515496590516, 9299619125326026848}, + {7297256232167521068, 17861204372399797627, 3100022958796565106, 15313770879200204613}, + }, + { + {9902363248877274636, 15776195244792726061, 1935342462634574355, 16572507349421626602}, + {7503944294807242065, 7454248748618678609, 2837392985175901475, 16494567631149775512}, + }, + { + {7821919851875204434, 3437243050078433703, 16281279739393410040, 3105985403882097775}, + {6392071520880083076, 2042340026857542253, 2492719020444109453, 7325465357665053546}, + }, + { + {12299242278498309265, 117303082144788574, 18382936515565701803, 7941141688858846015}, + {14923823358299367958, 15681089039073030752, 16878721085421212785, 3933697483394042011}, + }, + { + {17669228922922186836, 6423621568318435743, 16298886067880336557, 11009276012664659704}, + {2934438101395245878, 7492928446481808311, 1311515713186855284, 4493146166488261630}, + }, + { + {14009653500169461120, 12982754496644678513, 14586034645437015762, 18126832542767444974}, + {627541781236454235, 3801503508930355635, 14654684147782092084, 4179096323459534629}, + }, + { + {14829342742512426992, 12453047655591346244, 13146459409240287380, 18077963306248855764}, + {17149389409735171474, 13591892902058002302, 13872587256559899629, 15878632005942819501}, + }, + { + {2878536922988449879, 8819365314325664735, 2696760638950720974, 11357179421800829605}, + {14730809809256560583, 16277258726425730599, 13189689275745970592, 13769784951430309444}, + }, + { + {14706229979050107962, 8679247682181027680, 9705538653507374238, 12793525936716723768}, + {10022723640772366793, 2224403391050849804, 11511158380587667232, 3250960576892370870}, + }, + { + {17671892277522139639, 1384260767972381005, 7623504419117295292, 11197930232971575240}, + {14867469242175831789, 897596747715880677, 3892483173599058531, 13453254609965163080}, + }, + { + {2690362926234343281, 12134546410412600166, 15715872358030533545, 18160163251393343275}, + {12233720002415141519, 556081697748597124, 1099809960955937522, 15489604457800724223}, + }, + { + {10292669945637125918, 13595563061674492799, 18301330068714272653, 16981073598172019270}, + {4022713583718555211, 847970754090163894, 12867993617169467387, 10021141621864633865}, + }, + { + {5408393826294570360, 16896935186698126584, 13028972412622343885, 7850626233281656805}, + {962076344521148275, 12332350290936839731, 1774588207039851940, 17877147526933423087}, + }, + { + {11625440764115934244, 17372224561416726989, 13457342366450471135, 1569549943944038472}, + {17753658357081801983, 14093490077993040859, 1282770820260996510, 16402793994329437670}, + }, + { + {13086054618104175873, 11714492854942191582, 1743587223054035136, 5474094059388998723}, + {13150833497051757606, 17129392131927259958, 5739140380294248045, 10239738807213437974}, + }, + }, + { + { + {3631886121917081375, 14286411187847401959, 1546298555066841633, 4790996540037176549}, + {9541492152219486842, 12304868498960755609, 11426775785781090329, 10793898029125361155}, + }, + { + {10932352970046201499, 5875690226460998551, 3699681560657289718, 8665743594825198441}, + {10232089728487302472, 15664572298733091969, 7267222702489958195, 10552093353886118696}, + }, + { + {4008236965647744142, 8547116629188387980, 13874587567755370880, 12696453513706541959}, + {10752386832421030566, 365775083075323708, 14295272684753058141, 11024897725724291722}, + }, + { + {2399232949134869057, 16408469118941953277, 17229778225562184411, 15990256768949242309}, + {10694906341686584836, 2816242351659628719, 10794163145486835660, 15601904974333104002}, + }, + { + {1158521281204350113, 6232098057848694897, 12517518152351190341, 17852831094628421272}, + {11653774695260269881, 4420518556213490728, 13835371272800239099, 12119809446886544909}, + }, + { + {5143546864201185527, 6400878864024957342, 15513803558106064076, 6712861984922181478}, + {15623960351786428150, 3094277713920675576, 6184647748693682810, 7857605928718754519}, + }, + { + {2219152199405421709, 5367881810186787185, 9606063680551349934, 18233690822105957780}, + {9941441403610160291, 14996958158691873775, 4936282940888570414, 16608409936766385729}, + }, + { + {13270099407878039596, 11569032926557804346, 7759575992876193458, 8239088820951102451}, + {9633607727685959064, 9775909232917811341, 12297921731498614906, 14756100221590046549}, + }, + { + {3076166255574886489, 5587891405059542759, 2449830540875545916, 15616237426524550707}, + {17820334717580127167, 11506219580693301288, 15242532286743473103, 3266057695402840388}, + }, + { + {7193168093115966016, 8050992763687139302, 9734357192061785185, 15553552690657851227}, + {4632257996795951659, 1007158456255834509, 17052740163052114844, 15619284827675470063}, + }, + { + {4224824291132201768, 5709863556852834901, 13539485156399791894, 10330250853413634451}, + {2817020820518906625, 14306724568884734914, 10421968182740721623, 6943068506740047695}, + }, + { + {10830476567180688368, 10003074695797360184, 5589380226277136479, 14952961630386717087}, + {6354514974022878533, 3426762794422332369, 17950815054280597743, 14940277403242978595}, + }, + { + {14582622177810553114, 2819236216667324430, 11333005326119114902, 15900677556115860419}, + {12265999577465855236, 14521351376076108710, 3999293994697120555, 2365385934872188434}, + }, + { + {1803647016552158312, 12981833819573589527, 11371133227762071, 8210800033974528109}, + {16927172347295306236, 11674533305143999306, 1514600283696801303, 17036724058500952986}, + }, + { + {15551380071341300893, 1378878534597097794, 16601031904934455368, 14515377519758777108}, + {7039813638645241317, 12524221355672362377, 10483072291636269482, 5711815649533531303}, + }, + }, + { + { + {9246769514475702626, 5788284997389507365, 15857897362850327403, 13864676801095094218}, + {12881526722328523267, 2620841421323221200, 12599981775316397124, 12820989846844560040}, + }, + { + {13066648645100247757, 16727492115601921665, 15749471761440498106, 937594351871983779}, + {8381111811209734349, 10884357918725639691, 781591570669492079, 12778743765298428266}, + }, + { + {1797915488494232282, 17274756142259274463, 14207994319179101777, 9405903752538915237}, + {9001743317941152797, 15048752608061590843, 4925745663463425863, 17143694017177138485}, + }, + { + {11613437975225156304, 8619196433402562266, 11907033287998837424, 5056904365610561965}, + {7637552956459333558, 2827449950719061527, 9998507085256853501, 9238562885525900325}, + }, + { + {13246436769495027717, 5445015753017977819, 16266739009580878036, 15566606095998238977}, + {12196078605380432771, 4854324313875295137, 10974170498288217052, 6425550765546527417}, + }, + { + {14574824159194628650, 16992289415800830701, 3499062703303067574, 11220872042664151226}, + {18135860701984580530, 13630928571014923388, 2913126838766947469, 15869180955632349704}, + }, + { + {10621010745328025245, 14637275395423748577, 12928463178963493980, 3270672471462681194}, + {11765440832075775157, 8138439106739837848, 10004644076263261924, 12582897670868871780}, + }, + { + {9605391611675301152, 14014632424042523224, 4638465078692570733, 3013469722048440965}, + {10972600060210514686, 4497572559400894366, 2652629676209366276, 15827846806499715082}, + }, + { + {216774559418075105, 7056732230404238374, 4342481467357759950, 16143194646968227790}, + {12304857685680249595, 5021239809847286634, 745754913624924064, 1603290801266214539}, + }, + { + {2784418922013631805, 3554650219010546629, 8896448905401216908, 13445015286698819482}, + {6508982623352460996, 3322529327934132311, 18417788670080975365, 17554108945303789353}, + }, + { + {17620122226715347133, 9738429733440215024, 15577771434516492888, 12422193389576942718}, + {18383756008252443605, 12736926759685644351, 16981429110294392086, 11999528928951986433}, + }, + { + {14489177617081844909, 15995916840320959685, 6361381313838994395, 11146176143708648759}, + {17190512001934479207, 8406914945663974955, 18073221191428103088, 14075266763636071788}, + }, + { + {11493260321718935244, 7134447477334726345, 10489281872281557152, 6145540581503915475}, + {4002857892747271740, 5167943945955725680, 2892864850826359384, 16887114279977647596}, + }, + { + {16493058314197913501, 14642843949567816202, 8421201635021034279, 3645913604138483317}, + {6127272877310948153, 3660286308390076870, 14343325047340052700, 5355450922054278073}, + }, + { + {8426383571761073988, 17627146217941553397, 7396223609641674418, 2402241526082789613}, + {4067059813672963823, 10306840429023537942, 18342506396531908477, 7249869764848707701}, + }, + }, + { + { + {13937553904380032591, 9165760362893872288, 14159606902675650669, 7794101517494576908}, + {11994596892880464164, 16211278212275417034, 1568324133241165712, 6579463633356173526}, + }, + { + {369660229032730089, 11851915833529805698, 13485269529443969890, 1270120511649175022}, + {9128783725626301238, 6173048611666804214, 14151404531169195672, 18241008099921643437}, + }, + { + {16331025972320545471, 6852381640421896437, 9324740413214863495, 15718339035381717722}, + {1521756232012903545, 5431459367124818841, 5364830919043042094, 11104748870982011750}, + }, + { + {16226789363155700046, 13734705589524056856, 9629995513492843231, 2636144377026081617}, + {1233405076007260313, 2119672919365858964, 4932766292290315579, 4185117177904214366}, + }, + { + {6556637108078954923, 854911879338322327, 17335608616262058670, 8212786550755149003}, + {8111194132924193031, 15689965289081013375, 16641361924274000294, 13131032775030004856}, + }, + { + {8653575060724839982, 11482527594744353256, 10837608928215660048, 3651629796762058243}, + {7098570919231943894, 16903422906687575782, 6449467519885582678, 14455694979526406871}, + }, + { + {781149662684377075, 9606778745577048892, 16642923833572014687, 6804945833779567806}, + {7749938807818369385, 4119995592971432914, 17172069782410404367, 11558710124840085255}, + }, + { + {16996170392430604056, 2476294162951949891, 6677439492116109133, 1649550562276235959}, + {7307278264575968221, 17128676264244010843, 9768062299436691373, 3825325732056225433}, + }, + { + {6593955722549970555, 17069122731812152854, 9033349482403834703, 17728559655579364768}, + {16586780540128534825, 13307658170018069777, 3129405955501687685, 11183053750385689524}, + }, + { + {396019325068553604, 11523268935121791712, 15099363117146465288, 15263791092270534216}, + {13442484747453660303, 9234120847672647934, 12419564747087042045, 11765927783051357577}, + }, + { + {6946885342337567475, 7614129273290805579, 5593360004251714058, 12661112521307810378}, + {3109170497657341517, 17179338146382046416, 10757457188650866858, 6777926602245453235}, + }, + { + {5861627228365499618, 5011684805137210454, 1579621475012951778, 11535371650014354624}, + {12847902922833318241, 4997014846790385136, 9875988184618650628, 13094082946822736823}, + }, + { + {2372542806512167707, 4770713673953713652, 14348746494327256696, 7497346441434630132}, + {8937635379675246570, 8485257033326447249, 9021969910533595955, 17083952234675640995}, + }, + { + {15253158548483712314, 10967825792345015198, 9742716807127259344, 14359543366972625129}, + {6622650705673586588, 10738437674137632549, 1628663686364470696, 6788821495127737255}, + }, + { + {10456049238997614164, 3762844951386993276, 489305084297229810, 1360312650067674972}, + {11869321173985817492, 5817931657599210177, 16741327479242559412, 1205037582258757668}, + }, + }, + { + { + {7109145612337154341, 10502845970727626855, 6527587047878193251, 7049690136888681718}, + {16750703006415156202, 2559311261501721445, 1222802194566919230, 18019462938525560766}, + }, + { + {2592184418896595488, 1723751460114310463, 11198512454461769811, 6203707848404803677}, + {2601731234271436477, 18186700975610533226, 4757569424831899615, 13359873383138312209}, + }, + { + {13904640252203718708, 10747313134117021792, 14667070697514384141, 2600977347774743546}, + {15498986940124021079, 14740645313274577011, 17403811028932224808, 8060102076475954685}, + }, + { + {12990649636107730851, 13002224935892458030, 4380799638612122791, 7935443787987894924}, + {10438069978940053126, 302419699431148366, 551508078777729872, 366155636877501719}, + }, + { + {14734735764746786753, 1378251478826083755, 13509550209468602124, 14458158239096821346}, + {5681313138148713219, 9054039627425609375, 4235536482830620712, 1502753755874778370}, + }, + { + {8914021876030553161, 9071747156187788379, 14974736924255494885, 17070198435868341999}, + {3643991391224035758, 260637732328275649, 17609644917816078225, 2302996326941944665}, + }, + { + {5888744936142942064, 17277140802638358763, 10290028650289820825, 1940657436863195045}, + {10796401239257150661, 7788083050548605852, 13474393003015663489, 8961936186303685357}, + }, + { + {16407225233842256953, 13423683834633513951, 17454464203550700633, 6033758555290610449}, + {5063673994339442907, 12250392784929419939, 5954485814444410119, 10099095370725442279}, + }, + { + {4687621216548073298, 12683256962895584277, 1406415612737291460, 3991320149877222007}, + {403384179417053146, 7072351635192146705, 14388831570324308780, 2518546598792352745}, + }, + { + {2866701220158780648, 14345701180700655413, 10383205903323525163, 14561034237887346332}, + {4525630512028460468, 7470042867870921036, 12498636959757093905, 14959680069767374094}, + }, + { + {939355076355747784, 236998652239230884, 7862332576114728232, 3008745396212765985}, + {16892515157128448879, 1688671543548974140, 582235491724828261, 2879861045707356356}, + }, + { + {5793581539270397654, 12067972155882240315, 1914416028486337582, 2044052608129533771}, + {1045680055817519578, 6183307954634642810, 1115903654002488241, 9729229622559998051}, + }, + { + {11505233554542243613, 13650372171621554098, 11886401428750724176, 2616122636264787282}, + {9807875738265530891, 2065326856613209663, 3841177149705795822, 12478836916087572836}, + }, + { + {8725096612265348131, 16959754534248500306, 3934616751368449170, 887912345061829880}, + {11410178859948957868, 12867384504930748729, 4367798270196663137, 4359910421693489126}, + }, + { + {18221589825782480868, 15875305463032670629, 1054133002549446970, 2220911650204683784}, + {10874691797030180071, 13903803155513130100, 14873882741737344436, 9374498718172057556}, + }, + }, + { + { + {4471613312912718060, 13601785177495103328, 8083849806888905297, 9053545412554844461}, + {1876605639999952155, 6124537911475118673, 16877891074567085688, 16541720065079132344}, + }, + { + {18138305348849897995, 11498878557125400853, 14125346336359365201, 11991638807788804369}, + {13935355764550912568, 16209147067155729660, 11086190285777019292, 16727288863943596410}, + }, + { + {8873152377611229668, 6260821826956744083, 11489383533808918262, 6585112195310961861}, + {7365821041919648819, 1936165695028211587, 16164747634991415711, 17957320776652490392}, + }, + { + {13065030057172289846, 7278765836407486850, 383827150208081081, 7832055893191054601}, + {5249323286889945617, 1631661912887095912, 4431088469837785451, 2866263172993336891}, + }, + { + {6140213328062333551, 16704025329777067037, 5839832043209342792, 9196354634862869885}, + {2735762290983671190, 5323501742548818139, 3199127466610501482, 6719610946615763192}, + }, + { + {4032564124345275293, 240208626666701335, 10264845378648897042, 15608289126091352415}, + {17866864241918154829, 6207477318890336372, 491708931325462670, 7002400618323099260}, + }, + { + {11507747783030541234, 13683043390668171754, 9924966309328785763, 5549516466627385909}, + {3724001483041449858, 2408778220985427590, 10510707601023430105, 12862520912519186496}, + }, + { + {5012372868660694231, 12033652755433827667, 5960732801180177919, 6089487525155575261}, + {18400192045204062277, 12754175136438960528, 6170965736016609163, 10141374482047067946}, + }, + { + {11781193922347227447, 16937876011211881637, 2982972111293427964, 1728244726890919596}, + {3327997232304084768, 4754833121145407334, 5871027825507908591, 15772493911709624273}, + }, + { + {5862944033912881884, 11132730978666088350, 12167180155548291888, 16449838286695349787}, + {14399676610730016345, 17071083123672650337, 13727728787831175379, 7507765123422748291}, + }, + { + {4883057314704644529, 6606742732149784343, 16070555141087563722, 8408294891669305261}, + {4298316003054547788, 1573237855902568238, 5357176885445018289, 5855732582172939202}, + }, + { + {11721126538980357625, 7216004194033429913, 12765889884935948315, 6003399149613653734}, + {4571046290325663920, 15023470461830485075, 11463513436288928362, 16135217522406374542}, + }, + { + {14300855104129153291, 11491527690078786162, 5674183453812271017, 5044682546652747711}, + {9153978680942338831, 400454762074409409, 12351470849648616331, 10559229320903248832}, + }, + { + {11839166519633311143, 16489041153719856002, 4820713204385149226, 13768001962143023630}, + {13107713406478328396, 15471245828032402460, 6733652296473831544, 7665657127090105428}, + }, + { + {6114372925011600760, 13061069979571997963, 12156991017966837826, 12403009591138383583}, + {5761958709898299258, 1907771304051897263, 3007439379929412593, 18410854883912163962}, + }, + }, + { + { + {10153847769616409178, 16591913677701651064, 11369151065084080884, 9493662847124813178}, + {14299126668179023903, 2451525064998641745, 16055696673728703463, 7600736037142850105}, + }, + { + {3339871688614476269, 2937156932445032796, 2071344655111136329, 509603454456841298}, + {10929109734329673813, 4531629375826317764, 1802431569220697099, 7971315018970882891}, + }, + { + {831440329504272059, 17398063681351066636, 14954668702259408996, 5717183520144440084}, + {5683898996859918421, 9613688159291425744, 14476049487507222229, 3689544236835488368}, + }, + { + {4307546666223047416, 13914498777427309061, 6812156124789414732, 1680174913762530491}, + {6756325174405757110, 2535144759174364990, 11263393915003278429, 14767595249676286403}, + }, + { + {16671897597823309975, 8846923580617118936, 16420413907022376284, 2344779928765541883}, + {13727655669851883280, 934227091954463432, 4722713881950047653, 11812583008287470589}, + }, + { + {5321392406277114518, 347488367118035707, 13877286915167943316, 9829617275563347891}, + {12220860524024630629, 12190721936758412489, 7308208895364574537, 1525158119497637419}, + }, + { + {12984508126047021344, 13884472939864196037, 7382834581395586970, 11638480609720520178}, + {3822030693056621440, 16565826187005934945, 8411123762207988382, 1177726217844912325}, + }, + { + {6981289090623415465, 8930069945493884157, 8223216504978132408, 796477795300774057}, + {3120155459209743472, 14825603392456550470, 3711879425019804830, 11041054473536223927}, + }, + { + {6533202055887887500, 8435346764005128028, 14910943752455571727, 12906760590440667071}, + {6009159206340842586, 15232286290711710102, 13101554303130256987, 9535887764075322183}, + }, + { + {2364828287094520952, 12465747625792776806, 2520175043973011525, 17224593222741233568}, + {1891958595100476046, 14167979679885431508, 6587293950576996181, 438078840840804918}, + }, + { + {3740623254035318453, 2026091438664349886, 10842473205058238690, 5471257179527938221}, + {7725900701946760330, 2830662433803069280, 17799722315873409980, 10759084277615005300}, + }, + { + {14135544350792474553, 6171419888118563156, 12495035851387242130, 2843310747449412555}, + {5668766087526340552, 10117858698838396246, 5181027414039980750, 13247490124270426}, + }, + { + {5630566354382744149, 13019515676216329576, 5170054423571001981, 6980215251505169036}, + {12147009277250683724, 5685374899516102781, 10470553909247052379, 13479624060240397189}, + }, + { + {9352291669847160009, 8941401423217216209, 14488820078509299610, 16185610851702419585}, + {11995025321082820298, 8447817180287020945, 5861763576711981236, 14278368152612939946}, + }, + { + {17266177108677586607, 54295173557875478, 6565771227548453510, 11327083086584790599}, + {2516266639353612660, 16450448808532150212, 4693041555468884719, 10262468795248362309}, + }, + }, + { + { + {2365455792963674834, 2249234228455309648, 5237136544555745182, 8814246419234451463}, + {13017813702607013347, 2241193992640629733, 17982226236989862510, 9800528153239873634}, + }, + { + {17271890190678399664, 284117971978206043, 14999643475704678808, 6264699496666119083}, + {8859934981351804429, 8300880062060532031, 3667839168820458685, 17133003164910522197}, + }, + { + {17791633957402883820, 5938849497629314459, 8356801465373786047, 3163889445599730677}, + {9723709910898285412, 2841967670768995554, 10896757438566636700, 7434996874241771203}, + }, + { + {14086272070125896854, 12009239107306499026, 6592816798466831203, 11371087141421707743}, + {16277593907837607793, 16449564916599232060, 17471042072158213549, 11953382410698485455}, + }, + { + {14613304240735929191, 7658770973133328064, 3028731168325633068, 1486737152001467114}, + {16715835021406106944, 15214200823642287507, 18441898204110447697, 5669963154424393607}, + }, + { + {8381651800836461905, 275661552864412688, 5548629401959193001, 7174991431295718071}, + {7441251258233899268, 14052832476485122412, 301250917807487282, 17797202428295526090}, + }, + { + {16448089571044203401, 1396460397790470601, 9796571033221459545, 8162511506983092708}, + {13893406727199803081, 16188892369453405032, 16023105002157964343, 7061289566170423383}, + }, + { + {8743817608749172620, 7804846024944300667, 507107926259802795, 5258061329638283805}, + {15071070675288472598, 1848743106176521296, 16295570828486620412, 7409462376590083349}, + }, + { + {2825832734356158434, 10662490421734807455, 6363563030616301959, 16552149102037287266}, + {8852342875874616869, 16848248230809388411, 6581680050166700198, 245046966305064563}, + }, + { + {7828655274510399422, 8354801505584011854, 17818478328917068523, 17325245990806811268}, + {750899848242404370, 6729023687199559366, 5406329621088392947, 9196565205678366888}, + }, + { + {8064539304829538257, 6441901327220658696, 17278408443193767018, 6094106832683864460}, + {9824329910822370076, 5272517980512991724, 8211352561755619726, 16303987070546290759}, + }, + { + {16798983177239698753, 12189491924433050580, 9517619110936281609, 17570406314312177597}, + {9873809692789257777, 7539953961664846819, 14652839873293130968, 11082914471633564328}, + }, + { + {5471221015674785794, 8844747884377425274, 10084666525179707178, 11340747033059217003}, + {7295797213045550755, 8395678759725657352, 9654316500807954493, 9062353099996695484}, + }, + { + {4588282548354659427, 7317148840331807496, 1344326657487996813, 1542409176821028318}, + {16178223850158437787, 14916858636047869579, 13512744779273961596, 13549205429423761570}, + }, + { + {12307321769285447055, 293357554223804370, 1007020265087773203, 701738899338647839}, + {12276634770118212432, 14777553112070534726, 4541693432120405052, 9103025487888313415}, + }, + }, + { + { + {5757832545805155636, 17609080533053427627, 13855662030602089892, 9622498683452213297}, + {12281586442064581946, 610529441714948581, 14740357477019436626, 16983190111725558863}, + }, + { + {8470173855499872166, 15915210069852758660, 12368087246231545517, 3867174158581293223}, + {9082358201271846042, 16663463402757176964, 13740908859955866819, 7748969412274962298}, + }, + { + {13375424826931892789, 8508645806391261552, 18359272328758476903, 16433208398005282080}, + {13071423254987294580, 7999383023651164492, 14514701556577587750, 4848295889377673720}, + }, + { + {1020519568493754982, 10467781020270669620, 17607771250627508499, 6620300538436640218}, + {3858527175523168333, 13798129597334232823, 12495322651937391008, 3926713306087152023}, + }, + { + {5116038770086590715, 9943789276328255827, 13715439407309914230, 4887040860130243503}, + {18288477612078228131, 7640050573721350378, 14537362862524718973, 1658575506924200900}, + }, + { + {18400486168653423966, 18026904540891591040, 2037921821724043966, 18010956304511658647}, + {3751340308708032971, 16275459031633957091, 17177866831427164840, 1635431811339422016}, + }, + { + {3897330996014812355, 14347736534650088376, 16862404119462964612, 12216005411754788835}, + {11561909516001453735, 6261639657930189859, 9101978764314050064, 12280333151331067982}, + }, + { + {910276569977357717, 2872810615152156462, 1942106118995935911, 8734004121981822024}, + {13862118436432879698, 1912639548162720505, 13060137938875924732, 10642216911059510120}, + }, + { + {5132232031613377471, 3053931945527415993, 2695169719602504430, 11855046366025891084}, + {16462491222215366712, 16664416596202206835, 3077124688577987843, 7109495326459366311}, + }, + { + {3858762384693274897, 7520194928987242278, 4496744297661574884, 16159343214247089321}, + {6441167128044578145, 3604951495694157848, 3072075325567814428, 1964798869371174506}, + }, + { + {13689578474000942304, 8998724267038772595, 3350174507425430811, 15015413657749135511}, + {4848907595494161497, 7935644131326131098, 385849363817229511, 10087353746314516691}, + }, + { + {6067717601858189468, 10438404859927821308, 9991403870358837471, 17728358586134467771}, + {13476949968946830198, 7311235997042381570, 4429835371823736972, 17463216455983091974}, + }, + { + {3446799583712077997, 6763499387263152328, 9231082163128267527, 7733182914440272884}, + {17225092062157610409, 8163842076250628108, 14230171836718858439, 8195740716303697476}, + }, + { + {57759226194841354, 14962480748390190557, 2047254208877381876, 2830450574091058648}, + {14905486147404440754, 15792397930637469157, 16383409053580142957, 8686506861607761226}, + }, + { + {11120178572139812895, 11534611317577597022, 10437856602660752754, 13925966850017814278}, + {16776862023867799947, 17362554889424346260, 3408825299914455645, 2606150045870067742}, + }, + }, + { + { + {12109367644744157376, 18037756988516427980, 814572839386760074, 913616818805172815}, + {12974490864633240943, 5228203788953366069, 11458421156905635350, 14534725545904442520}, + }, + { + {13918155529832261002, 12953608416498491778, 4285102780598248527, 15853935066983430239}, + {2610351403194505517, 14905969693015035277, 12043976761492019990, 3883507340167876094}, + }, + { + {5439519346074792827, 2176389624009388617, 2631244572392601375, 15049241095214776941}, + {16292195309463965431, 4379169091046493311, 2454237863606964835, 16333960950959567989}, + }, + { + {10994470105201067642, 16033352651464686189, 15774427704233149170, 4596106024708523955}, + {8854068685612048031, 13529126595187822090, 11509928293490788309, 11620850709434334690}, + }, + { + {267621988570094461, 10587206279243947181, 11593510291287574067, 14787400314862354894}, + {4136983718443464652, 2976380359687256413, 11142324903811863489, 4610908641771667701}, + }, + { + {296274281547444433, 3085587185113256560, 12609265193181717917, 4535801536028989527}, + {3096496338675531142, 9292526016029159200, 13112825412047135381, 16663099831183411702}, + }, + { + {2767353193349225715, 8712112934471091092, 608599382922156785, 4028449356066786979}, + {17542394472389324402, 8680897831809226389, 7666317335732585298, 17261030852301003617}, + }, + { + {2068337952936280662, 6856444059219131741, 17213926210819196459, 513413453513211652}, + {5520465604253824995, 12970886588014924605, 12296275668437451137, 16808287251356954962}, + }, + { + {15914937173048753781, 12510295026185206015, 15954705664179129326, 9689253582699600268}, + {15356442010394775998, 2438265211465631320, 15141425278420483672, 17026865278332658671}, + }, + { + {775118291486058191, 14811108570252044526, 1277462327112210144, 1303109520734915949}, + {17662756477349124684, 3447822852149651619, 6150341860560710757, 13223916277431807977}, + }, + { + {9324118164416603919, 86833914568469678, 16815316898277944489, 5015780480822908208}, + {4077581079810359659, 6644887514971920354, 4892606269782662646, 12780428915404556278}, + }, + { + {3413637388791433603, 16937929882486384885, 11215805046681294327, 11559398419268924015}, + {11697258172757450737, 6137795229387768085, 3190984692021653574, 15347236891154706739}, + }, + { + {12504195828868930633, 14311735968635225029, 3580069346315758668, 12909891866007218579}, + {10780120525711488015, 17942431687417272891, 4966616543136223651, 11565637729828595342}, + }, + { + {12013939709036934636, 4233656138400235608, 5744753585886244254, 7800398410233442143}, + {15609887409465530711, 11633197710359969914, 4221051249637072360, 11317958694020095179}, + }, + { + {5703670472856822602, 8043375474958283103, 2470834322231268196, 13020386017071254236}, + {13795230438353673114, 9108571599173545401, 10145331563807416240, 17474439008571566321}, + }, + }, + { + { + {16430555432520738762, 11225321696360643709, 11777973654353154098, 13133115227828884393}, + {17678738157022850345, 1586660156856830642, 840647763693221003, 8645742354464326466}, + }, + { + {3598736754916501501, 4827022662021197854, 8203180748141933720, 10283251600632599041}, + {16186680658340956808, 15183393398087319142, 8714402370450665212, 13217902016653171217}, + }, + { + {11743016372336018414, 6125536020759642301, 16563280170798047733, 14529052521060111789}, + {15253502329174644388, 1556763737841306861, 3041940064290508531, 18020881359462953336}, + }, + { + {2297585344913389180, 13965959247788377604, 11341378863608387800, 9890953382689640379}, + {10443523266835246852, 9631856696811288063, 6944503116553031744, 10030824122780966395}, + }, + { + {6636244234467769744, 18284390012667441869, 722929822219329257, 3274166388651987221}, + {13177791837760949480, 2568122970128111127, 3477167651270374316, 11371867850093288299}, + }, + { + {12876460969864886954, 4692925517843901006, 17390372170975588763, 14692578774429957295}, + {1759864963511373267, 12016553435172103063, 13015881292003590351, 16187569590073958370}, + }, + { + {5868176722765418764, 8429364877332796959, 7785756492654137899, 14975349488807886278}, + {3272010964035218775, 8946396491617515063, 3774503492701710541, 2113917870331282160}, + }, + { + {13276631120161396750, 16968574704982977753, 2376454925072971568, 9477134218094425043}, + {13784622991820528988, 2074505569780291922, 14294803056569335889, 8759684036994631222}, + }, + { + {9884417819806228161, 10473583853313294601, 14339795822328931094, 8504498283323826917}, + {526127293629665058, 10891388783681447537, 4568472708151557518, 10369081088106148862}, + }, + { + {14875690099724520068, 15708131372860771936, 15063351920655636623, 13673754555867312132}, + {15920462627529593070, 9885706734937065436, 16823591115242423655, 1258777215756511827}, + }, + { + {8202515950988182345, 14546423651242108828, 14227698061016162353, 10918615690964448766}, + {17106085332738434415, 16355746637376756806, 990444867181428081, 15553043817355146246}, + }, + { + {3823475181283510630, 10848691050793796395, 6491636971888772243, 757676231362735550}, + {8973136455980928416, 6503381298194573307, 7834237673135397878, 10787325521157907075}, + }, + { + {455211601892268020, 1552688795129565862, 8165081519906588268, 5446810663215253742}, + {6750786745561416995, 6997284811902307211, 16012972729607911414, 9114458230677816387}, + }, + { + {10975008541567105079, 3750365577590028809, 13516995106985748006, 8919511738051569176}, + {12930984911878205493, 14293252788401143455, 1989517604536428154, 10167748824687611261}, + }, + { + {4403033949751056724, 8371165401092074176, 4457099049748166877, 18160854660487137945}, + {18090711188318162626, 2052332783995780991, 10990843822512572670, 8096670640545581193}, + }, + }, + { + { + {987127652983079722, 6872208513691823695, 10110578719299008714, 16457381243184327116}, + {10779072738879347999, 5965282398006505989, 18251577267494363268, 9321323379108563422}, + }, + { + {6119049170407437179, 12938407708038792521, 10105420405825346383, 3416306788177016826}, + {330648587825212481, 125568991290568141, 13857127346570918649, 4376080986981308805}, + }, + { + {5930434126597036589, 11240994623469578584, 839346533006694594, 10015087329724081709}, + {6285097815938761787, 17244606485954860090, 11523249727882012981, 7178451948850151803}, + }, + { + {16733615335426327004, 14833564736134873977, 15736159435317472941, 17560193966711884894}, + {4670172300306758374, 9477713670983496835, 14243955354032737980, 6459864769649694970}, + }, + { + {16053517698989562256, 2069464650596796670, 18305730134729303993, 1090863611964008044}, + {10595928817546105363, 11743183506441120484, 8584767248013363683, 9187452830514379903}, + }, + { + {6938579711827578880, 16268282168771714072, 4567473305742437221, 754548046014059669}, + {7773636946295303572, 8132380485366854656, 5054542590195827722, 6074347500754248128}, + }, + { + {3955857908381474930, 11852678900999621852, 13783017203403417097, 13616745777931267488}, + {13189924588414196918, 14519927295809952876, 9334100965942760501, 15172548734242885286}, + }, + { + {4869852132020793901, 14921212823114724347, 14342559113353033349, 13336827701782657309}, + {11168346789878684452, 9790480725902426052, 9171116079841529936, 9268902731763220711}, + }, + { + {4417372365016540659, 17280138652899703220, 6650972319709075180, 11252221422799491438}, + {6825784270383052414, 18308562203755695191, 4237445205082731447, 8485872406483449772}, + }, + { + {11718726714045105993, 2624508790343569765, 5794111482300008213, 12819216567095091385}, + {285329842793152354, 17257707863943097374, 16912487373614458842, 9501952033607497057}, + }, + { + {13074643344738491288, 8505193022029238118, 9932652098552590323, 267408114280737600}, + {14802861246220332716, 17506028737327736269, 15929083591675282371, 10937680132245212187}, + }, + { + {16688733766460131050, 12777635326299184071, 7769405825716531061, 12435979606514844725}, + {2767987141420672349, 6723940414217341603, 16114182069580717377, 4541113259200434040}, + }, + { + {8506371389960537559, 18031198550689409305, 11510251852995503442, 1923472385053944821}, + {6189904387119195613, 345664413118550356, 6439003191582953600, 18344385760549575361}, + }, + { + {5320548958745018096, 8341561189829530680, 3327828110998403156, 17981346269177513223}, + {14254804273025688074, 11111147827704077234, 9093333670517437191, 7272552282364063165}, + }, + { + {7587268797387514088, 4402481408866840263, 11260815389095334885, 14391444701764948710}, + {4224880318604689771, 2472148458660279030, 961218007313548745, 13826356220879831691}, + }, + }, + { + { + {5733697799130763963, 962857090393715865, 10538932452511329419, 3413281437172590207}, + {6635428480179771287, 4404718679994229138, 329074170931436370, 17746708206910902139}, + }, + { + {179238781994802586, 9017860544212172426, 16179187983079961859, 1380105261896053495}, + {6187003332254463653, 9896593306091975718, 17181949235068293496, 6820143159816507763}, + }, + { + {4652378169433586070, 2069013165869224423, 13972912433480425078, 2248203233787863058}, + {12819880125496785064, 12462800229583867169, 7969192387226362512, 15450728326339004590}, + }, + { + {11156900805411912784, 1737275748212365168, 16993486692205800040, 12538938066475152524}, + {13167476167764338790, 17373319366642541595, 6054831428930905282, 7118452124011953000}, + }, + { + {15319323094268250368, 15751569639563379275, 9174762389399453601, 5359273060607997116}, + {7548480167962649047, 4093535200286790152, 18255003581953064302, 17037929372197430710}, + }, + { + {3640693116491518731, 9689920283410066894, 16070225083132083168, 13505008973802466003}, + {750230942699692016, 15522838682331888368, 112268476925002814, 17491605970126192984}, + }, + { + {16769567946241955549, 17099752525969374817, 14041401861628609700, 13883170585376164878}, + {1568639950869924595, 7305902646691031157, 12536573783075304502, 12490145094151973568}, + }, + { + {743288751022377974, 9226164090128370715, 17669221687181604232, 1117842260351396541}, + {17697784451833850722, 14382209306891991103, 16951372733687268016, 188390802712613066}, + }, + { + {7332583781810119624, 11974900502289827649, 9825039434151224666, 13612433455140779130}, + {11167094757836568968, 148858902984029622, 4325547061862811500, 8439987427904092212}, + }, + { + {9775040802880336170, 2183956155792599391, 10102475962557589963, 14902149990037881859}, + {7528893974593517583, 18271333130592009124, 11812759747597590978, 3931581515688264350}, + }, + { + {7368734173241076742, 12419301291748626639, 10534790951032501149, 16676926058266807225}, + {13614593066288445663, 5547469267128540754, 5071513241190976074, 6206141439571986364}, + }, + { + {13268209255833199938, 16633146482265079265, 6044233937395578074, 1733872861371247406}, + {14239198956565602758, 4036306057099495106, 1778912298053970082, 6174082695927204648}, + }, + { + {9563897475320169888, 3828463449263891363, 4522408683909966848, 10085044841903958270}, + {15115863363467748291, 3921763467143122522, 3241611744432406503, 16149166019569794702}, + }, + { + {13355027832202142668, 13259310595418810737, 16638224598838046396, 388655643128437049}, + {6131988039969669992, 16758867465997134050, 793705445085763779, 16225736542798627427}, + }, + { + {12060616483613851492, 11185023117529741833, 15286366164051065546, 5407795227432242447}, + {3261413161331398298, 7182873809282605970, 2155509494582452911, 16998725707829879258}, + }, + }, + { + { + {14380343880230315251, 6834909096379668102, 15975839936772635678, 7738230945027714388}, + {7971648870467745046, 8320128435052726628, 10820026056424631461, 7058118462476293754}, + }, + { + {11165438517321289842, 8661037418831619311, 4401480924846865713, 9355650368902126256}, + {14352422544185763829, 12268031594529744663, 17607497268577344783, 12698954426769962214}, + }, + { + {5091534986326281709, 8005812102849517353, 17366496686564185717, 3658878980438307796}, + {8455810244524637026, 7649393961871195909, 8629386422022530934, 507133797409068858}, + }, + { + {10098955144981013765, 4095621933458866623, 313357785962326778, 14880249056209398407}, + {10605627454111004262, 7841561005378789988, 5015399193497762029, 5818383539901203899}, + }, + { + {829322392873083372, 3459913121476606612, 4547714508342797986, 5801286056105229312}, + {11591136160675314269, 17965845487226778560, 7022309609363885527, 5990586084398664157}, + }, + { + {6288277991521986035, 12231480617236286340, 8633990423689180869, 13535190275290488690}, + {13419223868164389899, 17622732596713666209, 10071779220640400024, 9451660464882303005}, + }, + { + {11761084765182152401, 9226969173242076459, 5445719591917489914, 9371133174853825566}, + {18381867235964583187, 17262888224001222346, 1934253649802391267, 3574888052111089863}, + }, + { + {15270079546607712667, 8471883658965202468, 10333206241569264742, 7414741159725097798}, + {7709713706668701850, 4461310100162632915, 10099194304024685274, 4760203118683828795}, + }, + { + {784143359277603248, 15514589681861498400, 4131024411374659852, 3624433493936743696}, + {3251402229976672212, 4649659622203715244, 926933500763282104, 6444675794782453444}, + }, + { + {3756269038539504739, 7020323719189662644, 9035687928909659722, 10611580746254894906}, + {6310976205075048332, 11776014447017145895, 18193543588427463707, 12941703752632419110}, + }, + { + {13258346207952257162, 14737306929596267614, 139896257833059475, 5049568122463438631}, + {12260461320589066027, 46497756452454082, 15185750105748824007, 3681406295924007900}, + }, + { + {2833339165549332500, 18300762432878821923, 13251805801497937312, 17798840894981774941}, + {10659715417364364943, 9241413425866019176, 9144746556705463526, 18018473193185776281}, + }, + { + {7436336871105679313, 3718902224813103412, 8186181643677715434, 17182578567975462342}, + {659724975715028710, 9425698860660002856, 796351253238186633, 18323943433898241577}, + }, + { + {13500588337778130334, 15143039800006025480, 5471884014140775766, 8599189774825271733}, + {14063442714998210193, 17130659899212878144, 2181888550891204616, 13594088124987533554}, + }, + { + {16216101853436910766, 13302132899821289315, 8876723129840557561, 2026846371223185778}, + {7753254296964005427, 16607365864296868674, 1800351426181020953, 12473523172043936884}, + }, + }, + { + { + {14734199666349771791, 4159865781008764547, 4413963548436270853, 4489431649937855880}, + {2824856157476907519, 5111945927271461159, 9825486821405155220, 7657332565522279292}, + }, + { + {8798422177670065832, 1250388939918922012, 5145324733132743026, 3716299737175574168}, + {14387202892738514375, 10255681359895407489, 8563822744122397080, 18430417713920116013}, + }, + { + {7857399215288147901, 2593284350589299949, 10086687882410147351, 14407837835956327624}, + {4469878646287387405, 6845712208092605310, 3019047164798827279, 2760591274816994522}, + }, + { + {10930605176025081830, 5850835312463207607, 9603163404664606781, 15623771803942139684}, + {4096748595672894276, 13060617166821837740, 11222939712741281346, 18445178894593253710}, + }, + { + {7976335583419810431, 16568954524837045521, 5581116346602990350, 18369129318179031997}, + {1930478946186473631, 14255806344323769850, 5302512325798050097, 10008570767203424472}, + }, + { + {929118050943456183, 445163760697913504, 7208246135487165437, 13565354217377841149}, + {3835063466770003968, 8214155842021576753, 2078717035803259674, 12502657820500987763}, + }, + { + {17741004372977419914, 16320851348541958575, 11853008901690968430, 9954777341381304447}, + {14274892887030297417, 10721339848307167540, 8731332510371325649, 13676383433520290197}, + }, + { + {6251805914672095769, 1063060143452094078, 16647397170554915088, 15454955736319919321}, + {11509235104607349098, 8441647766544589978, 956121464218389431, 10752793912033728149}, + }, + { + {14879603883666664508, 11158422912437249402, 8667988090392051507, 12702057193823135575}, + {13234479167199208223, 13752955092077643608, 1117550756888145931, 1184967682872965330}, + }, + { + {7004802666964716824, 395433501626287206, 16674151908279399004, 2279551165611331131}, + {18032555740803644790, 3573953642384243989, 9892480504006025100, 2397759375236735831}, + }, + { + {15032723931727013905, 4176673226777913017, 7270920367565154969, 8867675920919464620}, + {8174119413251699506, 15030539680120439131, 12325981936900309518, 2932283844656871802}, + }, + { + {3227890727136855788, 10772277744280338071, 10065219931092397730, 17233706446636791341}, + {1372997838851103811, 14430098741859995846, 3290287064497023581, 13054133915521430696}, + }, + { + {3404625123065318735, 11884832674715736469, 16513753127836546671, 2355202492840722899}, + {2182039060332057784, 17942518439766613327, 16731345075928062112, 5501869092504492134}, + }, + { + {15704211025163561149, 14596679078416770266, 10262177146233936833, 12443005669252298316}, + {1541294166390346144, 2952804996209068760, 15358481016273272880, 1321729586231860999}, + }, + { + {6862865331233391228, 15106279167311639122, 3283008666555627541, 13405610967904725343}, + {9845239597399801983, 10764942720093673542, 6506992344666983370, 2483131164245259278}, + }, + }, + { + { + {9844707592410952215, 8167497709587672711, 18115463401502884199, 8471563375691441535}, + {17525405040226359165, 2460181803833371342, 3375780580907171205, 3024376384135966552}, + }, + { + {18138724984190926809, 4154767406604950048, 5209478936276366634, 15469512148904762872}, + {3613429290324777670, 12631812917445459751, 10280179062385049041, 19656860716268566}, + }, + { + {14203862032167128161, 13470939927320077756, 10327441827790615277, 10318573137694660185}, + {14560780313347476436, 17088464982837309355, 733937949060316950, 14069325810788446179}, + }, + { + {12030193727051241373, 13981191132445467472, 18205169646206905593, 12162181194046583886}, + {10929925499200074058, 15291772758590352491, 8452344520852919320, 8199821440451878776}, + }, + { + {702956275289752726, 11856189935311796245, 14185745521831658392, 4370665693013677718}, + {4339320942948136612, 7422618440224759582, 871840009976682819, 1758213746931263134}, + }, + { + {7463305936638691553, 10552402742907536443, 9732741351132553899, 194397927117005699}, + {12837197785265289115, 4412933472643099429, 12440864981406580998, 17072316007921211511}, + }, + { + {5025653014579399483, 6266285559889618786, 17667439302823084142, 8837073500207072384}, + {16230880878690171580, 8966359704103918073, 2671625161783975934, 5761959268140569579}, + }, + { + {9876482463501409337, 17331045017548147052, 17542726936580732548, 8299195336372136083}, + {12891767721269002608, 14062358772374813347, 4165127680073507756, 16350672737379495431}, + }, + { + {15987859092221739938, 10999006767011320329, 16931834873460681704, 40989027820989117}, + {16439290771012023473, 6900965556474667785, 7253680936177336810, 17240235510851599487}, + }, + { + {4114449005477323279, 11333071244606712260, 5639227616302034307, 15107257128889549417}, + {5046122977641767311, 17558812465185003134, 18137671581165086239, 4382776603153058089}, + }, + { + {18024760665596162063, 4581156045659391508, 968287218068232238, 9228777525067749703}, + {17309990917327276325, 7114941925430814300, 16735731670154258613, 6290532662018771504}, + }, + { + {7595271959296927018, 15286771623821390629, 980612661413312852, 5738158184597378995}, + {6972117550390447038, 6246497134979772260, 2935831443692029059, 12837371529160496660}, + }, + { + {10790135298802805255, 7259368218310211690, 12050916808246223984, 2030323364779525994}, + {12824594050397534312, 4098150364864727064, 15604500991562385767, 2831443658783115116}, + }, + { + {6469454686530052235, 2594644969515545140, 5284951626835069400, 14441180041267617906}, + {16001664398759990060, 13049178223054879255, 3268931999230968043, 3072360434503949622}, + }, + { + {4565530397071857053, 857029374864691712, 15955478286869670604, 17781316921869181573}, + {16457191703043818907, 5989113593649065091, 4425872606756635499, 4532030700973621003}, + }, + }, + { + { + {2317249352525369754, 15030797481081533168, 12237590576308284360, 15660076992611440873}, + {11341015819700735887, 8280257602754365719, 9212501234696283343, 9673375202141178099}, + }, + { + {9762534010701623728, 15349113802811029024, 8305297169667044246, 18013018210154476198}, + {18414050009163335761, 2190126859433916996, 5444481274452218807, 13415988647365667724}, + }, + { + {11641532224340210206, 71261001011952801, 2321745415903209397, 6595984444855093239}, + {10341299657770272718, 11529878689049370930, 14381510695605158203, 6869272773579747365}, + }, + { + {1073778278665127828, 301289653767944933, 11482324780950168317, 10626716202328004967}, + {7258024014655363102, 12597648090458567878, 2617914106162603499, 12324652644266476584}, + }, + { + {13957732574177025801, 1100344278733481546, 12156946932617203965, 2007756425747006287}, + {16454508610548016441, 18058668363064769203, 15619001054652658323, 1201476243910931863}, + }, + { + {16341334571424533804, 4657494880554316004, 18092783076286521475, 19832895869027143}, + {8667365497283429486, 11501953273367138162, 5832487631687776985, 664754160781757174}, + }, + { + {13524719886605363170, 11553593166914861649, 12034020205580665813, 985175984881624722}, + {11040631342644137311, 12107496606245418129, 7328748654066365904, 14741972847454326011}, + }, + { + {12828567388121500364, 2264959796189127526, 6222205589523394088, 8827682270015065013}, + {2619170858745203321, 14835030117099398518, 5960028394532808010, 2233397097850889639}, + }, + { + {3879642723354138203, 5439355518658448857, 14194463322012776543, 14947367699252203702}, + {11497182458118153903, 16347396442451668378, 16912659817226286851, 6972297461053626970}, + }, + { + {14953681219966965709, 18116944572750863844, 16774540053916392198, 6518998682436778354}, + {11207035159486725904, 17279266785091386830, 15987732680339874714, 4953887381255790681}, + }, + { + {18128055290529398111, 4838636144867908799, 17655818333374840693, 5013823741985131317}, + {1920449774281311783, 13898340137609808546, 861099289958274037, 12441596565887895930}, + }, + { + {7244015348755525626, 13520825180887535513, 9165067445392785660, 9250553550156732893}, + {15663564389384259196, 5724018088820370997, 11379531752316746866, 17687565409319417941}, + }, + { + {11050714794366707475, 12230144450501707996, 12363862313107363407, 6348205119671766380}, + {14263471584626838352, 7350100163762375926, 1902788311165167298, 11691126042005505984}, + }, + { + {3948847772791576201, 11933738159609952054, 15749315384347059669, 8831922078851474178}, + {8463496071867925621, 12756218686011120865, 4691766390469398064, 5252134452066688477}, + }, + { + {4880806069791899809, 11099088460364672063, 12627384861893315861, 4239079797011518662}, + {14560690935803003234, 15267325636353169132, 16919582304973803583, 10073876067858458517}, + }, + }, + { + { + {15695265447782578013, 15506558718447241194, 12341861439298989232, 18400958156300100845}, + {13704811286967591150, 5802260047239067846, 3266013253411255445, 9892957742319181954}, + }, + { + {6053458788987550519, 3243549259991905443, 17990025476026266205, 3918149716414968130}, + {562225565996136148, 12175287017902713154, 16317970834262634990, 5431198806775607012}, + }, + { + {15123186170178367264, 3054913246068400920, 8130663466272395280, 2852812622149318730}, + {6747630551931917110, 18302049774259156971, 3663865061939346221, 12340091610704678811}, + }, + { + {17453312277789785069, 1148609799196055657, 5931758962926317381, 5297597381576544508}, + {9136842287749269744, 3007653173299649609, 12364677607049679091, 3656932227466449489}, + }, + { + {17732801126130995365, 16093023291975796560, 17028512234142609413, 6293028118993952199}, + {4019599708379609715, 3557632583507755601, 16737140015288442165, 7041678499288317736}, + }, + { + {5187842645752673199, 14914432544387315508, 4944360914161982641, 4177329533692612281}, + {18423887817846407126, 11935898134550505219, 9191754399457615042, 962223885189306707}, + }, + { + {5467152559317256227, 13407023128339380091, 656806207084558176, 10823228592509573890}, + {282802378108427873, 13003319652664166176, 11501612671901244594, 8595770155487539951}, + }, + { + {1805255869285898834, 11676967700876044626, 3486630203654875772, 8366336693945605431}, + {17874084888474647879, 8803709150655606891, 680993178667234696, 1603785777136148315}, + }, + { + {3637712241808318043, 1673622542455477465, 14468899013751477571, 6607241816357171779}, + {2332200248940843815, 14077155355848738174, 17298155509321457563, 13624623885136011130}, + }, + { + {12550073596584561722, 13898852145577133829, 31360866049197404, 12629522544897401454}, + {4563446134761510332, 7272813487383198495, 16767195814334178362, 13600498026689482359}, + }, + { + {5170414136067325373, 10875290278133558518, 7331268231382198947, 4082234313337835514}, + {11725295114019619895, 6488017511603508543, 11399466652931338200, 2898113599278666684}, + }, + { + {7553418756944942759, 2324485560009697358, 16004009784734101843, 8345371056076551939}, + {7377284629098981027, 11049718262343754276, 8021605820736410979, 8175349759714152494}, + }, + { + {805625092558946929, 11996029844853502332, 1725029464967101849, 8189609560660709539}, + {10396089572662865065, 1756007811373736605, 7645529329516777410, 2608132938055260111}, + }, + { + {17014595621244604813, 1574499958190108567, 8684546755761322906, 9997538531915911005}, + {5652402150243592363, 6315865356369667235, 8687115108443972047, 12369176255146729475}, + }, + { + {5117004045853299762, 2238407612548002914, 12392667457861900490, 10614312910576266709}, + {6446577503758597410, 3767883614425995197, 17954966454260719539, 5233322901463099}, + }, + }, + { + { + {1081257522368061155, 16144982029632101790, 2280210790959566458, 5000326950136078873}, + {10441086845859171982, 5717080014740953823, 16816253740467637151, 5185838557034755093}, + }, + { + {3897734650128449985, 3892478283047854402, 153850176068596076, 4448963435449755938}, + {9911011406822436713, 6379744721342779297, 360324666931028426, 8002086405015565067}, + }, + { + {13662666854424521459, 17028614494600252018, 13372166182804100759, 8978661571842967509}, + {1689945315009228820, 9997133634912151808, 4070075534875432478, 5780712439158341418}, + }, + { + {18068291112584812890, 10288580446655316879, 16866690514199445805, 15458664010538199871}, + {17175925202246173890, 12208778610361755998, 927739404697616036, 10330183209424493139}, + }, + { + {4422872630455196261, 14815650254807917367, 9426346157598724768, 17764302665164113296}, + {9474027272970951461, 3048886202121388617, 7073604597785890399, 9516006646305083675}, + }, + { + {16541317581647968302, 7221753201217091047, 554497992080233562, 12743131795939254731}, + {6113032707000257613, 4448176364247161206, 738044254484725063, 3096942233684051465}, + }, + { + {2801392933730991479, 15502003900939246745, 11340323610824656109, 13690394827169426680}, + {2298413291804124677, 12243772219106809119, 9550327342593445260, 18354548835264437008}, + }, + { + {17095781462759061506, 13984950766342782369, 7038608479806172868, 7073471193601880894}, + {9212126909381119712, 15865851343492198107, 3874039137971369196, 15366505242302572319}, + }, + { + {10476508037395688256, 5905562397524931472, 15147896444621280595, 3856601647293477321}, + {4204909177546012159, 17515684210872904454, 12561834979880779760, 6477848309789627185}, + }, + { + {3226022509034031128, 5771385963704757771, 17861700165696478115, 14976034400726774156}, + {17945959497662269352, 6322288130414861016, 3008853024335853994, 5599925939427067989}, + }, + { + {15408448007738805625, 3855259080280453396, 11776434265478354726, 11784885919111239520}, + {8108981861486003291, 16553896039002150783, 5694423121092647200, 16414563259092889693}, + }, + { + {3235058267792568155, 8030551941244615429, 12851363585510555514, 9786973022560471711}, + {4901414898060251968, 13240438628487941170, 4707852389766057435, 6503805666511566831}, + }, + { + {1178073204986944698, 10685133932326477495, 11710162005310407793, 11019188929725710305}, + {16244991946372165706, 3272168887117805467, 15045747299972144833, 8155681972478369649}, + }, + { + {12308450869393289693, 14268794937571237354, 9141189178824378983, 11605207657904000518}, + {17071770108549330148, 11045960524457021256, 13807710432855107212, 8427718050873363613}, + }, + { + {16762196363426636910, 7316863360113205703, 7937998445095491508, 3946557199536080470}, + {16019910399697645039, 11522845950519380293, 2362453023191035102, 6547077716792082654}, + }, + }, + { + { + {5218985848865375996, 5835476376320976237, 9096499658845542933, 8952489298840360492}, + {16605895184424459659, 505731104315931813, 17784248872812610986, 4151555707609374291}, + }, + { + {4963953120977916566, 6585250545846301109, 4490972754776862709, 10674499592300479120}, + {17494988318349821345, 1814042777264686189, 8938395423478059768, 9062966010283426056}, + }, + { + {3879469818714011415, 11493820457829716643, 10091807027724827301, 5032134849078736052}, + {18015749204009276046, 9667758283246223357, 4629693773460610802, 3807196436109718946}, + }, + { + {5724217930909760221, 15420221591912350415, 9910465013739250802, 12511683773790779491}, + {2841532862707547306, 16614426471009646589, 407574220261191228, 17422057170120224031}, + }, + { + {3725101809714764432, 2995111022132376824, 9338883729618021504, 8824923738291347476}, + {3745497072215538317, 3576446898425965872, 2350077748663612773, 15793255155885543355}, + }, + { + {12904339001067417585, 1972265247859388742, 8908590936681392405, 10320719400504224158}, + {8298368064038407143, 2105745729886511647, 16509751074757847095, 15156289751671616565}, + }, + { + {885617946245226760, 17871561572095909264, 16413308527330544768, 2938750343525834336}, + {6332736376778563648, 16772687696658236231, 9760470695949399178, 17420556823805232882}, + }, + { + {4407657041250297528, 13832960959347315977, 15056546959967740939, 4350443362134191429}, + {8013419913016572733, 8888684099801298477, 15401479253620745715, 18279947201669400847}, + }, + { + {16774767206504477529, 15784248755460218800, 890363416232172440, 6798249980336291014}, + {1295939576916968887, 14501516576359061383, 5181286196215569291, 8884842683907072200}, + }, + { + {12906144535917740163, 4179201185048577793, 8949647323841299627, 2168773816567792706}, + {1715683170634778607, 9901501903322086192, 7624633731287546358, 10530124063631858009}, + }, + { + {14199956317346734484, 13250211595320054421, 18197952479293091552, 16161313407818957084}, + {17435507292968186894, 6560268436714668609, 1299607057816966726, 8157462320016248727}, + }, + { + {3603583288706717651, 17387128326071547512, 17907604816622771553, 17853094381965037384}, + {12273843852205811233, 13840584476006398280, 2018654168596055410, 11549248055135584644}, + }, + { + {4742377140579111706, 845465928037625085, 12028953960657292824, 16438644767032965255}, + {17377088622232632294, 1631558517096568450, 11363064014018667511, 6006029335296807862}, + }, + { + {8877393780281438935, 9848923171251074575, 1554975198005028643, 2251034043951525516}, + {9696558687758873050, 3889942916226212472, 8326933892612496812, 7463785348361544799}, + }, + { + {4205364996189816688, 5453611962777060261, 16993840011943171053, 11689161310506207011}, + {16699173739044458906, 6254168288000491517, 12642281218300963313, 10028950653175051753}, + }, + }, + { + { + {8784043285714375740, 8483257759279461889, 8789745728267363600, 1770019616739251654}, + {15992936863339206154, 10037038012062884956, 15197544864945402661, 9615747158586711429}, + }, + { + {9583737883674400333, 12279877754802111101, 8296198976379850969, 17778859909846088251}, + {3401986641240187301, 1525831644595056632, 1849003687033449918, 8702493044913179195}, + }, + { + {18423170064697770279, 12693387071620743675, 7398701556189346968, 2779682216903406718}, + {12703629940499916779, 6358598532389273114, 8683512038509439374, 15415938252666293255}, + }, + { + {8408419572923862476, 5066733120953500019, 926242532005776114, 6301489109130024811}, + {3285079390283344806, 1685054835664548935, 7740622190510199342, 9561507292862134371}, + }, + { + {13698695174800826869, 10442832251048252285, 10672604962207744524, 14485711676978308040}, + {16947216143812808464, 8342189264337602603, 3837253281927274344, 8331789856935110934}, + }, + { + {4627808394696681034, 6174000022702321214, 15351247319787348909, 1371147458593240691}, + {10651965436787680331, 2998319090323362997, 17592419471314886417, 11874181791118522207}, + }, + { + {524165018444839759, 3157588572894920951, 17599692088379947784, 1421537803477597699}, + {2902517390503550285, 7440776657136679901, 17263207614729765269, 16928425260420958311}, + }, + { + {2878166099891431311, 5056053391262430293, 10345032411278802027, 13214556496570163981}, + {17698482058276194679, 2441850938900527637, 1314061001345252336, 6263402014353842038}, + }, + { + {8487436533858443496, 12386798851261442113, 3224748875345095424, 16166568617729909099}, + {2213369110503306004, 6246347469485852131, 3129440554298978074, 605269941184323483}, + }, + { + {3177531230451277512, 11022989490494865721, 8321856985295555401, 14727273563873821327}, + {876865438755954294, 14139765236890058248, 6880705719513638354, 8678887646434118325}, + }, + { + {16896703203004244996, 11377226897030111200, 2302364246994590389, 4499255394192625779}, + {1906858144627445384, 2670515414718439880, 868537809054295101, 7535366755622172814}, + }, + { + {339769604981749608, 12384581172556225075, 2596838235904096350, 5684069910326796630}, + {913125548148611907, 1661497269948077623, 2892028918424825190, 9220412792897768138}, + }, + { + {14754959387565938441, 1023838193204581133, 13599978343236540433, 8323909593307920217}, + {3852032956982813055, 7526785533690696419, 8993798556223495105, 18140648187477079959}, + }, + { + {11692087196810962506, 1328079167955601379, 1664008958165329504, 18063501818261063470}, + {2861243404839114859, 13702578580056324034, 16781565866279299035, 1524194541633674171}, + }, + { + {8267721299596412251, 273633183929630283, 17164190306640434032, 16332882679719778825}, + {4663567915067622493, 15521151801790569253, 7273215397645141911, 2324445691280731636}, + }, + }, + } +} diff --git a/core/crypto/_weierstrass/tools/ecc_gen_tables.odin b/core/crypto/_weierstrass/tools/ecc_gen_tables.odin new file mode 100644 index 000000000..e69927a90 --- /dev/null +++ b/core/crypto/_weierstrass/tools/ecc_gen_tables.odin @@ -0,0 +1,99 @@ +package weistrass_tools + +import secec "core:crypto/_weierstrass" +import "core:fmt" +import path "core:path/filepath" +import "core:os" +import "core:strings" + +// Yes this leaks memory, fite me IRL. + +GENERATED :: `/* + ------ GENERATED ------ DO NOT EDIT ------ GENERATED ------ DO NOT EDIT ------ GENERATED ------ +*/` + +main :: proc() { + gen_p256r1_tables() +} + +gen_p256r1_tables :: proc() { + Affine_Point_p256r1 :: struct { + x: secec.Field_Element_p256r1, + y: secec.Field_Element_p256r1, + } + Multiply_Table_p256r1_hi: [32][15]Affine_Point_p256r1 + Multiply_Table_p256r1_lo: [32][15]Affine_Point_p256r1 + + g, p: secec.Point_p256r1 + secec.pt_generator(&g) + + // Precompute ([1,15] << n) * G multiples of G, MSB->LSB + for i in 0..<32 { + b: [32]byte + for j in 1..<16 { + b[i] = u8(j) << 4 + secec.pt_scalar_mul_bytes(&p, &g, b[:], true) + secec.pt_rescale(&p, &p) + secec.fe_set(&Multiply_Table_p256r1_hi[i][j-1].x, &p.x) + secec.fe_set(&Multiply_Table_p256r1_hi[i][j-1].y, &p.y) + + b[i] = u8(j) + secec.pt_scalar_mul_bytes(&p, &g, b[:], true) + secec.pt_rescale(&p, &p) + secec.fe_set(&Multiply_Table_p256r1_lo[i][j-1].x, &p.x) + secec.fe_set(&Multiply_Table_p256r1_lo[i][j-1].y, &p.y) + + b[i] = 0 + } + } + + fn := path.join({ODIN_ROOT, "core", "crypto", "_weierstrass", "secp256r1_table.odin"}) + bld: strings.Builder + w := strings.to_writer(&bld) + + fmt.wprintln(w, "package _weierstrass") + fmt.wprintln(w, "") + fmt.wprintln(w, GENERATED) + fmt.wprintln(w, "") + fmt.wprintln(w, "import \"core:crypto\"") + fmt.wprintln(w, "") + fmt.wprintln(w, "when crypto.COMPACT_IMPLS == false {") + + fmt.wprintln(w, "\t@(private,rodata)") + fmt.wprintln(w, "\tGen_Multiply_Table_p256r1_hi := [32][15]Affine_Point_p256r1 {") + for &v, i in Multiply_Table_p256r1_hi { + fmt.wprintln(w, "\t\t{") + for &ap, j in v { + fmt.wprintln(w, "\t\t\t{") + + x, y := &ap.x, &ap.y + fmt.wprintf(w, "\t\t\t\t{{%d, %d, %d, %d},\n", x[0], x[1], x[2], x[3]) + fmt.wprintf(w, "\t\t\t\t{{%d, %d, %d, %d},\n", y[0], y[1], y[2], y[3]) + + fmt.wprintln(w, "\t\t\t},") + } + fmt.wprintln(w, "\t\t},") + } + fmt.wprintln(w, "\t}\n") + + fmt.wprintln(w, "\t@(private,rodata)") + fmt.wprintln(w, "\tGen_Multiply_Table_p256r1_lo := [32][15]Affine_Point_p256r1 {") + for &v, i in Multiply_Table_p256r1_lo { + fmt.wprintln(w, "\t\t{") + for &ap, j in v { + fmt.wprintln(w, "\t\t\t{") + + x, y := &ap.x, &ap.y + fmt.wprintf(w, "\t\t\t\t{{%d, %d, %d, %d},\n", x[0], x[1], x[2], x[3]) + fmt.wprintf(w, "\t\t\t\t{{%d, %d, %d, %d},\n", y[0], y[1], y[2], y[3]) + + fmt.wprintln(w, "\t\t\t},") + } + fmt.wprintln(w, "\t\t},") + } + fmt.wprintln(w, "\t}") + + fmt.wprintln(w, "}") + + _ = os.write_entire_file(fn, transmute([]byte)(strings.to_string(bld))) +} diff --git a/core/crypto/crypto.odin b/core/crypto/crypto.odin index 7ccf126e6..3fb369a54 100644 --- a/core/crypto/crypto.odin +++ b/core/crypto/crypto.odin @@ -2,8 +2,12 @@ package crypto import "base:runtime" +import subtle "core:crypto/_subtle" import "core:mem" +// Omit large precomputed tables, trading off performance for size. +COMPACT_IMPLS: bool : #config(ODIN_CRYPTO_COMPACT, false) + // HAS_RAND_BYTES is true iff the runtime provides a cryptographic // entropy source. HAS_RAND_BYTES :: runtime.HAS_RAND_BYTES @@ -44,7 +48,17 @@ compare_byte_ptrs_constant_time :: proc "contextless" (a, b: ^byte, n: int) -> i // After the loop, v == 0 iff a == b. The subtraction will underflow // iff v == 0, setting the sign-bit, which gets returned. - return int((u32(v)-1) >> 31) + return subtle.eq(0, v) +} + +// is_zero_constant_time returns 1 iff b is all 0s, 0 otherwise. +is_zero_constant_time :: proc "contextless" (b: []byte) -> int { + v: byte + for b_ in b { + v |= b_ + } + + return subtle.byte_eq(0, v) } // rand_bytes fills the dst buffer with cryptographic entropy taken from diff --git a/core/crypto/ecdh/doc.odin b/core/crypto/ecdh/doc.odin new file mode 100644 index 000000000..e34f255f2 --- /dev/null +++ b/core/crypto/ecdh/doc.odin @@ -0,0 +1,4 @@ +/* +A generic interface to Elliptic Curve Diffie-Hellman key exchange. +*/ +package ecdh diff --git a/core/crypto/ecdh/ecdh.odin b/core/crypto/ecdh/ecdh.odin new file mode 100644 index 000000000..3e97ebdc7 --- /dev/null +++ b/core/crypto/ecdh/ecdh.odin @@ -0,0 +1,404 @@ +package ecdh + +import "core:crypto" +import secec "core:crypto/_weierstrass" +import "core:crypto/x25519" +import "core:crypto/x448" +import "core:mem" +import "core:reflect" + +// Note: For these primitives scalar size = point size +@(private="file") +X25519_Buf :: [x25519.SCALAR_SIZE]byte +@(private="file") +X448_Buf :: [x448.SCALAR_SIZE]byte + +// Curve the curve identifier associated with a given Private_Key +// or Public_Key +Curve :: enum { + Invalid, + SECP256R1, + X25519, + X448, +} + +// CURVE_NAMES is the Curve to curve name string. +CURVE_NAMES := [Curve]string { + .Invalid = "Invalid", + .SECP256R1 = "secp256r1", + .X25519 = "X25519", + .X448 = "X448", +} + +// PRIVATE_KEY_SIZES is the Curve to private key size in bytes. +PRIVATE_KEY_SIZES := [Curve]int { + .Invalid = 0, + .SECP256R1 = secec.SC_SIZE_P256R1, + .X25519 = x25519.SCALAR_SIZE, + .X448 = x448.SCALAR_SIZE, +} + +// PUBLIC_KEY_SIZES is the Curve to public key size in bytes. +PUBLIC_KEY_SIZES := [Curve]int { + .Invalid = 0, + .SECP256R1 = 1 + 2 * secec.FE_SIZE_P256R1, + .X25519 = x25519.POINT_SIZE, + .X448 = x448.POINT_SIZE, +} + +// SHARED_SECRET_SIZES is the Curve to shared secret size in bytes. +SHARED_SECRET_SIZES := [Curve]int { + .Invalid = 0, + .SECP256R1 = secec.FE_SIZE_P256R1, + .X25519 = x25519.POINT_SIZE, + .X448 = x448.POINT_SIZE, +} + +@(private="file") +_PRIV_IMPL_IDS := [Curve]typeid { + .Invalid = nil, + .SECP256R1 = typeid_of(secec.Scalar_p256r1), + .X25519 = typeid_of(X25519_Buf), + .X448 = typeid_of(X448_Buf), +} + +@(private="file") +_PUB_IMPL_IDS := [Curve]typeid { + .Invalid = nil, + .SECP256R1 = typeid_of(secec.Point_p256r1), + .X25519 = typeid_of(X25519_Buf), + .X448 = typeid_of(X448_Buf), +} + +// Private_Key is an ECDH private key. +Private_Key :: struct { + // WARNING: All of the members are to be treated as internal (ie: + // the Private_Key structure is intended to be opaque). + _curve: Curve, + _impl: union { + secec.Scalar_p256r1, + X25519_Buf, + X448_Buf, + }, + _pub_key: Public_Key, +} + +// Public_Key is an ECDH public key. +Public_Key :: struct { + // WARNING: All of the members are to be treated as internal (ie: + // the Public_Key structure is intended to be opaque). + _curve: Curve, + _impl: union { + secec.Point_p256r1, + X25519_Buf, + X448_Buf, + }, +} + +// private_key_generate uses the system entropy source to generate a new +// Private_Key. This will only fail iff the system entropy source is +// missing or broken. +private_key_generate :: proc(priv_key: ^Private_Key, curve: Curve) -> bool { + private_key_clear(priv_key) + + if !crypto.HAS_RAND_BYTES { + return false + } + + reflect.set_union_variant_typeid( + priv_key._impl, + _PRIV_IMPL_IDS[curve], + ) + + #partial switch curve { + case .SECP256R1: + sc := &priv_key._impl.(secec.Scalar_p256r1) + + // 384-bits reduced makes the modulo bias insignificant + b: [48]byte = --- + defer (mem.zero_explicit(&b, size_of(b))) + for { + crypto.rand_bytes(b[:]) + _ = secec.sc_set_bytes(sc, b[:]) + if secec.sc_is_zero(sc) == 0 { // Likely + break + } + } + case .X25519: + sc := &priv_key._impl.(X25519_Buf) + crypto.rand_bytes(sc[:]) + case .X448: + sc := &priv_key._impl.(X448_Buf) + crypto.rand_bytes(sc[:]) + case: + panic("crypto/ecdh: invalid curve") + } + + priv_key._curve = curve + private_key_generate_public(priv_key) + + return true +} + +// private_key_set_bytes decodes a byte-encoded private key, and returns +// true iff the operation was successful. +private_key_set_bytes :: proc(priv_key: ^Private_Key, curve: Curve, b: []byte) -> bool { + private_key_clear(priv_key) + + if len(b) != PRIVATE_KEY_SIZES[curve] { + return false + } + + reflect.set_union_variant_typeid( + priv_key._impl, + _PRIV_IMPL_IDS[curve], + ) + + #partial switch curve { + case .SECP256R1: + sc := &priv_key._impl.(secec.Scalar_p256r1) + did_reduce := secec.sc_set_bytes(sc, b) + is_zero := secec.sc_is_zero(sc) == 1 + + // Reject `0` and scalars that are not less than the + // curve order. + if did_reduce || is_zero { + private_key_clear(priv_key) + return false + } + case .X25519: + sc := &priv_key._impl.(X25519_Buf) + copy(sc[:], b) + case .X448: + sc := &priv_key._impl.(X448_Buf) + copy(sc[:], b) + case: + panic("crypto/ecdh: invalid curve") + } + + priv_key._curve = curve + private_key_generate_public(priv_key) + + return true +} + +@(private="file") +private_key_generate_public :: proc(priv_key: ^Private_Key) { + switch &sc in priv_key._impl { + case secec.Scalar_p256r1: + pub_key: secec.Point_p256r1 = --- + secec.pt_scalar_mul_generator(&pub_key, &sc) + secec.pt_rescale(&pub_key, &pub_key) + priv_key._pub_key._impl = pub_key + case X25519_Buf: + pub_key: X25519_Buf = --- + x25519.scalarmult_basepoint(pub_key[:], sc[:]) + priv_key._pub_key._impl = pub_key + case X448_Buf: + pub_key: X448_Buf = --- + x448.scalarmult_basepoint(pub_key[:], sc[:]) + priv_key._pub_key._impl = pub_key + case: + panic("crypto/ecdh: invalid curve") + } + + priv_key._pub_key._curve = priv_key._curve +} + +// private_key_bytes sets dst to byte-encoding of priv_key. +private_key_bytes :: proc(priv_key: ^Private_Key, dst: []byte) { + ensure(priv_key._curve != .Invalid, "crypto/ecdh: uninitialized private key") + ensure(len(dst) == PRIVATE_KEY_SIZES[priv_key._curve], "crypto/ecdh: invalid destination size") + + #partial switch priv_key._curve { + case .SECP256R1: + sc := &priv_key._impl.(secec.Scalar_p256r1) + secec.sc_bytes(dst, sc) + case .X25519: + sc := &priv_key._impl.(X25519_Buf) + copy(dst, sc[:]) + case .X448: + sc := &priv_key._impl.(X448_Buf) + copy(dst, sc[:]) + case: + panic("crypto/ecdh: invalid curve") + } +} + +// private_key_equal returns true iff the private keys are equal, +// in constant time. +private_key_equal :: proc(p, q: ^Private_Key) -> bool { + if p._curve != q._curve { + return false + } + + #partial switch p._curve { + case .SECP256R1: + sc_p, sc_q := &p._impl.(secec.Scalar_p256r1), &q._impl.(secec.Scalar_p256r1) + return secec.sc_equal(sc_p, sc_q) == 1 + case .X25519: + b_p, b_q := &p._impl.(X25519_Buf), &q._impl.(X25519_Buf) + return crypto.compare_constant_time(b_p[:], b_q[:]) == 1 + case .X448: + b_p, b_q := &p._impl.(X448_Buf), &q._impl.(X448_Buf) + return crypto.compare_constant_time(b_p[:], b_q[:]) == 1 + case: + return false + } +} + +// private_key_clear clears priv_key to the uninitialized state. +private_key_clear :: proc "contextless" (priv_key: ^Private_Key) { + mem.zero_explicit(priv_key, size_of(Private_Key)) +} + +// public_key_set_bytes decodes a byte-encoded public key, and returns +// true iff the operation was successful. +public_key_set_bytes :: proc(pub_key: ^Public_Key, curve: Curve, b: []byte) -> bool { + public_key_clear(pub_key) + + if len(b) != PUBLIC_KEY_SIZES[curve] { + return false + } + + reflect.set_union_variant_typeid( + pub_key._impl, + _PUB_IMPL_IDS[curve], + ) + + #partial switch curve { + case .SECP256R1: + if b[0] != secec.SEC_PREFIX_UNCOMPRESSED { + return false + } + + pt := &pub_key._impl.(secec.Point_p256r1) + ok := secec.pt_set_sec_bytes(pt, b) + if !ok || secec.pt_is_identity(pt) == 1 { + return false + } + case .X25519: + pt := &pub_key._impl.(X25519_Buf) + copy(pt[:], b) + case .X448: + pt := &pub_key._impl.(X448_Buf) + copy(pt[:], b) + case: + panic("crypto/ecdh: invalid curve") + } + + pub_key._curve = curve + + return true +} + +// public_key_set_priv sets pub_key to the public component of priv_key. +public_key_set_priv :: proc(pub_key: ^Public_Key, priv_key: ^Private_Key) { + ensure(priv_key._curve != .Invalid, "crypto/ecdh: uninitialized private key") + public_key_clear(pub_key) + pub_key^ = priv_key._pub_key +} + +// public_key_bytes sets dst to byte-encoding of pub_key. +public_key_bytes :: proc(pub_key: ^Public_Key, dst: []byte) { + ensure(pub_key._curve != .Invalid, "crypto/ecdh: uninitialized public key") + ensure(len(dst) == PUBLIC_KEY_SIZES[pub_key._curve], "crypto/ecdh: invalid destination size") + + #partial switch pub_key._curve { + case .SECP256R1: + // Invariant: Unless the caller is manually building pub_key + // `Z = 1`, so we can skip the rescale. + pt := &pub_key._impl.(secec.Point_p256r1) + + dst[0] = secec.SEC_PREFIX_UNCOMPRESSED + secec.fe_bytes(dst[1:1+secec.FE_SIZE_P256R1], &pt.x) + secec.fe_bytes(dst[1+secec.FE_SIZE_P256R1:], &pt.y) + case .X25519: + pt := &pub_key._impl.(X25519_Buf) + copy(dst, pt[:]) + case .X448: + pt := &pub_key._impl.(X448_Buf) + copy(dst, pt[:]) + case: + panic("crypto/ecdh: invalid curve") + } +} + +// public_key_equal returns true iff the public keys are equal, +// in constant time. +public_key_equal :: proc(p, q: ^Public_Key) -> bool { + if p._curve != q._curve { + return false + } + + #partial switch p._curve { + case .SECP256R1: + pt_p, pt_q := &p._impl.(secec.Point_p256r1), &q._impl.(secec.Point_p256r1) + return secec.pt_equal(pt_p, pt_q) == 1 + case .X25519: + b_p, b_q := &p._impl.(X25519_Buf), &q._impl.(X25519_Buf) + return crypto.compare_constant_time(b_p[:], b_q[:]) == 1 + case .X448: + b_p, b_q := &p._impl.(X448_Buf), &q._impl.(X448_Buf) + return crypto.compare_constant_time(b_p[:], b_q[:]) == 1 + case: + panic("crypto/ecdh: invalid curve") + } +} + +// public_key_clear clears pub_key to the uninitialized state. +public_key_clear :: proc "contextless" (pub_key: ^Public_Key) { + mem.zero_explicit(pub_key, size_of(Public_Key)) +} + +// ecdh performs an Elliptic Curve Diffie-Hellman key exchange betwween +// the Private_Key and Public_Key, writing the shared secret to dst. +// +// The neutral element is rejected as an error. +@(require_results) +ecdh :: proc(priv_key: ^Private_Key, pub_key: ^Public_Key, dst: []byte) -> bool { + ensure(priv_key._curve == pub_key._curve, "crypto/ecdh: curve mismatch") + ensure(pub_key._curve != .Invalid, "crypto/ecdh: uninitialized public key") + ensure(len(dst) == SHARED_SECRET_SIZES[priv_key._curve], "crypto/ecdh: invalid shared secret size") + + #partial switch priv_key._curve { + case .SECP256R1: + sc, pt := &priv_key._impl.(secec.Scalar_p256r1), &pub_key._impl.(secec.Point_p256r1) + ss: secec.Point_p256r1 + defer secec.pt_clear(&ss) + + secec.pt_scalar_mul(&ss, pt, sc) + return secec.pt_bytes(dst, nil, &ss) + case .X25519: + sc, pt := &priv_key._impl.(X25519_Buf), &pub_key._impl.(X25519_Buf) + x25519.scalarmult(dst, sc[:], pt[:]) + case .X448: + sc, pt := &priv_key._impl.(X448_Buf), &pub_key._impl.(X448_Buf) + x448.scalarmult(dst, sc[:], pt[:]) + case: + panic("crypto/ecdh: invalid curve") + } + + // X25519/X448 check for all zero digest. + return crypto.is_zero_constant_time(dst) == 0 +} + +// curve returns the Curve used by a Private_Key or Public_Key instance. +curve :: proc(k: ^$T) -> Curve where(T == Private_Key || T == Public_Key) { + return k._curve +} + +// key_size returns the key size of a Private_Key or Public_Key in bytes. +key_size :: proc(k: ^$T) -> int where(T == Private_Key || T == Public_Key) { + when T == Private_Key { + return PRIVATE_KEY_SIZES[k._curve] + } else { + return PUBLIC_KEY_SIZES[k._curve] + } +} + +// shared_secret_size returns the shared secret size of a key exchange +// in bytes. +shared_secret_size :: proc(k: ^$T) -> int where(T == Private_Key || T == Public_Key) { + return SHARED_SECRET_SIZES[k._curve] +} diff --git a/core/crypto/ed25519/ed25519.odin b/core/crypto/ed25519/ed25519.odin index 0382a6739..f6a71d888 100644 --- a/core/crypto/ed25519/ed25519.odin +++ b/core/crypto/ed25519/ed25519.odin @@ -170,7 +170,7 @@ public_key_set_bytes :: proc "contextless" (pub_key: ^Public_Key, b: []byte) -> // public_key_set_priv sets pub_key to the public component of priv_key. public_key_set_priv :: proc(pub_key: ^Public_Key, priv_key: ^Private_Key) { - ensure(priv_key._is_initialized, "crypto/ed25519: uninitialized public key") + ensure(priv_key._is_initialized, "crypto/ed25519: uninitialized private key") src := &priv_key._pub_key copy(pub_key._b[:], src._b[:]) diff --git a/core/crypto/x25519/x25519.odin b/core/crypto/x25519/x25519.odin index e25d1831f..2d7aa4153 100644 --- a/core/crypto/x25519/x25519.odin +++ b/core/crypto/x25519/x25519.odin @@ -6,6 +6,8 @@ See: */ package x25519 +import "core:crypto" +import ed "core:crypto/_edwards25519" import field "core:crypto/_fiat/field_curve25519" import "core:mem" @@ -14,8 +16,10 @@ SCALAR_SIZE :: 32 // POINT_SIZE is the size of a X25519 point (public key/shared secret) in bytes. POINT_SIZE :: 32 -@(private, rodata) -_BASE_POINT: [32]byte = {9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +when crypto.COMPACT_IMPLS == true { + @(private,rodata) + _BASE_POINT: [32]byte = {9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +} @(private) _scalar_bit :: #force_inline proc "contextless" (s: ^[32]byte, i: int) -> u8 { @@ -111,19 +115,44 @@ scalarmult :: proc(dst, scalar, point: []byte) { e[31] &= 127 e[31] |= 64 - p: [32]byte = --- - copy_slice(p[:], point) - - d: [32]byte = --- - _scalarmult(&d, &e, &p) - copy_slice(dst, d[:]) + p := (^[32]byte)(raw_data(point)) + d := (^[32]byte)(raw_data(dst)) + _scalarmult(d, &e, p) mem.zero_explicit(&e, size_of(e)) - mem.zero_explicit(&d, size_of(d)) } // scalarmult_basepoint "multiplies" the provided scalar with the X25519 // base point and writes the resulting point to dst. scalarmult_basepoint :: proc(dst, scalar: []byte) { - scalarmult(dst, scalar, _BASE_POINT[:]) + when crypto.COMPACT_IMPLS == true { + scalarmult(dst, scalar, _BASE_POINT[:]) + } else { + ensure(len(scalar) == SCALAR_SIZE, "crypto/x25519: invalid scalar size") + ensure(len(dst) == POINT_SIZE, "crypto/x25519: invalid destination point size") + + sc: ed.Scalar = --- + ed.sc_set_bytes_rfc8032(&sc, scalar) + + ge: ed.Group_Element = --- + ed.ge_scalarmult_basepoint(&ge, &sc) + + // u = (y + z)/(z - y) + y_plus_z: field.Loose_Field_Element = --- + z_minus_y: field.Loose_Field_Element = --- + u: field.Tight_Field_Element = --- + + field.fe_add(&y_plus_z, &ge.y, &ge.z) + field.fe_sub(&z_minus_y, &ge.z, &ge.y) + field.fe_carry_inv(&u, &z_minus_y) + field.fe_carry_mul(&u, &y_plus_z, field.fe_relax_cast(&u)) + + dst_ := (^[32]byte)(raw_data(dst)) + field.fe_to_bytes(dst_, &u) + + field.fe_clear_vec([]^field.Loose_Field_Element{&y_plus_z, &z_minus_y}) + field.fe_clear(&u) + ed.sc_clear(&sc) + ed.ge_clear(&ge) + } } diff --git a/core/encoding/base32/base32.odin b/core/encoding/base32/base32.odin index 34de2ff53..d272b32b8 100644 --- a/core/encoding/base32/base32.odin +++ b/core/encoding/base32/base32.odin @@ -153,15 +153,15 @@ decode :: proc( padding_count += 1 } + // Verify no padding in the middle + for i := 0; i < data_len - padding_count; i += 1 { + if data[i] == byte(PADDING) { + return nil, .Malformed_Input + } + } + // Check for proper padding and length combinations if padding_count > 0 { - // Verify no padding in the middle - for i := 0; i < data_len - padding_count; i += 1 { - if data[i] == byte(PADDING) { - return nil, .Malformed_Input - } - } - content_len := data_len - padding_count mod8 := content_len % 8 required_padding: int diff --git a/core/encoding/base64/base64.odin b/core/encoding/base64/base64.odin index 032716bde..0677fdfb7 100644 --- a/core/encoding/base64/base64.odin +++ b/core/encoding/base64/base64.odin @@ -24,6 +24,18 @@ ENC_TABLE := [64]byte { '4', '5', '6', '7', '8', '9', '+', '/', } +// Encoding table for Base64url variant +ENC_URL_TABLE := [64]byte { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', + 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '0', '1', '2', '3', + '4', '5', '6', '7', '8', '9', '-', '_', +} + PADDING :: '=' DEC_TABLE := [256]u8 { @@ -61,6 +73,43 @@ DEC_TABLE := [256]u8 { 0, 0, 0, 0, 0, 0, 0, 0, } +// Decoding table for Base64url variant +DEC_URL_TABLE := [256]u8 { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 62, 0, 0, + 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 0, 0, 0, 0, 63, + 0, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +} + + encode :: proc(data: []byte, ENC_TBL := ENC_TABLE, allocator := context.allocator) -> (encoded: string, err: mem.Allocator_Error) #optional_allocator_error { out_length := encoded_len(data) if out_length == 0 { diff --git a/core/encoding/entity/entity.odin b/core/encoding/entity/entity.odin index e112eedf2..a756bdf39 100644 --- a/core/encoding/entity/entity.odin +++ b/core/encoding/entity/entity.odin @@ -21,6 +21,7 @@ package encoding_unicode_entity Jeroen van Rijn: Initial implementation. */ +import "base:runtime" import "core:unicode/utf8" import "core:unicode" import "core:strings" @@ -141,8 +142,10 @@ decode_xml :: proc(input: string, options := XML_Decode_Options{}, allocator := write_string(&builder, entity) } else { if .No_Entity_Decode not_in options { - if decoded, ok := xml_decode_entity(entity); ok { - write_rune(&builder, decoded) + if decoded, count, ok := xml_decode_entity(entity); ok { + for i in 0.. (err: Error) { } } -xml_decode_entity :: proc(entity: string) -> (decoded: rune, ok: bool) { +xml_decode_entity :: proc(entity: string) -> (decoded: [2]rune, rune_count: int, ok: bool) { entity := entity - if len(entity) == 0 { return -1, false } + if len(entity) == 0 { return } - switch entity[0] { - case '#': + if entity[0] == '#' { base := 10 val := 0 entity = entity[1:] - if len(entity) == 0 { return -1, false } + if len(entity) == 0 { return } if entity[0] == 'x' || entity[0] == 'X' { base = 16 @@ -237,30 +239,275 @@ xml_decode_entity :: proc(entity: string) -> (decoded: rune, ok: bool) { val += int(r - '0') case 'a'..='f': - if base == 10 { return -1, false } + if base == 10 { return } val *= base val += int(r - 'a' + 10) case 'A'..='F': - if base == 10 { return -1, false } + if base == 10 { return } val *= base val += int(r - 'A' + 10) case: - return -1, false + return } - if val > MAX_RUNE_CODEPOINT { return -1, false } + if val > MAX_RUNE_CODEPOINT { return } entity = entity[1:] } - return rune(val), true - - case: - // Named entity. - return named_xml_entity_to_rune(entity) + return rune(val), 1, true } + // Named entity. + return named_xml_entity_to_rune(entity) } + +// escape_html escapes special characters like '&' to become '&'. +// It escapes only 5 different characters: & ' < > and " +@(require_results) +escape_html :: proc(s: string, allocator := context.allocator, loc := #caller_location) -> (output: string, was_allocation: bool) { + /* + & -> & + ' -> ' // ' is shorter than ' (NOTE: ' was not available until HTML 5) + < -> < + > -> > + " -> " // " is shorter than " + */ + + b := transmute([]byte)s + + extra_bytes_needed := 0 + + for c in b { + switch c { + case '&': extra_bytes_needed += 4 + case '\'': extra_bytes_needed += 4 + case '<': extra_bytes_needed += 3 + case '>': extra_bytes_needed += 3 + case '"': extra_bytes_needed += 4 + } + } + + if extra_bytes_needed == 0 { + return s, false + } + + t, err := make([]byte, len(s) + extra_bytes_needed, allocator, loc) + if err != nil { + return + } + was_allocation = true + + w := 0 + for c in b { + x := "" + switch c { + case '&': x = "&" + case '\'': x = "'" + case '<': x = "<" + case '>': x = ">" + case '"': x = """ + } + if x != "" { + copy(t[w:], x) + w += len(x) + } else { + t[w] = c + w += 1 + } + } + output = string(t[0:w]) + return +} + + +@(require_results) +unescape_html :: proc(s: string, allocator := context.allocator, loc := #caller_location) -> (output: string, was_allocation: bool, err: runtime.Allocator_Error) { + @(require_results) + do_append :: proc(s: string, amp_idx: int, buf: ^[dynamic]byte) -> (n: int) { + s, amp_idx := s, amp_idx + + n += len(s[:amp_idx]) + if buf != nil { append(buf, s[:amp_idx]) } + s = s[amp_idx:] + for len(s) > 0 { + b, w, j := unescape_entity(s) + n += w + if buf != nil { append(buf, ..b[:w]) } + + s = s[j:] + + amp_idx = strings.index_byte(s, '&') + if amp_idx < 0 { + n += len(s) + if buf != nil { append(buf, s) } + break + } + n += amp_idx + if buf != nil { append(buf, s[:amp_idx]) } + s = s[amp_idx:] + } + + return + } + + s := s + amp_idx := strings.index_byte(s, '&') + if amp_idx < 0 { + return s, false, nil + } + + // NOTE(bill): this does a two pass in order to minimize the allocations required + bytes_required := do_append(s, amp_idx, nil) + + buf := make([dynamic]byte, 0, bytes_required, allocator, loc) or_return + was_allocation = true + + _ = do_append(s, amp_idx, &buf) + + assert(len(buf) == cap(buf)) + output = string(buf[:]) + + return +} + +// Returns an unescaped string of an encoded XML/HTML entity. +@(require_results) +unescape_entity :: proc(s: string) -> (b: [8]byte, w: int, j: int) { + s := s + if len(s) < 2 { + return + } + if s[0] != '&' { + return + } + j = 1 + + if s[j] == '#' { // scan numbers + j += 1 + if len(s) <= 3 { // remove `&#.` + return + } + c := s[j] + hex := false + if c == 'x' || c == 'X' { + hex = true + j += 1 + } + + x := rune(0) + scan_number: for j < len(s) { + c = s[j] + j += 1 + if hex { + switch c { + case '0'..='9': x = 16*x + rune(c) - '0'; continue scan_number + case 'a'..='f': x = 16*x + rune(c) - 'a' + 10; continue scan_number + case 'A'..='F': x = 16*x + rune(c) - 'A' + 10; continue scan_number + } + } else { + switch c { + case '0'..='9': x = 10*x + rune(c) - '0'; continue scan_number + } + } + + // Keep the ';' to check for cases which require it and cases which might not + if c != ';' { + j -= 1 + } + break scan_number + } + + + if j <= 3 { // no replacement characters found + return + } + + @(static, rodata) + windows_1252_replacement_table := [0xa0 - 0x80]rune{ // Windows-1252 -> UTF-8 + '\u20ac', '\u0081', '\u201a', '\u0192', + '\u201e', '\u2026', '\u2020', '\u2021', + '\u02c6', '\u2030', '\u0160', '\u2039', + '\u0152', '\u008d', '\u017d', '\u008f', + '\u0090', '\u2018', '\u2019', '\u201c', + '\u201d', '\u2022', '\u2013', '\u2014', + '\u02dc', '\u2122', '\u0161', '\u203a', + '\u0153', '\u009d', '\u017e', '\u0178', + } + + switch x { + case 0x80..<0xa0: + x = windows_1252_replacement_table[x-0x80] + case 0, 0xd800..=0xdfff: + x = utf8.RUNE_ERROR + case: + if x > 0x10ffff { + x = utf8.RUNE_ERROR + } + + } + + b1, w1 := utf8.encode_rune(x) + w += copy(b[:], b1[:w1]) + return + } + + // Lookup by entity names + + scan_ident: for j < len(s) { // scan over letters and digits + c := s[j] + j += 1 + + switch c { + case 'a'..='z', 'A'..='Z', '0'..='9': + continue scan_ident + } + // Keep the ';' to check for cases which require it and cases which might not + if c != ';' { + j -= 1 + } + break scan_ident + } + + entity_name := s[1:j] + if len(entity_name) == 0 { + return + } + + if entity_name[len(entity_name)-1] == ';' { + entity_name = entity_name[:len(entity_name)-1] + } + + if r2, _, ok := named_xml_entity_to_rune(entity_name); ok { + b1, w1 := utf8.encode_rune(r2[0]) + w += copy(b[w:], b1[:w1]) + if r2[1] != 0 { + b2, w2 := utf8.encode_rune(r2[1]) + w += copy(b[w:], b2[:w2]) + } + return + } + + // The longest entities that do not end with a semicolon are <=6 bytes long + LONGEST_ENTITY_WITHOUT_SEMICOLON :: 6 + + n := min(len(entity_name)-1, LONGEST_ENTITY_WITHOUT_SEMICOLON) + for i := n; i > 1; i -= 1 { + if r2, _, ok := named_xml_entity_to_rune(entity_name[:i]); ok { + b1, w1 := utf8.encode_rune(r2[0]) + w += copy(b[w:], b1[:w1]) + if r2[1] != 0 { + b2, w2 := utf8.encode_rune(r2[1]) + w += copy(b[w:], b2[:w2]) + } + return + } + } + + return +} + + // Private XML helper to extract `&;` entity. @(private="file") _extract_xml_entity :: proc(t: ^Tokenizer) -> (entity: string, err: Error) { diff --git a/core/encoding/entity/generated.odin b/core/encoding/entity/generated.odin index 52027ae03..0096c8199 100644 --- a/core/encoding/entity/generated.odin +++ b/core/encoding/entity/generated.odin @@ -43,5047 +43,5047 @@ XML_NAME_TO_RUNE_MAX_LENGTH :: 31 entity_name - a string, like "copy" that describes a user-encoded Unicode entity as used in XML. Returns: - "decoded" - The decoded rune if found by name, or -1 otherwise. - "ok" - true if found, false if not. + "decoded" - The decoded runes if found by name, or all zero otherwise. + "rune_count" - The number of decoded runes + "ok" - true if found, false if not. IMPORTANT: XML processors (including browsers) treat these names as case-sensitive. So do we. */ -named_xml_entity_to_rune :: proc(name: string) -> (decoded: rune, ok: bool) { +named_xml_entity_to_rune :: proc(name: string) -> (decoded: [2]rune, rune_count: int, ok: bool) { /* Early out if the name is too short or too long. min as a precaution in case the generated table has a bogus value. */ if len(name) < min(1, XML_NAME_TO_RUNE_MIN_LENGTH) || len(name) > XML_NAME_TO_RUNE_MAX_LENGTH { - return -1, false + return } switch rune(name[0]) { - case 'A': switch name { case "AElig": // LATIN CAPITAL LETTER AE - return rune(0xc6), true + return {'Æ', 0}, 1, true case "AMP": // AMPERSAND - return rune(0x26), true + return {'&', 0}, 1, true case "Aacgr": // GREEK CAPITAL LETTER ALPHA WITH TONOS - return rune(0x0386), true + return {'\u0386', 0}, 1, true case "Aacute": // LATIN CAPITAL LETTER A WITH ACUTE - return rune(0xc1), true + return {'Á', 0}, 1, true case "Abreve": // LATIN CAPITAL LETTER A WITH BREVE - return rune(0x0102), true + return {'\u0102', 0}, 1, true case "Acirc": // LATIN CAPITAL LETTER A WITH CIRCUMFLEX - return rune(0xc2), true + return {'Â', 0}, 1, true case "Acy": // CYRILLIC CAPITAL LETTER A - return rune(0x0410), true + return {'\u0410', 0}, 1, true case "Afr": // MATHEMATICAL FRAKTUR CAPITAL A - return rune(0x01d504), true + return {'\U0001d504', 0}, 1, true case "Agr": // GREEK CAPITAL LETTER ALPHA - return rune(0x0391), true + return {'\u0391', 0}, 1, true case "Agrave": // LATIN CAPITAL LETTER A WITH GRAVE - return rune(0xc0), true + return {'À', 0}, 1, true case "Alpha": // GREEK CAPITAL LETTER ALPHA - return rune(0x0391), true + return {'\u0391', 0}, 1, true case "Amacr": // LATIN CAPITAL LETTER A WITH MACRON - return rune(0x0100), true + return {'\u0100', 0}, 1, true case "And": // DOUBLE LOGICAL AND - return rune(0x2a53), true + return {'\u2a53', 0}, 1, true case "Aogon": // LATIN CAPITAL LETTER A WITH OGONEK - return rune(0x0104), true + return {'\u0104', 0}, 1, true case "Aopf": // MATHEMATICAL DOUBLE-STRUCK CAPITAL A - return rune(0x01d538), true + return {'\U0001d538', 0}, 1, true case "ApplyFunction": // FUNCTION APPLICATION - return rune(0x2061), true + return {'\u2061', 0}, 1, true case "Aring": // LATIN CAPITAL LETTER A WITH RING ABOVE - return rune(0xc5), true + return {'Å', 0}, 1, true case "Ascr": // MATHEMATICAL SCRIPT CAPITAL A - return rune(0x01d49c), true + return {'\U0001d49c', 0}, 1, true case "Assign": // COLON EQUALS - return rune(0x2254), true + return {'\u2254', 0}, 1, true case "Ast": // TWO ASTERISKS ALIGNED VERTICALLY - return rune(0x2051), true + return {'\u2051', 0}, 1, true case "Atilde": // LATIN CAPITAL LETTER A WITH TILDE - return rune(0xc3), true + return {'Ã', 0}, 1, true case "Auml": // LATIN CAPITAL LETTER A WITH DIAERESIS - return rune(0xc4), true + return {'Ä', 0}, 1, true } case 'B': switch name { case "Backslash": // SET MINUS - return rune(0x2216), true + return {'\u2216', 0}, 1, true case "Barint": // INTEGRAL WITH DOUBLE STROKE - return rune(0x2a0e), true + return {'\u2a0e', 0}, 1, true case "Barv": // SHORT DOWN TACK WITH OVERBAR - return rune(0x2ae7), true + return {'\u2ae7', 0}, 1, true case "Barwed": // PERSPECTIVE - return rune(0x2306), true + return {'\u2306', 0}, 1, true case "Barwedl": // LOGICAL AND WITH DOUBLE OVERBAR - return rune(0x2a5e), true + return {'\u2a5e', 0}, 1, true case "Bcy": // CYRILLIC CAPITAL LETTER BE - return rune(0x0411), true + return {'\u0411', 0}, 1, true case "Because": // BECAUSE - return rune(0x2235), true + return {'\u2235', 0}, 1, true case "Bernoullis": // SCRIPT CAPITAL B - return rune(0x212c), true + return {'\u212c', 0}, 1, true case "Beta": // GREEK CAPITAL LETTER BETA - return rune(0x0392), true + return {'\u0392', 0}, 1, true case "Bfr": // MATHEMATICAL FRAKTUR CAPITAL B - return rune(0x01d505), true + return {'\U0001d505', 0}, 1, true case "Bgr": // GREEK CAPITAL LETTER BETA - return rune(0x0392), true + return {'\u0392', 0}, 1, true case "Bopf": // MATHEMATICAL DOUBLE-STRUCK CAPITAL B - return rune(0x01d539), true + return {'\U0001d539', 0}, 1, true case "Breve": // BREVE - return rune(0x02d8), true + return {'\u02d8', 0}, 1, true case "Bscr": // SCRIPT CAPITAL B - return rune(0x212c), true + return {'\u212c', 0}, 1, true case "Bumpeq": // GEOMETRICALLY EQUIVALENT TO - return rune(0x224e), true + return {'\u224e', 0}, 1, true case "Bvert": // BOX DRAWINGS LIGHT TRIPLE DASH VERTICAL - return rune(0x2506), true + return {'\u2506', 0}, 1, true } case 'C': switch name { case "CHcy": // CYRILLIC CAPITAL LETTER CHE - return rune(0x0427), true + return {'\u0427', 0}, 1, true case "COPY": // COPYRIGHT SIGN - return rune(0xa9), true + return {'©', 0}, 1, true case "Cacute": // LATIN CAPITAL LETTER C WITH ACUTE - return rune(0x0106), true + return {'\u0106', 0}, 1, true case "Cap": // DOUBLE INTERSECTION - return rune(0x22d2), true + return {'\u22d2', 0}, 1, true case "CapitalDifferentialD": // DOUBLE-STRUCK ITALIC CAPITAL D - return rune(0x2145), true + return {'\u2145', 0}, 1, true case "Cayleys": // BLACK-LETTER CAPITAL C - return rune(0x212d), true + return {'\u212d', 0}, 1, true case "Ccaron": // LATIN CAPITAL LETTER C WITH CARON - return rune(0x010c), true + return {'\u010c', 0}, 1, true case "Ccedil": // LATIN CAPITAL LETTER C WITH CEDILLA - return rune(0xc7), true + return {'Ç', 0}, 1, true case "Ccirc": // LATIN CAPITAL LETTER C WITH CIRCUMFLEX - return rune(0x0108), true + return {'\u0108', 0}, 1, true case "Cconint": // VOLUME INTEGRAL - return rune(0x2230), true + return {'\u2230', 0}, 1, true case "Cdot": // LATIN CAPITAL LETTER C WITH DOT ABOVE - return rune(0x010a), true + return {'\u010a', 0}, 1, true case "Cedilla": // CEDILLA - return rune(0xb8), true + return {'¸', 0}, 1, true case "CenterDot": // MIDDLE DOT - return rune(0xb7), true + return {'·', 0}, 1, true case "Cfr": // BLACK-LETTER CAPITAL C - return rune(0x212d), true + return {'\u212d', 0}, 1, true case "Chi": // GREEK CAPITAL LETTER CHI - return rune(0x03a7), true + return {'\u03a7', 0}, 1, true case "CircleDot": // CIRCLED DOT OPERATOR - return rune(0x2299), true + return {'\u2299', 0}, 1, true case "CircleMinus": // CIRCLED MINUS - return rune(0x2296), true + return {'\u2296', 0}, 1, true case "CirclePlus": // CIRCLED PLUS - return rune(0x2295), true + return {'\u2295', 0}, 1, true case "CircleTimes": // CIRCLED TIMES - return rune(0x2297), true + return {'\u2297', 0}, 1, true case "ClockwiseContourIntegral": // CLOCKWISE CONTOUR INTEGRAL - return rune(0x2232), true + return {'\u2232', 0}, 1, true case "CloseCurlyDoubleQuote": // RIGHT DOUBLE QUOTATION MARK - return rune(0x201d), true + return {'\u201d', 0}, 1, true case "CloseCurlyQuote": // RIGHT SINGLE QUOTATION MARK - return rune(0x2019), true + return {'\u2019', 0}, 1, true case "Colon": // PROPORTION - return rune(0x2237), true + return {'\u2237', 0}, 1, true case "Colone": // DOUBLE COLON EQUAL - return rune(0x2a74), true + return {'\u2a74', 0}, 1, true case "Congruent": // IDENTICAL TO - return rune(0x2261), true + return {'\u2261', 0}, 1, true case "Conint": // SURFACE INTEGRAL - return rune(0x222f), true + return {'\u222f', 0}, 1, true case "ContourIntegral": // CONTOUR INTEGRAL - return rune(0x222e), true + return {'\u222e', 0}, 1, true case "Copf": // DOUBLE-STRUCK CAPITAL C - return rune(0x2102), true + return {'\u2102', 0}, 1, true case "Coproduct": // N-ARY COPRODUCT - return rune(0x2210), true + return {'\u2210', 0}, 1, true case "CounterClockwiseContourIntegral": // ANTICLOCKWISE CONTOUR INTEGRAL - return rune(0x2233), true + return {'\u2233', 0}, 1, true case "Cross": // VECTOR OR CROSS PRODUCT - return rune(0x2a2f), true + return {'\u2a2f', 0}, 1, true case "Cscr": // MATHEMATICAL SCRIPT CAPITAL C - return rune(0x01d49e), true + return {'\U0001d49e', 0}, 1, true case "Cup": // DOUBLE UNION - return rune(0x22d3), true + return {'\u22d3', 0}, 1, true case "CupCap": // EQUIVALENT TO - return rune(0x224d), true + return {'\u224d', 0}, 1, true } case 'D': switch name { case "DD": // DOUBLE-STRUCK ITALIC CAPITAL D - return rune(0x2145), true + return {'\u2145', 0}, 1, true case "DDotrahd": // RIGHTWARDS ARROW WITH DOTTED STEM - return rune(0x2911), true + return {'\u2911', 0}, 1, true case "DJcy": // CYRILLIC CAPITAL LETTER DJE - return rune(0x0402), true + return {'\u0402', 0}, 1, true case "DScy": // CYRILLIC CAPITAL LETTER DZE - return rune(0x0405), true + return {'\u0405', 0}, 1, true case "DZcy": // CYRILLIC CAPITAL LETTER DZHE - return rune(0x040f), true + return {'\u040f', 0}, 1, true case "Dagger": // DOUBLE DAGGER - return rune(0x2021), true + return {'\u2021', 0}, 1, true case "Darr": // DOWNWARDS TWO HEADED ARROW - return rune(0x21a1), true + return {'\u21a1', 0}, 1, true case "Dashv": // VERTICAL BAR DOUBLE LEFT TURNSTILE - return rune(0x2ae4), true + return {'\u2ae4', 0}, 1, true case "Dcaron": // LATIN CAPITAL LETTER D WITH CARON - return rune(0x010e), true + return {'\u010e', 0}, 1, true case "Dcy": // CYRILLIC CAPITAL LETTER DE - return rune(0x0414), true + return {'\u0414', 0}, 1, true case "Del": // NABLA - return rune(0x2207), true + return {'\u2207', 0}, 1, true case "Delta": // GREEK CAPITAL LETTER DELTA - return rune(0x0394), true + return {'\u0394', 0}, 1, true case "Dfr": // MATHEMATICAL FRAKTUR CAPITAL D - return rune(0x01d507), true + return {'\U0001d507', 0}, 1, true case "Dgr": // GREEK CAPITAL LETTER DELTA - return rune(0x0394), true + return {'\u0394', 0}, 1, true case "DiacriticalAcute": // ACUTE ACCENT - return rune(0xb4), true + return {'´', 0}, 1, true case "DiacriticalDot": // DOT ABOVE - return rune(0x02d9), true + return {'\u02d9', 0}, 1, true case "DiacriticalDoubleAcute": // DOUBLE ACUTE ACCENT - return rune(0x02dd), true + return {'\u02dd', 0}, 1, true case "DiacriticalGrave": // GRAVE ACCENT - return rune(0x60), true + return {'`', 0}, 1, true case "DiacriticalTilde": // SMALL TILDE - return rune(0x02dc), true + return {'\u02dc', 0}, 1, true case "Diamond": // DIAMOND OPERATOR - return rune(0x22c4), true + return {'\u22c4', 0}, 1, true case "DifferentialD": // DOUBLE-STRUCK ITALIC SMALL D - return rune(0x2146), true + return {'\u2146', 0}, 1, true case "Dopf": // MATHEMATICAL DOUBLE-STRUCK CAPITAL D - return rune(0x01d53b), true + return {'\U0001d53b', 0}, 1, true case "Dot": // DIAERESIS - return rune(0xa8), true + return {'¨', 0}, 1, true case "DotDot": // COMBINING FOUR DOTS ABOVE - return rune(0x20dc), true + return {'\u20dc', 0}, 1, true case "DotEqual": // APPROACHES THE LIMIT - return rune(0x2250), true + return {'\u2250', 0}, 1, true case "DoubleContourIntegral": // SURFACE INTEGRAL - return rune(0x222f), true + return {'\u222f', 0}, 1, true case "DoubleDot": // DIAERESIS - return rune(0xa8), true + return {'¨', 0}, 1, true case "DoubleDownArrow": // DOWNWARDS DOUBLE ARROW - return rune(0x21d3), true + return {'\u21d3', 0}, 1, true case "DoubleLeftArrow": // LEFTWARDS DOUBLE ARROW - return rune(0x21d0), true + return {'\u21d0', 0}, 1, true case "DoubleLeftRightArrow": // LEFT RIGHT DOUBLE ARROW - return rune(0x21d4), true + return {'\u21d4', 0}, 1, true case "DoubleLeftTee": // VERTICAL BAR DOUBLE LEFT TURNSTILE - return rune(0x2ae4), true + return {'\u2ae4', 0}, 1, true case "DoubleLongLeftArrow": // LONG LEFTWARDS DOUBLE ARROW - return rune(0x27f8), true + return {'\u27f8', 0}, 1, true case "DoubleLongLeftRightArrow": // LONG LEFT RIGHT DOUBLE ARROW - return rune(0x27fa), true + return {'\u27fa', 0}, 1, true case "DoubleLongRightArrow": // LONG RIGHTWARDS DOUBLE ARROW - return rune(0x27f9), true + return {'\u27f9', 0}, 1, true case "DoubleRightArrow": // RIGHTWARDS DOUBLE ARROW - return rune(0x21d2), true + return {'\u21d2', 0}, 1, true case "DoubleRightTee": // TRUE - return rune(0x22a8), true + return {'\u22a8', 0}, 1, true case "DoubleUpArrow": // UPWARDS DOUBLE ARROW - return rune(0x21d1), true + return {'\u21d1', 0}, 1, true case "DoubleUpDownArrow": // UP DOWN DOUBLE ARROW - return rune(0x21d5), true + return {'\u21d5', 0}, 1, true case "DoubleVerticalBar": // PARALLEL TO - return rune(0x2225), true + return {'\u2225', 0}, 1, true case "DownArrow": // DOWNWARDS ARROW - return rune(0x2193), true + return {'\u2193', 0}, 1, true case "DownArrowBar": // DOWNWARDS ARROW TO BAR - return rune(0x2913), true + return {'\u2913', 0}, 1, true case "DownArrowUpArrow": // DOWNWARDS ARROW LEFTWARDS OF UPWARDS ARROW - return rune(0x21f5), true + return {'\u21f5', 0}, 1, true case "DownBreve": // COMBINING INVERTED BREVE - return rune(0x0311), true + return {'\u0311', 0}, 1, true case "DownLeftRightVector": // LEFT BARB DOWN RIGHT BARB DOWN HARPOON - return rune(0x2950), true + return {'\u2950', 0}, 1, true case "DownLeftTeeVector": // LEFTWARDS HARPOON WITH BARB DOWN FROM BAR - return rune(0x295e), true + return {'\u295e', 0}, 1, true case "DownLeftVector": // LEFTWARDS HARPOON WITH BARB DOWNWARDS - return rune(0x21bd), true + return {'\u21bd', 0}, 1, true case "DownLeftVectorBar": // LEFTWARDS HARPOON WITH BARB DOWN TO BAR - return rune(0x2956), true + return {'\u2956', 0}, 1, true case "DownRightTeeVector": // RIGHTWARDS HARPOON WITH BARB DOWN FROM BAR - return rune(0x295f), true + return {'\u295f', 0}, 1, true case "DownRightVector": // RIGHTWARDS HARPOON WITH BARB DOWNWARDS - return rune(0x21c1), true + return {'\u21c1', 0}, 1, true case "DownRightVectorBar": // RIGHTWARDS HARPOON WITH BARB DOWN TO BAR - return rune(0x2957), true + return {'\u2957', 0}, 1, true case "DownTee": // DOWN TACK - return rune(0x22a4), true + return {'\u22a4', 0}, 1, true case "DownTeeArrow": // DOWNWARDS ARROW FROM BAR - return rune(0x21a7), true + return {'\u21a7', 0}, 1, true case "Downarrow": // DOWNWARDS DOUBLE ARROW - return rune(0x21d3), true + return {'\u21d3', 0}, 1, true case "Dscr": // MATHEMATICAL SCRIPT CAPITAL D - return rune(0x01d49f), true + return {'\U0001d49f', 0}, 1, true case "Dstrok": // LATIN CAPITAL LETTER D WITH STROKE - return rune(0x0110), true + return {'\u0110', 0}, 1, true } case 'E': switch name { case "EEacgr": // GREEK CAPITAL LETTER ETA WITH TONOS - return rune(0x0389), true + return {'\u0389', 0}, 1, true case "EEgr": // GREEK CAPITAL LETTER ETA - return rune(0x0397), true + return {'\u0397', 0}, 1, true case "ENG": // LATIN CAPITAL LETTER ENG - return rune(0x014a), true + return {'\u014a', 0}, 1, true case "ETH": // LATIN CAPITAL LETTER ETH - return rune(0xd0), true + return {'Ð', 0}, 1, true case "Eacgr": // GREEK CAPITAL LETTER EPSILON WITH TONOS - return rune(0x0388), true + return {'\u0388', 0}, 1, true case "Eacute": // LATIN CAPITAL LETTER E WITH ACUTE - return rune(0xc9), true + return {'É', 0}, 1, true case "Ecaron": // LATIN CAPITAL LETTER E WITH CARON - return rune(0x011a), true + return {'\u011a', 0}, 1, true case "Ecirc": // LATIN CAPITAL LETTER E WITH CIRCUMFLEX - return rune(0xca), true + return {'Ê', 0}, 1, true case "Ecy": // CYRILLIC CAPITAL LETTER E - return rune(0x042d), true + return {'\u042d', 0}, 1, true case "Edot": // LATIN CAPITAL LETTER E WITH DOT ABOVE - return rune(0x0116), true + return {'\u0116', 0}, 1, true case "Efr": // MATHEMATICAL FRAKTUR CAPITAL E - return rune(0x01d508), true + return {'\U0001d508', 0}, 1, true case "Egr": // GREEK CAPITAL LETTER EPSILON - return rune(0x0395), true + return {'\u0395', 0}, 1, true case "Egrave": // LATIN CAPITAL LETTER E WITH GRAVE - return rune(0xc8), true + return {'È', 0}, 1, true case "Element": // ELEMENT OF - return rune(0x2208), true + return {'\u2208', 0}, 1, true case "Emacr": // LATIN CAPITAL LETTER E WITH MACRON - return rune(0x0112), true + return {'\u0112', 0}, 1, true case "EmptySmallSquare": // WHITE MEDIUM SQUARE - return rune(0x25fb), true + return {'\u25fb', 0}, 1, true case "EmptyVerySmallSquare": // WHITE SMALL SQUARE - return rune(0x25ab), true + return {'\u25ab', 0}, 1, true case "Eogon": // LATIN CAPITAL LETTER E WITH OGONEK - return rune(0x0118), true + return {'\u0118', 0}, 1, true case "Eopf": // MATHEMATICAL DOUBLE-STRUCK CAPITAL E - return rune(0x01d53c), true + return {'\U0001d53c', 0}, 1, true case "Epsilon": // GREEK CAPITAL LETTER EPSILON - return rune(0x0395), true + return {'\u0395', 0}, 1, true case "Equal": // TWO CONSECUTIVE EQUALS SIGNS - return rune(0x2a75), true + return {'\u2a75', 0}, 1, true case "EqualTilde": // MINUS TILDE - return rune(0x2242), true + return {'\u2242', 0}, 1, true case "Equilibrium": // RIGHTWARDS HARPOON OVER LEFTWARDS HARPOON - return rune(0x21cc), true + return {'\u21cc', 0}, 1, true case "Escr": // SCRIPT CAPITAL E - return rune(0x2130), true + return {'\u2130', 0}, 1, true case "Esim": // EQUALS SIGN ABOVE TILDE OPERATOR - return rune(0x2a73), true + return {'\u2a73', 0}, 1, true case "Eta": // GREEK CAPITAL LETTER ETA - return rune(0x0397), true + return {'\u0397', 0}, 1, true case "Euml": // LATIN CAPITAL LETTER E WITH DIAERESIS - return rune(0xcb), true + return {'Ë', 0}, 1, true case "Exists": // THERE EXISTS - return rune(0x2203), true + return {'\u2203', 0}, 1, true case "ExponentialE": // DOUBLE-STRUCK ITALIC SMALL E - return rune(0x2147), true + return {'\u2147', 0}, 1, true } case 'F': switch name { case "Fcy": // CYRILLIC CAPITAL LETTER EF - return rune(0x0424), true + return {'\u0424', 0}, 1, true case "Ffr": // MATHEMATICAL FRAKTUR CAPITAL F - return rune(0x01d509), true + return {'\U0001d509', 0}, 1, true case "FilledSmallSquare": // BLACK MEDIUM SQUARE - return rune(0x25fc), true + return {'\u25fc', 0}, 1, true case "FilledVerySmallSquare": // BLACK SMALL SQUARE - return rune(0x25aa), true + return {'\u25aa', 0}, 1, true case "Fopf": // MATHEMATICAL DOUBLE-STRUCK CAPITAL F - return rune(0x01d53d), true + return {'\U0001d53d', 0}, 1, true case "ForAll": // FOR ALL - return rune(0x2200), true + return {'\u2200', 0}, 1, true case "Fouriertrf": // SCRIPT CAPITAL F - return rune(0x2131), true + return {'\u2131', 0}, 1, true case "Fscr": // SCRIPT CAPITAL F - return rune(0x2131), true + return {'\u2131', 0}, 1, true } case 'G': switch name { case "GJcy": // CYRILLIC CAPITAL LETTER GJE - return rune(0x0403), true + return {'\u0403', 0}, 1, true case "GT": // GREATER-THAN SIGN - return rune(0x3e), true + return {'>', 0}, 1, true case "Game": // TURNED SANS-SERIF CAPITAL G - return rune(0x2141), true + return {'\u2141', 0}, 1, true case "Gamma": // GREEK CAPITAL LETTER GAMMA - return rune(0x0393), true + return {'\u0393', 0}, 1, true case "Gammad": // GREEK LETTER DIGAMMA - return rune(0x03dc), true + return {'\u03dc', 0}, 1, true case "Gbreve": // LATIN CAPITAL LETTER G WITH BREVE - return rune(0x011e), true + return {'\u011e', 0}, 1, true case "Gcedil": // LATIN CAPITAL LETTER G WITH CEDILLA - return rune(0x0122), true + return {'\u0122', 0}, 1, true case "Gcirc": // LATIN CAPITAL LETTER G WITH CIRCUMFLEX - return rune(0x011c), true + return {'\u011c', 0}, 1, true case "Gcy": // CYRILLIC CAPITAL LETTER GHE - return rune(0x0413), true + return {'\u0413', 0}, 1, true case "Gdot": // LATIN CAPITAL LETTER G WITH DOT ABOVE - return rune(0x0120), true + return {'\u0120', 0}, 1, true case "Gfr": // MATHEMATICAL FRAKTUR CAPITAL G - return rune(0x01d50a), true + return {'\U0001d50a', 0}, 1, true case "Gg": // VERY MUCH GREATER-THAN - return rune(0x22d9), true + return {'\u22d9', 0}, 1, true case "Ggr": // GREEK CAPITAL LETTER GAMMA - return rune(0x0393), true + return {'\u0393', 0}, 1, true case "Gopf": // MATHEMATICAL DOUBLE-STRUCK CAPITAL G - return rune(0x01d53e), true + return {'\U0001d53e', 0}, 1, true case "GreaterEqual": // GREATER-THAN OR EQUAL TO - return rune(0x2265), true + return {'\u2265', 0}, 1, true case "GreaterEqualLess": // GREATER-THAN EQUAL TO OR LESS-THAN - return rune(0x22db), true + return {'\u22db', 0}, 1, true case "GreaterFullEqual": // GREATER-THAN OVER EQUAL TO - return rune(0x2267), true + return {'\u2267', 0}, 1, true case "GreaterGreater": // DOUBLE NESTED GREATER-THAN - return rune(0x2aa2), true + return {'\u2aa2', 0}, 1, true case "GreaterLess": // GREATER-THAN OR LESS-THAN - return rune(0x2277), true + return {'\u2277', 0}, 1, true case "GreaterSlantEqual": // GREATER-THAN OR SLANTED EQUAL TO - return rune(0x2a7e), true + return {'\u2a7e', 0}, 1, true case "GreaterTilde": // GREATER-THAN OR EQUIVALENT TO - return rune(0x2273), true + return {'\u2273', 0}, 1, true case "Gscr": // MATHEMATICAL SCRIPT CAPITAL G - return rune(0x01d4a2), true + return {'\U0001d4a2', 0}, 1, true case "Gt": // MUCH GREATER-THAN - return rune(0x226b), true + return {'\u226b', 0}, 1, true } case 'H': switch name { case "HARDcy": // CYRILLIC CAPITAL LETTER HARD SIGN - return rune(0x042a), true + return {'\u042a', 0}, 1, true case "Hacek": // CARON - return rune(0x02c7), true + return {'\u02c7', 0}, 1, true case "Hat": // CIRCUMFLEX ACCENT - return rune(0x5e), true + return {'^', 0}, 1, true case "Hcirc": // LATIN CAPITAL LETTER H WITH CIRCUMFLEX - return rune(0x0124), true + return {'\u0124', 0}, 1, true case "Hfr": // BLACK-LETTER CAPITAL H - return rune(0x210c), true + return {'\u210c', 0}, 1, true case "HilbertSpace": // SCRIPT CAPITAL H - return rune(0x210b), true + return {'\u210b', 0}, 1, true case "Hopf": // DOUBLE-STRUCK CAPITAL H - return rune(0x210d), true + return {'\u210d', 0}, 1, true case "HorizontalLine": // BOX DRAWINGS LIGHT HORIZONTAL - return rune(0x2500), true + return {'\u2500', 0}, 1, true case "Hscr": // SCRIPT CAPITAL H - return rune(0x210b), true + return {'\u210b', 0}, 1, true case "Hstrok": // LATIN CAPITAL LETTER H WITH STROKE - return rune(0x0126), true + return {'\u0126', 0}, 1, true case "HumpDownHump": // GEOMETRICALLY EQUIVALENT TO - return rune(0x224e), true + return {'\u224e', 0}, 1, true case "HumpEqual": // DIFFERENCE BETWEEN - return rune(0x224f), true + return {'\u224f', 0}, 1, true } case 'I': switch name { case "IEcy": // CYRILLIC CAPITAL LETTER IE - return rune(0x0415), true + return {'\u0415', 0}, 1, true case "IJlig": // LATIN CAPITAL LIGATURE IJ - return rune(0x0132), true + return {'\u0132', 0}, 1, true case "IOcy": // CYRILLIC CAPITAL LETTER IO - return rune(0x0401), true + return {'\u0401', 0}, 1, true case "Iacgr": // GREEK CAPITAL LETTER IOTA WITH TONOS - return rune(0x038a), true + return {'\u038a', 0}, 1, true case "Iacute": // LATIN CAPITAL LETTER I WITH ACUTE - return rune(0xcd), true + return {'Í', 0}, 1, true case "Icirc": // LATIN CAPITAL LETTER I WITH CIRCUMFLEX - return rune(0xce), true + return {'Î', 0}, 1, true case "Icy": // CYRILLIC CAPITAL LETTER I - return rune(0x0418), true + return {'\u0418', 0}, 1, true case "Idigr": // GREEK CAPITAL LETTER IOTA WITH DIALYTIKA - return rune(0x03aa), true + return {'\u03aa', 0}, 1, true case "Idot": // LATIN CAPITAL LETTER I WITH DOT ABOVE - return rune(0x0130), true + return {'\u0130', 0}, 1, true case "Ifr": // BLACK-LETTER CAPITAL I - return rune(0x2111), true + return {'\u2111', 0}, 1, true case "Igr": // GREEK CAPITAL LETTER IOTA - return rune(0x0399), true + return {'\u0399', 0}, 1, true case "Igrave": // LATIN CAPITAL LETTER I WITH GRAVE - return rune(0xcc), true + return {'Ì', 0}, 1, true case "Im": // BLACK-LETTER CAPITAL I - return rune(0x2111), true + return {'\u2111', 0}, 1, true case "Imacr": // LATIN CAPITAL LETTER I WITH MACRON - return rune(0x012a), true + return {'\u012a', 0}, 1, true case "ImaginaryI": // DOUBLE-STRUCK ITALIC SMALL I - return rune(0x2148), true + return {'\u2148', 0}, 1, true case "Implies": // RIGHTWARDS DOUBLE ARROW - return rune(0x21d2), true + return {'\u21d2', 0}, 1, true case "Int": // DOUBLE INTEGRAL - return rune(0x222c), true + return {'\u222c', 0}, 1, true case "Integral": // INTEGRAL - return rune(0x222b), true + return {'\u222b', 0}, 1, true case "Intersection": // N-ARY INTERSECTION - return rune(0x22c2), true + return {'\u22c2', 0}, 1, true case "InvisibleComma": // INVISIBLE SEPARATOR - return rune(0x2063), true + return {'\u2063', 0}, 1, true case "InvisibleTimes": // INVISIBLE TIMES - return rune(0x2062), true + return {'\u2062', 0}, 1, true case "Iogon": // LATIN CAPITAL LETTER I WITH OGONEK - return rune(0x012e), true + return {'\u012e', 0}, 1, true case "Iopf": // MATHEMATICAL DOUBLE-STRUCK CAPITAL I - return rune(0x01d540), true + return {'\U0001d540', 0}, 1, true case "Iota": // GREEK CAPITAL LETTER IOTA - return rune(0x0399), true + return {'\u0399', 0}, 1, true case "Iscr": // SCRIPT CAPITAL I - return rune(0x2110), true + return {'\u2110', 0}, 1, true case "Itilde": // LATIN CAPITAL LETTER I WITH TILDE - return rune(0x0128), true + return {'\u0128', 0}, 1, true case "Iukcy": // CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I - return rune(0x0406), true + return {'\u0406', 0}, 1, true case "Iuml": // LATIN CAPITAL LETTER I WITH DIAERESIS - return rune(0xcf), true + return {'Ï', 0}, 1, true } case 'J': switch name { case "Jcirc": // LATIN CAPITAL LETTER J WITH CIRCUMFLEX - return rune(0x0134), true + return {'\u0134', 0}, 1, true case "Jcy": // CYRILLIC CAPITAL LETTER SHORT I - return rune(0x0419), true + return {'\u0419', 0}, 1, true case "Jfr": // MATHEMATICAL FRAKTUR CAPITAL J - return rune(0x01d50d), true + return {'\U0001d50d', 0}, 1, true case "Jopf": // MATHEMATICAL DOUBLE-STRUCK CAPITAL J - return rune(0x01d541), true + return {'\U0001d541', 0}, 1, true case "Jscr": // MATHEMATICAL SCRIPT CAPITAL J - return rune(0x01d4a5), true + return {'\U0001d4a5', 0}, 1, true case "Jsercy": // CYRILLIC CAPITAL LETTER JE - return rune(0x0408), true + return {'\u0408', 0}, 1, true case "Jukcy": // CYRILLIC CAPITAL LETTER UKRAINIAN IE - return rune(0x0404), true + return {'\u0404', 0}, 1, true } case 'K': switch name { case "KHcy": // CYRILLIC CAPITAL LETTER HA - return rune(0x0425), true + return {'\u0425', 0}, 1, true case "KHgr": // GREEK CAPITAL LETTER CHI - return rune(0x03a7), true + return {'\u03a7', 0}, 1, true case "KJcy": // CYRILLIC CAPITAL LETTER KJE - return rune(0x040c), true + return {'\u040c', 0}, 1, true case "Kappa": // GREEK CAPITAL LETTER KAPPA - return rune(0x039a), true + return {'\u039a', 0}, 1, true case "Kcedil": // LATIN CAPITAL LETTER K WITH CEDILLA - return rune(0x0136), true + return {'\u0136', 0}, 1, true case "Kcy": // CYRILLIC CAPITAL LETTER KA - return rune(0x041a), true + return {'\u041a', 0}, 1, true case "Kfr": // MATHEMATICAL FRAKTUR CAPITAL K - return rune(0x01d50e), true + return {'\U0001d50e', 0}, 1, true case "Kgr": // GREEK CAPITAL LETTER KAPPA - return rune(0x039a), true + return {'\u039a', 0}, 1, true case "Kopf": // MATHEMATICAL DOUBLE-STRUCK CAPITAL K - return rune(0x01d542), true + return {'\U0001d542', 0}, 1, true case "Kscr": // MATHEMATICAL SCRIPT CAPITAL K - return rune(0x01d4a6), true + return {'\U0001d4a6', 0}, 1, true } case 'L': switch name { case "LJcy": // CYRILLIC CAPITAL LETTER LJE - return rune(0x0409), true + return {'\u0409', 0}, 1, true case "LT": // LESS-THAN SIGN - return rune(0x3c), true + return {'<', 0}, 1, true case "Lacute": // LATIN CAPITAL LETTER L WITH ACUTE - return rune(0x0139), true + return {'\u0139', 0}, 1, true case "Lambda": // GREEK CAPITAL LETTER LAMDA - return rune(0x039b), true + return {'\u039b', 0}, 1, true case "Lang": // MATHEMATICAL LEFT DOUBLE ANGLE BRACKET - return rune(0x27ea), true + return {'\u27ea', 0}, 1, true case "Laplacetrf": // SCRIPT CAPITAL L - return rune(0x2112), true + return {'\u2112', 0}, 1, true case "Larr": // LEFTWARDS TWO HEADED ARROW - return rune(0x219e), true + return {'\u219e', 0}, 1, true case "Lcaron": // LATIN CAPITAL LETTER L WITH CARON - return rune(0x013d), true + return {'\u013d', 0}, 1, true case "Lcedil": // LATIN CAPITAL LETTER L WITH CEDILLA - return rune(0x013b), true + return {'\u013b', 0}, 1, true case "Lcy": // CYRILLIC CAPITAL LETTER EL - return rune(0x041b), true + return {'\u041b', 0}, 1, true case "LeftAngleBracket": // MATHEMATICAL LEFT ANGLE BRACKET - return rune(0x27e8), true + return {'\u27e8', 0}, 1, true case "LeftArrow": // LEFTWARDS ARROW - return rune(0x2190), true + return {'\u2190', 0}, 1, true case "LeftArrowBar": // LEFTWARDS ARROW TO BAR - return rune(0x21e4), true + return {'\u21e4', 0}, 1, true case "LeftArrowRightArrow": // LEFTWARDS ARROW OVER RIGHTWARDS ARROW - return rune(0x21c6), true + return {'\u21c6', 0}, 1, true case "LeftCeiling": // LEFT CEILING - return rune(0x2308), true + return {'\u2308', 0}, 1, true case "LeftDoubleBracket": // MATHEMATICAL LEFT WHITE SQUARE BRACKET - return rune(0x27e6), true + return {'\u27e6', 0}, 1, true case "LeftDownTeeVector": // DOWNWARDS HARPOON WITH BARB LEFT FROM BAR - return rune(0x2961), true + return {'\u2961', 0}, 1, true case "LeftDownVector": // DOWNWARDS HARPOON WITH BARB LEFTWARDS - return rune(0x21c3), true + return {'\u21c3', 0}, 1, true case "LeftDownVectorBar": // DOWNWARDS HARPOON WITH BARB LEFT TO BAR - return rune(0x2959), true + return {'\u2959', 0}, 1, true case "LeftFloor": // LEFT FLOOR - return rune(0x230a), true + return {'\u230a', 0}, 1, true case "LeftRightArrow": // LEFT RIGHT ARROW - return rune(0x2194), true + return {'\u2194', 0}, 1, true case "LeftRightVector": // LEFT BARB UP RIGHT BARB UP HARPOON - return rune(0x294e), true + return {'\u294e', 0}, 1, true case "LeftTee": // LEFT TACK - return rune(0x22a3), true + return {'\u22a3', 0}, 1, true case "LeftTeeArrow": // LEFTWARDS ARROW FROM BAR - return rune(0x21a4), true + return {'\u21a4', 0}, 1, true case "LeftTeeVector": // LEFTWARDS HARPOON WITH BARB UP FROM BAR - return rune(0x295a), true + return {'\u295a', 0}, 1, true case "LeftTriangle": // NORMAL SUBGROUP OF - return rune(0x22b2), true + return {'\u22b2', 0}, 1, true case "LeftTriangleBar": // LEFT TRIANGLE BESIDE VERTICAL BAR - return rune(0x29cf), true + return {'\u29cf', 0}, 1, true case "LeftTriangleEqual": // NORMAL SUBGROUP OF OR EQUAL TO - return rune(0x22b4), true + return {'\u22b4', 0}, 1, true case "LeftUpDownVector": // UP BARB LEFT DOWN BARB LEFT HARPOON - return rune(0x2951), true + return {'\u2951', 0}, 1, true case "LeftUpTeeVector": // UPWARDS HARPOON WITH BARB LEFT FROM BAR - return rune(0x2960), true + return {'\u2960', 0}, 1, true case "LeftUpVector": // UPWARDS HARPOON WITH BARB LEFTWARDS - return rune(0x21bf), true + return {'\u21bf', 0}, 1, true case "LeftUpVectorBar": // UPWARDS HARPOON WITH BARB LEFT TO BAR - return rune(0x2958), true + return {'\u2958', 0}, 1, true case "LeftVector": // LEFTWARDS HARPOON WITH BARB UPWARDS - return rune(0x21bc), true + return {'\u21bc', 0}, 1, true case "LeftVectorBar": // LEFTWARDS HARPOON WITH BARB UP TO BAR - return rune(0x2952), true + return {'\u2952', 0}, 1, true case "Leftarrow": // LEFTWARDS DOUBLE ARROW - return rune(0x21d0), true + return {'\u21d0', 0}, 1, true case "Leftrightarrow": // LEFT RIGHT DOUBLE ARROW - return rune(0x21d4), true + return {'\u21d4', 0}, 1, true case "LessEqualGreater": // LESS-THAN EQUAL TO OR GREATER-THAN - return rune(0x22da), true + return {'\u22da', 0}, 1, true case "LessFullEqual": // LESS-THAN OVER EQUAL TO - return rune(0x2266), true + return {'\u2266', 0}, 1, true case "LessGreater": // LESS-THAN OR GREATER-THAN - return rune(0x2276), true + return {'\u2276', 0}, 1, true case "LessLess": // DOUBLE NESTED LESS-THAN - return rune(0x2aa1), true + return {'\u2aa1', 0}, 1, true case "LessSlantEqual": // LESS-THAN OR SLANTED EQUAL TO - return rune(0x2a7d), true + return {'\u2a7d', 0}, 1, true case "LessTilde": // LESS-THAN OR EQUIVALENT TO - return rune(0x2272), true + return {'\u2272', 0}, 1, true case "Lfr": // MATHEMATICAL FRAKTUR CAPITAL L - return rune(0x01d50f), true + return {'\U0001d50f', 0}, 1, true case "Lgr": // GREEK CAPITAL LETTER LAMDA - return rune(0x039b), true + return {'\u039b', 0}, 1, true case "Ll": // VERY MUCH LESS-THAN - return rune(0x22d8), true + return {'\u22d8', 0}, 1, true case "Lleftarrow": // LEFTWARDS TRIPLE ARROW - return rune(0x21da), true + return {'\u21da', 0}, 1, true case "Lmidot": // LATIN CAPITAL LETTER L WITH MIDDLE DOT - return rune(0x013f), true + return {'\u013f', 0}, 1, true case "LongLeftArrow": // LONG LEFTWARDS ARROW - return rune(0x27f5), true + return {'\u27f5', 0}, 1, true case "LongLeftRightArrow": // LONG LEFT RIGHT ARROW - return rune(0x27f7), true + return {'\u27f7', 0}, 1, true case "LongRightArrow": // LONG RIGHTWARDS ARROW - return rune(0x27f6), true + return {'\u27f6', 0}, 1, true case "Longleftarrow": // LONG LEFTWARDS DOUBLE ARROW - return rune(0x27f8), true + return {'\u27f8', 0}, 1, true case "Longleftrightarrow": // LONG LEFT RIGHT DOUBLE ARROW - return rune(0x27fa), true + return {'\u27fa', 0}, 1, true case "Longrightarrow": // LONG RIGHTWARDS DOUBLE ARROW - return rune(0x27f9), true + return {'\u27f9', 0}, 1, true case "Lopf": // MATHEMATICAL DOUBLE-STRUCK CAPITAL L - return rune(0x01d543), true + return {'\U0001d543', 0}, 1, true case "LowerLeftArrow": // SOUTH WEST ARROW - return rune(0x2199), true + return {'\u2199', 0}, 1, true case "LowerRightArrow": // SOUTH EAST ARROW - return rune(0x2198), true + return {'\u2198', 0}, 1, true case "Lscr": // SCRIPT CAPITAL L - return rune(0x2112), true + return {'\u2112', 0}, 1, true case "Lsh": // UPWARDS ARROW WITH TIP LEFTWARDS - return rune(0x21b0), true + return {'\u21b0', 0}, 1, true case "Lstrok": // LATIN CAPITAL LETTER L WITH STROKE - return rune(0x0141), true + return {'\u0141', 0}, 1, true case "Lt": // MUCH LESS-THAN - return rune(0x226a), true + return {'\u226a', 0}, 1, true case "Ltbar": // DOUBLE NESTED LESS-THAN WITH UNDERBAR - return rune(0x2aa3), true + return {'\u2aa3', 0}, 1, true } case 'M': switch name { case "Map": // RIGHTWARDS TWO-HEADED ARROW FROM BAR - return rune(0x2905), true + return {'\u2905', 0}, 1, true case "Mapfrom": // LEFTWARDS DOUBLE ARROW FROM BAR - return rune(0x2906), true + return {'\u2906', 0}, 1, true case "Mapto": // RIGHTWARDS DOUBLE ARROW FROM BAR - return rune(0x2907), true + return {'\u2907', 0}, 1, true case "Mcy": // CYRILLIC CAPITAL LETTER EM - return rune(0x041c), true + return {'\u041c', 0}, 1, true case "MediumSpace": // MEDIUM MATHEMATICAL SPACE - return rune(0x205f), true + return {'\u205f', 0}, 1, true case "Mellintrf": // SCRIPT CAPITAL M - return rune(0x2133), true + return {'\u2133', 0}, 1, true case "Mfr": // MATHEMATICAL FRAKTUR CAPITAL M - return rune(0x01d510), true + return {'\U0001d510', 0}, 1, true case "Mgr": // GREEK CAPITAL LETTER MU - return rune(0x039c), true + return {'\u039c', 0}, 1, true case "MinusPlus": // MINUS-OR-PLUS SIGN - return rune(0x2213), true + return {'\u2213', 0}, 1, true case "Mopf": // MATHEMATICAL DOUBLE-STRUCK CAPITAL M - return rune(0x01d544), true + return {'\U0001d544', 0}, 1, true case "Mscr": // SCRIPT CAPITAL M - return rune(0x2133), true + return {'\u2133', 0}, 1, true case "Mu": // GREEK CAPITAL LETTER MU - return rune(0x039c), true + return {'\u039c', 0}, 1, true } case 'N': switch name { case "NJcy": // CYRILLIC CAPITAL LETTER NJE - return rune(0x040a), true + return {'\u040a', 0}, 1, true case "Nacute": // LATIN CAPITAL LETTER N WITH ACUTE - return rune(0x0143), true + return {'\u0143', 0}, 1, true case "Ncaron": // LATIN CAPITAL LETTER N WITH CARON - return rune(0x0147), true + return {'\u0147', 0}, 1, true case "Ncedil": // LATIN CAPITAL LETTER N WITH CEDILLA - return rune(0x0145), true + return {'\u0145', 0}, 1, true case "Ncy": // CYRILLIC CAPITAL LETTER EN - return rune(0x041d), true + return {'\u041d', 0}, 1, true case "NegativeMediumSpace": // ZERO WIDTH SPACE - return rune(0x200b), true + return {'\u200b', 0}, 1, true case "NegativeThickSpace": // ZERO WIDTH SPACE - return rune(0x200b), true + return {'\u200b', 0}, 1, true case "NegativeThinSpace": // ZERO WIDTH SPACE - return rune(0x200b), true + return {'\u200b', 0}, 1, true case "NegativeVeryThinSpace": // ZERO WIDTH SPACE - return rune(0x200b), true + return {'\u200b', 0}, 1, true case "NestedGreaterGreater": // MUCH GREATER-THAN - return rune(0x226b), true + return {'\u226b', 0}, 1, true case "NestedLessLess": // MUCH LESS-THAN - return rune(0x226a), true + return {'\u226a', 0}, 1, true case "NewLine": // LINE FEED (LF) - return rune(0x0a), true + return {'\n', 0}, 1, true case "Nfr": // MATHEMATICAL FRAKTUR CAPITAL N - return rune(0x01d511), true + return {'\U0001d511', 0}, 1, true case "Ngr": // GREEK CAPITAL LETTER NU - return rune(0x039d), true + return {'\u039d', 0}, 1, true case "NoBreak": // WORD JOINER - return rune(0x2060), true + return {'\u2060', 0}, 1, true case "NonBreakingSpace": // NO-BREAK SPACE - return rune(0xa0), true + return {'\u00a0', 0}, 1, true case "Nopf": // DOUBLE-STRUCK CAPITAL N - return rune(0x2115), true + return {'\u2115', 0}, 1, true case "Not": // DOUBLE STROKE NOT SIGN - return rune(0x2aec), true + return {'\u2aec', 0}, 1, true case "NotCongruent": // NOT IDENTICAL TO - return rune(0x2262), true + return {'\u2262', 0}, 1, true case "NotCupCap": // NOT EQUIVALENT TO - return rune(0x226d), true + return {'\u226d', 0}, 1, true case "NotDoubleVerticalBar": // NOT PARALLEL TO - return rune(0x2226), true + return {'\u2226', 0}, 1, true case "NotElement": // NOT AN ELEMENT OF - return rune(0x2209), true + return {'\u2209', 0}, 1, true case "NotEqual": // NOT EQUAL TO - return rune(0x2260), true + return {'\u2260', 0}, 1, true case "NotEqualTilde": // MINUS TILDE with slash - return rune(0x2242), true + return {'\u2242', '\u0338'}, 2, true case "NotExists": // THERE DOES NOT EXIST - return rune(0x2204), true + return {'\u2204', 0}, 1, true case "NotGreater": // NOT GREATER-THAN - return rune(0x226f), true + return {'\u226f', 0}, 1, true case "NotGreaterEqual": // NEITHER GREATER-THAN NOR EQUAL TO - return rune(0x2271), true + return {'\u2271', 0}, 1, true case "NotGreaterFullEqual": // GREATER-THAN OVER EQUAL TO with slash - return rune(0x2267), true + return {'\u2267', '\u0338'}, 2, true case "NotGreaterGreater": // MUCH GREATER THAN with slash - return rune(0x226b), true + return {'\u226b', '\u0338'}, 2, true case "NotGreaterLess": // NEITHER GREATER-THAN NOR LESS-THAN - return rune(0x2279), true + return {'\u2279', 0}, 1, true case "NotGreaterSlantEqual": // GREATER-THAN OR SLANTED EQUAL TO with slash - return rune(0x2a7e), true + return {'\u2a7e', '\u0338'}, 2, true case "NotGreaterTilde": // NEITHER GREATER-THAN NOR EQUIVALENT TO - return rune(0x2275), true + return {'\u2275', 0}, 1, true case "NotHumpDownHump": // GEOMETRICALLY EQUIVALENT TO with slash - return rune(0x224e), true + return {'\u224e', '\u0338'}, 2, true case "NotHumpEqual": // DIFFERENCE BETWEEN with slash - return rune(0x224f), true + return {'\u224f', '\u0338'}, 2, true case "NotLeftTriangle": // NOT NORMAL SUBGROUP OF - return rune(0x22ea), true + return {'\u22ea', 0}, 1, true case "NotLeftTriangleBar": // LEFT TRIANGLE BESIDE VERTICAL BAR with slash - return rune(0x29cf), true + return {'\u29cf', '\u0338'}, 2, true case "NotLeftTriangleEqual": // NOT NORMAL SUBGROUP OF OR EQUAL TO - return rune(0x22ec), true + return {'\u22ec', 0}, 1, true case "NotLess": // NOT LESS-THAN - return rune(0x226e), true + return {'\u226e', 0}, 1, true case "NotLessEqual": // NEITHER LESS-THAN NOR EQUAL TO - return rune(0x2270), true + return {'\u2270', 0}, 1, true case "NotLessGreater": // NEITHER LESS-THAN NOR GREATER-THAN - return rune(0x2278), true + return {'\u2278', 0}, 1, true case "NotLessLess": // MUCH LESS THAN with slash - return rune(0x226a), true + return {'\u226a', '\u0338'}, 2, true case "NotLessSlantEqual": // LESS-THAN OR SLANTED EQUAL TO with slash - return rune(0x2a7d), true + return {'\u2a7d', '\u0338'}, 2, true case "NotLessTilde": // NEITHER LESS-THAN NOR EQUIVALENT TO - return rune(0x2274), true + return {'\u2274', 0}, 1, true case "NotNestedGreaterGreater": // DOUBLE NESTED GREATER-THAN with slash - return rune(0x2aa2), true + return {'\u2aa2', '\u0338'}, 2, true case "NotNestedLessLess": // DOUBLE NESTED LESS-THAN with slash - return rune(0x2aa1), true + return {'\u2aa1', '\u0338'}, 2, true case "NotPrecedes": // DOES NOT PRECEDE - return rune(0x2280), true + return {'\u2280', 0}, 1, true case "NotPrecedesEqual": // PRECEDES ABOVE SINGLE-LINE EQUALS SIGN with slash - return rune(0x2aaf), true + return {'\u2aaf', '\u0338'}, 2, true case "NotPrecedesSlantEqual": // DOES NOT PRECEDE OR EQUAL - return rune(0x22e0), true + return {'\u22e0', 0}, 1, true case "NotReverseElement": // DOES NOT CONTAIN AS MEMBER - return rune(0x220c), true + return {'\u220c', 0}, 1, true case "NotRightTriangle": // DOES NOT CONTAIN AS NORMAL SUBGROUP - return rune(0x22eb), true + return {'\u22eb', 0}, 1, true case "NotRightTriangleBar": // VERTICAL BAR BESIDE RIGHT TRIANGLE with slash - return rune(0x29d0), true + return {'\u29d0', '\u0338'}, 2, true case "NotRightTriangleEqual": // DOES NOT CONTAIN AS NORMAL SUBGROUP OR EQUAL - return rune(0x22ed), true + return {'\u22ed', 0}, 1, true case "NotSquareSubset": // SQUARE IMAGE OF with slash - return rune(0x228f), true + return {'\u228f', '\u0338'}, 2, true case "NotSquareSubsetEqual": // NOT SQUARE IMAGE OF OR EQUAL TO - return rune(0x22e2), true + return {'\u22e2', 0}, 1, true case "NotSquareSuperset": // SQUARE ORIGINAL OF with slash - return rune(0x2290), true + return {'\u2290', '\u0338'}, 2, true case "NotSquareSupersetEqual": // NOT SQUARE ORIGINAL OF OR EQUAL TO - return rune(0x22e3), true + return {'\u22e3', 0}, 1, true case "NotSubset": // SUBSET OF with vertical line - return rune(0x2282), true + return {'\u2282', '\u20d2'}, 2, true case "NotSubsetEqual": // NEITHER A SUBSET OF NOR EQUAL TO - return rune(0x2288), true + return {'\u2288', 0}, 1, true case "NotSucceeds": // DOES NOT SUCCEED - return rune(0x2281), true + return {'\u2281', 0}, 1, true case "NotSucceedsEqual": // SUCCEEDS ABOVE SINGLE-LINE EQUALS SIGN with slash - return rune(0x2ab0), true + return {'\u2ab0', '\u0338'}, 2, true case "NotSucceedsSlantEqual": // DOES NOT SUCCEED OR EQUAL - return rune(0x22e1), true + return {'\u22e1', 0}, 1, true case "NotSucceedsTilde": // SUCCEEDS OR EQUIVALENT TO with slash - return rune(0x227f), true + return {'\u227f', '\u0338'}, 2, true case "NotSuperset": // SUPERSET OF with vertical line - return rune(0x2283), true + return {'\u2283', '\u20d2'}, 2, true case "NotSupersetEqual": // NEITHER A SUPERSET OF NOR EQUAL TO - return rune(0x2289), true + return {'\u2289', 0}, 1, true case "NotTilde": // NOT TILDE - return rune(0x2241), true + return {'\u2241', 0}, 1, true case "NotTildeEqual": // NOT ASYMPTOTICALLY EQUAL TO - return rune(0x2244), true + return {'\u2244', 0}, 1, true case "NotTildeFullEqual": // NEITHER APPROXIMATELY NOR ACTUALLY EQUAL TO - return rune(0x2247), true + return {'\u2247', 0}, 1, true case "NotTildeTilde": // NOT ALMOST EQUAL TO - return rune(0x2249), true + return {'\u2249', 0}, 1, true case "NotVerticalBar": // DOES NOT DIVIDE - return rune(0x2224), true + return {'\u2224', 0}, 1, true case "Nscr": // MATHEMATICAL SCRIPT CAPITAL N - return rune(0x01d4a9), true + return {'\U0001d4a9', 0}, 1, true case "Ntilde": // LATIN CAPITAL LETTER N WITH TILDE - return rune(0xd1), true + return {'Ñ', 0}, 1, true case "Nu": // GREEK CAPITAL LETTER NU - return rune(0x039d), true + return {'\u039d', 0}, 1, true } case 'O': switch name { case "OElig": // LATIN CAPITAL LIGATURE OE - return rune(0x0152), true + return {'\u0152', 0}, 1, true case "OHacgr": // GREEK CAPITAL LETTER OMEGA WITH TONOS - return rune(0x038f), true + return {'\u038f', 0}, 1, true case "OHgr": // GREEK CAPITAL LETTER OMEGA - return rune(0x03a9), true + return {'\u03a9', 0}, 1, true case "Oacgr": // GREEK CAPITAL LETTER OMICRON WITH TONOS - return rune(0x038c), true + return {'\u038c', 0}, 1, true case "Oacute": // LATIN CAPITAL LETTER O WITH ACUTE - return rune(0xd3), true + return {'Ó', 0}, 1, true case "Ocirc": // LATIN CAPITAL LETTER O WITH CIRCUMFLEX - return rune(0xd4), true + return {'Ô', 0}, 1, true case "Ocy": // CYRILLIC CAPITAL LETTER O - return rune(0x041e), true + return {'\u041e', 0}, 1, true case "Odblac": // LATIN CAPITAL LETTER O WITH DOUBLE ACUTE - return rune(0x0150), true + return {'\u0150', 0}, 1, true case "Ofr": // MATHEMATICAL FRAKTUR CAPITAL O - return rune(0x01d512), true + return {'\U0001d512', 0}, 1, true case "Ogr": // GREEK CAPITAL LETTER OMICRON - return rune(0x039f), true + return {'\u039f', 0}, 1, true case "Ograve": // LATIN CAPITAL LETTER O WITH GRAVE - return rune(0xd2), true + return {'Ò', 0}, 1, true case "Omacr": // LATIN CAPITAL LETTER O WITH MACRON - return rune(0x014c), true + return {'\u014c', 0}, 1, true case "Omega": // GREEK CAPITAL LETTER OMEGA - return rune(0x03a9), true + return {'\u03a9', 0}, 1, true case "Omicron": // GREEK CAPITAL LETTER OMICRON - return rune(0x039f), true + return {'\u039f', 0}, 1, true case "Oopf": // MATHEMATICAL DOUBLE-STRUCK CAPITAL O - return rune(0x01d546), true + return {'\U0001d546', 0}, 1, true case "OpenCurlyDoubleQuote": // LEFT DOUBLE QUOTATION MARK - return rune(0x201c), true + return {'\u201c', 0}, 1, true case "OpenCurlyQuote": // LEFT SINGLE QUOTATION MARK - return rune(0x2018), true + return {'\u2018', 0}, 1, true case "Or": // DOUBLE LOGICAL OR - return rune(0x2a54), true + return {'\u2a54', 0}, 1, true case "Oscr": // MATHEMATICAL SCRIPT CAPITAL O - return rune(0x01d4aa), true + return {'\U0001d4aa', 0}, 1, true case "Oslash": // LATIN CAPITAL LETTER O WITH STROKE - return rune(0xd8), true + return {'Ø', 0}, 1, true case "Otilde": // LATIN CAPITAL LETTER O WITH TILDE - return rune(0xd5), true + return {'Õ', 0}, 1, true case "Otimes": // MULTIPLICATION SIGN IN DOUBLE CIRCLE - return rune(0x2a37), true + return {'\u2a37', 0}, 1, true case "Ouml": // LATIN CAPITAL LETTER O WITH DIAERESIS - return rune(0xd6), true + return {'Ö', 0}, 1, true case "OverBar": // OVERLINE - return rune(0x203e), true + return {'\u203e', 0}, 1, true case "OverBrace": // TOP CURLY BRACKET - return rune(0x23de), true + return {'\u23de', 0}, 1, true case "OverBracket": // TOP SQUARE BRACKET - return rune(0x23b4), true + return {'\u23b4', 0}, 1, true case "OverParenthesis": // TOP PARENTHESIS - return rune(0x23dc), true + return {'\u23dc', 0}, 1, true } case 'P': switch name { case "PHgr": // GREEK CAPITAL LETTER PHI - return rune(0x03a6), true + return {'\u03a6', 0}, 1, true case "PSgr": // GREEK CAPITAL LETTER PSI - return rune(0x03a8), true + return {'\u03a8', 0}, 1, true case "PartialD": // PARTIAL DIFFERENTIAL - return rune(0x2202), true + return {'\u2202', 0}, 1, true case "Pcy": // CYRILLIC CAPITAL LETTER PE - return rune(0x041f), true + return {'\u041f', 0}, 1, true case "Pfr": // MATHEMATICAL FRAKTUR CAPITAL P - return rune(0x01d513), true + return {'\U0001d513', 0}, 1, true case "Pgr": // GREEK CAPITAL LETTER PI - return rune(0x03a0), true + return {'\u03a0', 0}, 1, true case "Phi": // GREEK CAPITAL LETTER PHI - return rune(0x03a6), true + return {'\u03a6', 0}, 1, true case "Pi": // GREEK CAPITAL LETTER PI - return rune(0x03a0), true + return {'\u03a0', 0}, 1, true case "PlusMinus": // PLUS-MINUS SIGN - return rune(0xb1), true + return {'±', 0}, 1, true case "Poincareplane": // BLACK-LETTER CAPITAL H - return rune(0x210c), true + return {'\u210c', 0}, 1, true case "Popf": // DOUBLE-STRUCK CAPITAL P - return rune(0x2119), true + return {'\u2119', 0}, 1, true case "Pr": // DOUBLE PRECEDES - return rune(0x2abb), true + return {'\u2abb', 0}, 1, true case "Precedes": // PRECEDES - return rune(0x227a), true + return {'\u227a', 0}, 1, true case "PrecedesEqual": // PRECEDES ABOVE SINGLE-LINE EQUALS SIGN - return rune(0x2aaf), true + return {'\u2aaf', 0}, 1, true case "PrecedesSlantEqual": // PRECEDES OR EQUAL TO - return rune(0x227c), true + return {'\u227c', 0}, 1, true case "PrecedesTilde": // PRECEDES OR EQUIVALENT TO - return rune(0x227e), true + return {'\u227e', 0}, 1, true case "Prime": // DOUBLE PRIME - return rune(0x2033), true + return {'\u2033', 0}, 1, true case "Product": // N-ARY PRODUCT - return rune(0x220f), true + return {'\u220f', 0}, 1, true case "Proportion": // PROPORTION - return rune(0x2237), true + return {'\u2237', 0}, 1, true case "Proportional": // PROPORTIONAL TO - return rune(0x221d), true + return {'\u221d', 0}, 1, true case "Pscr": // MATHEMATICAL SCRIPT CAPITAL P - return rune(0x01d4ab), true + return {'\U0001d4ab', 0}, 1, true case "Psi": // GREEK CAPITAL LETTER PSI - return rune(0x03a8), true + return {'\u03a8', 0}, 1, true } case 'Q': switch name { case "QUOT": // QUOTATION MARK - return rune(0x22), true + return {'"', 0}, 1, true case "Qfr": // MATHEMATICAL FRAKTUR CAPITAL Q - return rune(0x01d514), true + return {'\U0001d514', 0}, 1, true case "Qopf": // DOUBLE-STRUCK CAPITAL Q - return rune(0x211a), true + return {'\u211a', 0}, 1, true case "Qscr": // MATHEMATICAL SCRIPT CAPITAL Q - return rune(0x01d4ac), true + return {'\U0001d4ac', 0}, 1, true } case 'R': switch name { case "RBarr": // RIGHTWARDS TWO-HEADED TRIPLE DASH ARROW - return rune(0x2910), true + return {'\u2910', 0}, 1, true case "REG": // REGISTERED SIGN - return rune(0xae), true + return {'®', 0}, 1, true case "Racute": // LATIN CAPITAL LETTER R WITH ACUTE - return rune(0x0154), true + return {'\u0154', 0}, 1, true case "Rang": // MATHEMATICAL RIGHT DOUBLE ANGLE BRACKET - return rune(0x27eb), true + return {'\u27eb', 0}, 1, true case "Rarr": // RIGHTWARDS TWO HEADED ARROW - return rune(0x21a0), true + return {'\u21a0', 0}, 1, true case "Rarrtl": // RIGHTWARDS TWO-HEADED ARROW WITH TAIL - return rune(0x2916), true + return {'\u2916', 0}, 1, true case "Rcaron": // LATIN CAPITAL LETTER R WITH CARON - return rune(0x0158), true + return {'\u0158', 0}, 1, true case "Rcedil": // LATIN CAPITAL LETTER R WITH CEDILLA - return rune(0x0156), true + return {'\u0156', 0}, 1, true case "Rcy": // CYRILLIC CAPITAL LETTER ER - return rune(0x0420), true + return {'\u0420', 0}, 1, true case "Re": // BLACK-LETTER CAPITAL R - return rune(0x211c), true + return {'\u211c', 0}, 1, true case "ReverseElement": // CONTAINS AS MEMBER - return rune(0x220b), true + return {'\u220b', 0}, 1, true case "ReverseEquilibrium": // LEFTWARDS HARPOON OVER RIGHTWARDS HARPOON - return rune(0x21cb), true + return {'\u21cb', 0}, 1, true case "ReverseUpEquilibrium": // DOWNWARDS HARPOON WITH BARB LEFT BESIDE UPWARDS HARPOON WITH BARB RIGHT - return rune(0x296f), true + return {'\u296f', 0}, 1, true case "Rfr": // BLACK-LETTER CAPITAL R - return rune(0x211c), true + return {'\u211c', 0}, 1, true case "Rgr": // GREEK CAPITAL LETTER RHO - return rune(0x03a1), true + return {'\u03a1', 0}, 1, true case "Rho": // GREEK CAPITAL LETTER RHO - return rune(0x03a1), true + return {'\u03a1', 0}, 1, true case "RightAngleBracket": // MATHEMATICAL RIGHT ANGLE BRACKET - return rune(0x27e9), true + return {'\u27e9', 0}, 1, true case "RightArrow": // RIGHTWARDS ARROW - return rune(0x2192), true + return {'\u2192', 0}, 1, true case "RightArrowBar": // RIGHTWARDS ARROW TO BAR - return rune(0x21e5), true + return {'\u21e5', 0}, 1, true case "RightArrowLeftArrow": // RIGHTWARDS ARROW OVER LEFTWARDS ARROW - return rune(0x21c4), true + return {'\u21c4', 0}, 1, true case "RightCeiling": // RIGHT CEILING - return rune(0x2309), true + return {'\u2309', 0}, 1, true case "RightDoubleBracket": // MATHEMATICAL RIGHT WHITE SQUARE BRACKET - return rune(0x27e7), true + return {'\u27e7', 0}, 1, true case "RightDownTeeVector": // DOWNWARDS HARPOON WITH BARB RIGHT FROM BAR - return rune(0x295d), true + return {'\u295d', 0}, 1, true case "RightDownVector": // DOWNWARDS HARPOON WITH BARB RIGHTWARDS - return rune(0x21c2), true + return {'\u21c2', 0}, 1, true case "RightDownVectorBar": // DOWNWARDS HARPOON WITH BARB RIGHT TO BAR - return rune(0x2955), true + return {'\u2955', 0}, 1, true case "RightFloor": // RIGHT FLOOR - return rune(0x230b), true + return {'\u230b', 0}, 1, true case "RightTee": // RIGHT TACK - return rune(0x22a2), true + return {'\u22a2', 0}, 1, true case "RightTeeArrow": // RIGHTWARDS ARROW FROM BAR - return rune(0x21a6), true + return {'\u21a6', 0}, 1, true case "RightTeeVector": // RIGHTWARDS HARPOON WITH BARB UP FROM BAR - return rune(0x295b), true + return {'\u295b', 0}, 1, true case "RightTriangle": // CONTAINS AS NORMAL SUBGROUP - return rune(0x22b3), true + return {'\u22b3', 0}, 1, true case "RightTriangleBar": // VERTICAL BAR BESIDE RIGHT TRIANGLE - return rune(0x29d0), true + return {'\u29d0', 0}, 1, true case "RightTriangleEqual": // CONTAINS AS NORMAL SUBGROUP OR EQUAL TO - return rune(0x22b5), true + return {'\u22b5', 0}, 1, true case "RightUpDownVector": // UP BARB RIGHT DOWN BARB RIGHT HARPOON - return rune(0x294f), true + return {'\u294f', 0}, 1, true case "RightUpTeeVector": // UPWARDS HARPOON WITH BARB RIGHT FROM BAR - return rune(0x295c), true + return {'\u295c', 0}, 1, true case "RightUpVector": // UPWARDS HARPOON WITH BARB RIGHTWARDS - return rune(0x21be), true + return {'\u21be', 0}, 1, true case "RightUpVectorBar": // UPWARDS HARPOON WITH BARB RIGHT TO BAR - return rune(0x2954), true + return {'\u2954', 0}, 1, true case "RightVector": // RIGHTWARDS HARPOON WITH BARB UPWARDS - return rune(0x21c0), true + return {'\u21c0', 0}, 1, true case "RightVectorBar": // RIGHTWARDS HARPOON WITH BARB UP TO BAR - return rune(0x2953), true + return {'\u2953', 0}, 1, true case "Rightarrow": // RIGHTWARDS DOUBLE ARROW - return rune(0x21d2), true + return {'\u21d2', 0}, 1, true case "Ropf": // DOUBLE-STRUCK CAPITAL R - return rune(0x211d), true + return {'\u211d', 0}, 1, true case "RoundImplies": // RIGHT DOUBLE ARROW WITH ROUNDED HEAD - return rune(0x2970), true + return {'\u2970', 0}, 1, true case "Rrightarrow": // RIGHTWARDS TRIPLE ARROW - return rune(0x21db), true + return {'\u21db', 0}, 1, true case "Rscr": // SCRIPT CAPITAL R - return rune(0x211b), true + return {'\u211b', 0}, 1, true case "Rsh": // UPWARDS ARROW WITH TIP RIGHTWARDS - return rune(0x21b1), true + return {'\u21b1', 0}, 1, true case "RuleDelayed": // RULE-DELAYED - return rune(0x29f4), true + return {'\u29f4', 0}, 1, true } case 'S': switch name { case "SHCHcy": // CYRILLIC CAPITAL LETTER SHCHA - return rune(0x0429), true + return {'\u0429', 0}, 1, true case "SHcy": // CYRILLIC CAPITAL LETTER SHA - return rune(0x0428), true + return {'\u0428', 0}, 1, true case "SOFTcy": // CYRILLIC CAPITAL LETTER SOFT SIGN - return rune(0x042c), true + return {'\u042c', 0}, 1, true case "Sacute": // LATIN CAPITAL LETTER S WITH ACUTE - return rune(0x015a), true + return {'\u015a', 0}, 1, true case "Sc": // DOUBLE SUCCEEDS - return rune(0x2abc), true + return {'\u2abc', 0}, 1, true case "Scaron": // LATIN CAPITAL LETTER S WITH CARON - return rune(0x0160), true + return {'\u0160', 0}, 1, true case "Scedil": // LATIN CAPITAL LETTER S WITH CEDILLA - return rune(0x015e), true + return {'\u015e', 0}, 1, true case "Scirc": // LATIN CAPITAL LETTER S WITH CIRCUMFLEX - return rune(0x015c), true + return {'\u015c', 0}, 1, true case "Scy": // CYRILLIC CAPITAL LETTER ES - return rune(0x0421), true + return {'\u0421', 0}, 1, true case "Sfr": // MATHEMATICAL FRAKTUR CAPITAL S - return rune(0x01d516), true + return {'\U0001d516', 0}, 1, true case "Sgr": // GREEK CAPITAL LETTER SIGMA - return rune(0x03a3), true + return {'\u03a3', 0}, 1, true case "ShortDownArrow": // DOWNWARDS ARROW - return rune(0x2193), true + return {'\u2193', 0}, 1, true case "ShortLeftArrow": // LEFTWARDS ARROW - return rune(0x2190), true + return {'\u2190', 0}, 1, true case "ShortRightArrow": // RIGHTWARDS ARROW - return rune(0x2192), true + return {'\u2192', 0}, 1, true case "ShortUpArrow": // UPWARDS ARROW - return rune(0x2191), true + return {'\u2191', 0}, 1, true case "Sigma": // GREEK CAPITAL LETTER SIGMA - return rune(0x03a3), true + return {'\u03a3', 0}, 1, true case "SmallCircle": // RING OPERATOR - return rune(0x2218), true + return {'\u2218', 0}, 1, true case "Sopf": // MATHEMATICAL DOUBLE-STRUCK CAPITAL S - return rune(0x01d54a), true + return {'\U0001d54a', 0}, 1, true case "Sqrt": // SQUARE ROOT - return rune(0x221a), true + return {'\u221a', 0}, 1, true case "Square": // WHITE SQUARE - return rune(0x25a1), true + return {'\u25a1', 0}, 1, true case "SquareIntersection": // SQUARE CAP - return rune(0x2293), true + return {'\u2293', 0}, 1, true case "SquareSubset": // SQUARE IMAGE OF - return rune(0x228f), true + return {'\u228f', 0}, 1, true case "SquareSubsetEqual": // SQUARE IMAGE OF OR EQUAL TO - return rune(0x2291), true + return {'\u2291', 0}, 1, true case "SquareSuperset": // SQUARE ORIGINAL OF - return rune(0x2290), true + return {'\u2290', 0}, 1, true case "SquareSupersetEqual": // SQUARE ORIGINAL OF OR EQUAL TO - return rune(0x2292), true + return {'\u2292', 0}, 1, true case "SquareUnion": // SQUARE CUP - return rune(0x2294), true + return {'\u2294', 0}, 1, true case "Sscr": // MATHEMATICAL SCRIPT CAPITAL S - return rune(0x01d4ae), true + return {'\U0001d4ae', 0}, 1, true case "Star": // STAR OPERATOR - return rune(0x22c6), true + return {'\u22c6', 0}, 1, true case "Sub": // DOUBLE SUBSET - return rune(0x22d0), true + return {'\u22d0', 0}, 1, true case "Subset": // DOUBLE SUBSET - return rune(0x22d0), true + return {'\u22d0', 0}, 1, true case "SubsetEqual": // SUBSET OF OR EQUAL TO - return rune(0x2286), true + return {'\u2286', 0}, 1, true case "Succeeds": // SUCCEEDS - return rune(0x227b), true + return {'\u227b', 0}, 1, true case "SucceedsEqual": // SUCCEEDS ABOVE SINGLE-LINE EQUALS SIGN - return rune(0x2ab0), true + return {'\u2ab0', 0}, 1, true case "SucceedsSlantEqual": // SUCCEEDS OR EQUAL TO - return rune(0x227d), true + return {'\u227d', 0}, 1, true case "SucceedsTilde": // SUCCEEDS OR EQUIVALENT TO - return rune(0x227f), true + return {'\u227f', 0}, 1, true case "SuchThat": // CONTAINS AS MEMBER - return rune(0x220b), true + return {'\u220b', 0}, 1, true case "Sum": // N-ARY SUMMATION - return rune(0x2211), true + return {'\u2211', 0}, 1, true case "Sup": // DOUBLE SUPERSET - return rune(0x22d1), true + return {'\u22d1', 0}, 1, true case "Superset": // SUPERSET OF - return rune(0x2283), true + return {'\u2283', 0}, 1, true case "SupersetEqual": // SUPERSET OF OR EQUAL TO - return rune(0x2287), true + return {'\u2287', 0}, 1, true case "Supset": // DOUBLE SUPERSET - return rune(0x22d1), true + return {'\u22d1', 0}, 1, true } case 'T': switch name { case "THORN": // LATIN CAPITAL LETTER THORN - return rune(0xde), true + return {'Þ', 0}, 1, true case "THgr": // GREEK CAPITAL LETTER THETA - return rune(0x0398), true + return {'\u0398', 0}, 1, true case "TRADE": // TRADE MARK SIGN - return rune(0x2122), true + return {'\u2122', 0}, 1, true case "TSHcy": // CYRILLIC CAPITAL LETTER TSHE - return rune(0x040b), true + return {'\u040b', 0}, 1, true case "TScy": // CYRILLIC CAPITAL LETTER TSE - return rune(0x0426), true + return {'\u0426', 0}, 1, true case "Tab": // CHARACTER TABULATION - return rune(0x09), true + return {'\t', 0}, 1, true case "Tau": // GREEK CAPITAL LETTER TAU - return rune(0x03a4), true + return {'\u03a4', 0}, 1, true case "Tcaron": // LATIN CAPITAL LETTER T WITH CARON - return rune(0x0164), true + return {'\u0164', 0}, 1, true case "Tcedil": // LATIN CAPITAL LETTER T WITH CEDILLA - return rune(0x0162), true + return {'\u0162', 0}, 1, true case "Tcy": // CYRILLIC CAPITAL LETTER TE - return rune(0x0422), true + return {'\u0422', 0}, 1, true case "Tfr": // MATHEMATICAL FRAKTUR CAPITAL T - return rune(0x01d517), true + return {'\U0001d517', 0}, 1, true case "Tgr": // GREEK CAPITAL LETTER TAU - return rune(0x03a4), true + return {'\u03a4', 0}, 1, true case "Therefore": // THEREFORE - return rune(0x2234), true + return {'\u2234', 0}, 1, true case "Theta": // GREEK CAPITAL LETTER THETA - return rune(0x0398), true + return {'\u0398', 0}, 1, true case "Thetav": // GREEK CAPITAL THETA SYMBOL - return rune(0x03f4), true + return {'\u03f4', 0}, 1, true case "ThickSpace": // space of width 5/18 em - return rune(0x205f), true + return {'\u205f', '\u200a'}, 2, true case "ThinSpace": // THIN SPACE - return rune(0x2009), true + return {'\u2009', 0}, 1, true case "Tilde": // TILDE OPERATOR - return rune(0x223c), true + return {'\u223c', 0}, 1, true case "TildeEqual": // ASYMPTOTICALLY EQUAL TO - return rune(0x2243), true + return {'\u2243', 0}, 1, true case "TildeFullEqual": // APPROXIMATELY EQUAL TO - return rune(0x2245), true + return {'\u2245', 0}, 1, true case "TildeTilde": // ALMOST EQUAL TO - return rune(0x2248), true + return {'\u2248', 0}, 1, true case "Topf": // MATHEMATICAL DOUBLE-STRUCK CAPITAL T - return rune(0x01d54b), true + return {'\U0001d54b', 0}, 1, true case "TripleDot": // COMBINING THREE DOTS ABOVE - return rune(0x20db), true + return {'\u20db', 0}, 1, true case "Tscr": // MATHEMATICAL SCRIPT CAPITAL T - return rune(0x01d4af), true + return {'\U0001d4af', 0}, 1, true case "Tstrok": // LATIN CAPITAL LETTER T WITH STROKE - return rune(0x0166), true + return {'\u0166', 0}, 1, true } case 'U': switch name { case "Uacgr": // GREEK CAPITAL LETTER UPSILON WITH TONOS - return rune(0x038e), true + return {'\u038e', 0}, 1, true case "Uacute": // LATIN CAPITAL LETTER U WITH ACUTE - return rune(0xda), true + return {'Ú', 0}, 1, true case "Uarr": // UPWARDS TWO HEADED ARROW - return rune(0x219f), true + return {'\u219f', 0}, 1, true case "Uarrocir": // UPWARDS TWO-HEADED ARROW FROM SMALL CIRCLE - return rune(0x2949), true + return {'\u2949', 0}, 1, true case "Ubrcy": // CYRILLIC CAPITAL LETTER SHORT U - return rune(0x040e), true + return {'\u040e', 0}, 1, true case "Ubreve": // LATIN CAPITAL LETTER U WITH BREVE - return rune(0x016c), true + return {'\u016c', 0}, 1, true case "Ucirc": // LATIN CAPITAL LETTER U WITH CIRCUMFLEX - return rune(0xdb), true + return {'Û', 0}, 1, true case "Ucy": // CYRILLIC CAPITAL LETTER U - return rune(0x0423), true + return {'\u0423', 0}, 1, true case "Udblac": // LATIN CAPITAL LETTER U WITH DOUBLE ACUTE - return rune(0x0170), true + return {'\u0170', 0}, 1, true case "Udigr": // GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA - return rune(0x03ab), true + return {'\u03ab', 0}, 1, true case "Ufr": // MATHEMATICAL FRAKTUR CAPITAL U - return rune(0x01d518), true + return {'\U0001d518', 0}, 1, true case "Ugr": // GREEK CAPITAL LETTER UPSILON - return rune(0x03a5), true + return {'\u03a5', 0}, 1, true case "Ugrave": // LATIN CAPITAL LETTER U WITH GRAVE - return rune(0xd9), true + return {'Ù', 0}, 1, true case "Umacr": // LATIN CAPITAL LETTER U WITH MACRON - return rune(0x016a), true + return {'\u016a', 0}, 1, true case "UnderBar": // LOW LINE - return rune(0x5f), true + return {'_', 0}, 1, true case "UnderBrace": // BOTTOM CURLY BRACKET - return rune(0x23df), true + return {'\u23df', 0}, 1, true case "UnderBracket": // BOTTOM SQUARE BRACKET - return rune(0x23b5), true + return {'\u23b5', 0}, 1, true case "UnderParenthesis": // BOTTOM PARENTHESIS - return rune(0x23dd), true + return {'\u23dd', 0}, 1, true case "Union": // N-ARY UNION - return rune(0x22c3), true + return {'\u22c3', 0}, 1, true case "UnionPlus": // MULTISET UNION - return rune(0x228e), true + return {'\u228e', 0}, 1, true case "Uogon": // LATIN CAPITAL LETTER U WITH OGONEK - return rune(0x0172), true + return {'\u0172', 0}, 1, true case "Uopf": // MATHEMATICAL DOUBLE-STRUCK CAPITAL U - return rune(0x01d54c), true + return {'\U0001d54c', 0}, 1, true case "UpArrow": // UPWARDS ARROW - return rune(0x2191), true + return {'\u2191', 0}, 1, true case "UpArrowBar": // UPWARDS ARROW TO BAR - return rune(0x2912), true + return {'\u2912', 0}, 1, true case "UpArrowDownArrow": // UPWARDS ARROW LEFTWARDS OF DOWNWARDS ARROW - return rune(0x21c5), true + return {'\u21c5', 0}, 1, true case "UpDownArrow": // UP DOWN ARROW - return rune(0x2195), true + return {'\u2195', 0}, 1, true case "UpEquilibrium": // UPWARDS HARPOON WITH BARB LEFT BESIDE DOWNWARDS HARPOON WITH BARB RIGHT - return rune(0x296e), true + return {'\u296e', 0}, 1, true case "UpTee": // UP TACK - return rune(0x22a5), true + return {'\u22a5', 0}, 1, true case "UpTeeArrow": // UPWARDS ARROW FROM BAR - return rune(0x21a5), true + return {'\u21a5', 0}, 1, true case "Uparrow": // UPWARDS DOUBLE ARROW - return rune(0x21d1), true + return {'\u21d1', 0}, 1, true case "Updownarrow": // UP DOWN DOUBLE ARROW - return rune(0x21d5), true + return {'\u21d5', 0}, 1, true case "UpperLeftArrow": // NORTH WEST ARROW - return rune(0x2196), true + return {'\u2196', 0}, 1, true case "UpperRightArrow": // NORTH EAST ARROW - return rune(0x2197), true + return {'\u2197', 0}, 1, true case "Upsi": // GREEK UPSILON WITH HOOK SYMBOL - return rune(0x03d2), true + return {'\u03d2', 0}, 1, true case "Upsilon": // GREEK CAPITAL LETTER UPSILON - return rune(0x03a5), true + return {'\u03a5', 0}, 1, true case "Uring": // LATIN CAPITAL LETTER U WITH RING ABOVE - return rune(0x016e), true + return {'\u016e', 0}, 1, true case "Uscr": // MATHEMATICAL SCRIPT CAPITAL U - return rune(0x01d4b0), true + return {'\U0001d4b0', 0}, 1, true case "Utilde": // LATIN CAPITAL LETTER U WITH TILDE - return rune(0x0168), true + return {'\u0168', 0}, 1, true case "Uuml": // LATIN CAPITAL LETTER U WITH DIAERESIS - return rune(0xdc), true + return {'Ü', 0}, 1, true } case 'V': switch name { case "VDash": // DOUBLE VERTICAL BAR DOUBLE RIGHT TURNSTILE - return rune(0x22ab), true + return {'\u22ab', 0}, 1, true case "Vbar": // DOUBLE UP TACK - return rune(0x2aeb), true + return {'\u2aeb', 0}, 1, true case "Vcy": // CYRILLIC CAPITAL LETTER VE - return rune(0x0412), true + return {'\u0412', 0}, 1, true case "Vdash": // FORCES - return rune(0x22a9), true + return {'\u22a9', 0}, 1, true case "Vdashl": // LONG DASH FROM LEFT MEMBER OF DOUBLE VERTICAL - return rune(0x2ae6), true + return {'\u2ae6', 0}, 1, true case "Vee": // N-ARY LOGICAL OR - return rune(0x22c1), true + return {'\u22c1', 0}, 1, true case "Verbar": // DOUBLE VERTICAL LINE - return rune(0x2016), true + return {'\u2016', 0}, 1, true case "Vert": // DOUBLE VERTICAL LINE - return rune(0x2016), true + return {'\u2016', 0}, 1, true case "VerticalBar": // DIVIDES - return rune(0x2223), true + return {'\u2223', 0}, 1, true case "VerticalLine": // VERTICAL LINE - return rune(0x7c), true + return {'|', 0}, 1, true case "VerticalSeparator": // LIGHT VERTICAL BAR - return rune(0x2758), true + return {'\u2758', 0}, 1, true case "VerticalTilde": // WREATH PRODUCT - return rune(0x2240), true + return {'\u2240', 0}, 1, true case "VeryThinSpace": // HAIR SPACE - return rune(0x200a), true + return {'\u200a', 0}, 1, true case "Vfr": // MATHEMATICAL FRAKTUR CAPITAL V - return rune(0x01d519), true + return {'\U0001d519', 0}, 1, true case "Vopf": // MATHEMATICAL DOUBLE-STRUCK CAPITAL V - return rune(0x01d54d), true + return {'\U0001d54d', 0}, 1, true case "Vscr": // MATHEMATICAL SCRIPT CAPITAL V - return rune(0x01d4b1), true + return {'\U0001d4b1', 0}, 1, true case "Vvdash": // TRIPLE VERTICAL BAR RIGHT TURNSTILE - return rune(0x22aa), true + return {'\u22aa', 0}, 1, true } case 'W': switch name { case "Wcirc": // LATIN CAPITAL LETTER W WITH CIRCUMFLEX - return rune(0x0174), true + return {'\u0174', 0}, 1, true case "Wedge": // N-ARY LOGICAL AND - return rune(0x22c0), true + return {'\u22c0', 0}, 1, true case "Wfr": // MATHEMATICAL FRAKTUR CAPITAL W - return rune(0x01d51a), true + return {'\U0001d51a', 0}, 1, true case "Wopf": // MATHEMATICAL DOUBLE-STRUCK CAPITAL W - return rune(0x01d54e), true + return {'\U0001d54e', 0}, 1, true case "Wscr": // MATHEMATICAL SCRIPT CAPITAL W - return rune(0x01d4b2), true + return {'\U0001d4b2', 0}, 1, true } case 'X': switch name { case "Xfr": // MATHEMATICAL FRAKTUR CAPITAL X - return rune(0x01d51b), true + return {'\U0001d51b', 0}, 1, true case "Xgr": // GREEK CAPITAL LETTER XI - return rune(0x039e), true + return {'\u039e', 0}, 1, true case "Xi": // GREEK CAPITAL LETTER XI - return rune(0x039e), true + return {'\u039e', 0}, 1, true case "Xopf": // MATHEMATICAL DOUBLE-STRUCK CAPITAL X - return rune(0x01d54f), true + return {'\U0001d54f', 0}, 1, true case "Xscr": // MATHEMATICAL SCRIPT CAPITAL X - return rune(0x01d4b3), true + return {'\U0001d4b3', 0}, 1, true } case 'Y': switch name { case "YAcy": // CYRILLIC CAPITAL LETTER YA - return rune(0x042f), true + return {'\u042f', 0}, 1, true case "YIcy": // CYRILLIC CAPITAL LETTER YI - return rune(0x0407), true + return {'\u0407', 0}, 1, true case "YUcy": // CYRILLIC CAPITAL LETTER YU - return rune(0x042e), true + return {'\u042e', 0}, 1, true case "Yacute": // LATIN CAPITAL LETTER Y WITH ACUTE - return rune(0xdd), true + return {'Ý', 0}, 1, true case "Ycirc": // LATIN CAPITAL LETTER Y WITH CIRCUMFLEX - return rune(0x0176), true + return {'\u0176', 0}, 1, true case "Ycy": // CYRILLIC CAPITAL LETTER YERU - return rune(0x042b), true + return {'\u042b', 0}, 1, true case "Yfr": // MATHEMATICAL FRAKTUR CAPITAL Y - return rune(0x01d51c), true + return {'\U0001d51c', 0}, 1, true case "Yopf": // MATHEMATICAL DOUBLE-STRUCK CAPITAL Y - return rune(0x01d550), true + return {'\U0001d550', 0}, 1, true case "Yscr": // MATHEMATICAL SCRIPT CAPITAL Y - return rune(0x01d4b4), true + return {'\U0001d4b4', 0}, 1, true case "Yuml": // LATIN CAPITAL LETTER Y WITH DIAERESIS - return rune(0x0178), true + return {'\u0178', 0}, 1, true } case 'Z': switch name { case "ZHcy": // CYRILLIC CAPITAL LETTER ZHE - return rune(0x0416), true + return {'\u0416', 0}, 1, true case "Zacute": // LATIN CAPITAL LETTER Z WITH ACUTE - return rune(0x0179), true + return {'\u0179', 0}, 1, true case "Zcaron": // LATIN CAPITAL LETTER Z WITH CARON - return rune(0x017d), true + return {'\u017d', 0}, 1, true case "Zcy": // CYRILLIC CAPITAL LETTER ZE - return rune(0x0417), true + return {'\u0417', 0}, 1, true case "Zdot": // LATIN CAPITAL LETTER Z WITH DOT ABOVE - return rune(0x017b), true + return {'\u017b', 0}, 1, true case "ZeroWidthSpace": // ZERO WIDTH SPACE - return rune(0x200b), true + return {'\u200b', 0}, 1, true case "Zeta": // GREEK CAPITAL LETTER ZETA - return rune(0x0396), true + return {'\u0396', 0}, 1, true case "Zfr": // BLACK-LETTER CAPITAL Z - return rune(0x2128), true + return {'\u2128', 0}, 1, true case "Zgr": // GREEK CAPITAL LETTER ZETA - return rune(0x0396), true + return {'\u0396', 0}, 1, true case "Zopf": // DOUBLE-STRUCK CAPITAL Z - return rune(0x2124), true + return {'\u2124', 0}, 1, true case "Zscr": // MATHEMATICAL SCRIPT CAPITAL Z - return rune(0x01d4b5), true + return {'\U0001d4b5', 0}, 1, true } case 'a': switch name { case "aacgr": // GREEK SMALL LETTER ALPHA WITH TONOS - return rune(0x03ac), true + return {'\u03ac', 0}, 1, true case "aacute": // LATIN SMALL LETTER A WITH ACUTE - return rune(0xe1), true + return {'á', 0}, 1, true case "abreve": // LATIN SMALL LETTER A WITH BREVE - return rune(0x0103), true + return {'\u0103', 0}, 1, true case "ac": // INVERTED LAZY S - return rune(0x223e), true + return {'\u223e', 0}, 1, true case "acE": // INVERTED LAZY S with double underline - return rune(0x223e), true + return {'\u223e', '\u0333'}, 2, true case "acd": // SINE WAVE - return rune(0x223f), true + return {'\u223f', 0}, 1, true case "acirc": // LATIN SMALL LETTER A WITH CIRCUMFLEX - return rune(0xe2), true + return {'â', 0}, 1, true case "actuary": // COMBINING ANNUITY SYMBOL - return rune(0x20e7), true + return {'\u20e7', 0}, 1, true case "acute": // ACUTE ACCENT - return rune(0xb4), true + return {'´', 0}, 1, true case "acy": // CYRILLIC SMALL LETTER A - return rune(0x0430), true + return {'\u0430', 0}, 1, true case "aelig": // LATIN SMALL LETTER AE - return rune(0xe6), true + return {'æ', 0}, 1, true case "af": // FUNCTION APPLICATION - return rune(0x2061), true + return {'\u2061', 0}, 1, true case "afr": // MATHEMATICAL FRAKTUR SMALL A - return rune(0x01d51e), true + return {'\U0001d51e', 0}, 1, true case "agr": // GREEK SMALL LETTER ALPHA - return rune(0x03b1), true + return {'\u03b1', 0}, 1, true case "agrave": // LATIN SMALL LETTER A WITH GRAVE - return rune(0xe0), true + return {'à', 0}, 1, true case "alefsym": // ALEF SYMBOL - return rune(0x2135), true + return {'\u2135', 0}, 1, true case "aleph": // ALEF SYMBOL - return rune(0x2135), true + return {'\u2135', 0}, 1, true case "alpha": // GREEK SMALL LETTER ALPHA - return rune(0x03b1), true + return {'\u03b1', 0}, 1, true case "amacr": // LATIN SMALL LETTER A WITH MACRON - return rune(0x0101), true + return {'\u0101', 0}, 1, true case "amalg": // AMALGAMATION OR COPRODUCT - return rune(0x2a3f), true + return {'\u2a3f', 0}, 1, true case "amp": // AMPERSAND - return rune(0x26), true + return {'&', 0}, 1, true case "and": // LOGICAL AND - return rune(0x2227), true + return {'\u2227', 0}, 1, true case "andand": // TWO INTERSECTING LOGICAL AND - return rune(0x2a55), true + return {'\u2a55', 0}, 1, true case "andd": // LOGICAL AND WITH HORIZONTAL DASH - return rune(0x2a5c), true + return {'\u2a5c', 0}, 1, true case "andslope": // SLOPING LARGE AND - return rune(0x2a58), true + return {'\u2a58', 0}, 1, true case "andv": // LOGICAL AND WITH MIDDLE STEM - return rune(0x2a5a), true + return {'\u2a5a', 0}, 1, true case "ang": // ANGLE - return rune(0x2220), true + return {'\u2220', 0}, 1, true case "ang90": // RIGHT ANGLE - return rune(0x221f), true + return {'\u221f', 0}, 1, true case "angdnl": // TURNED ANGLE - return rune(0x29a2), true + return {'\u29a2', 0}, 1, true case "angdnr": // ACUTE ANGLE - return rune(0x299f), true + return {'\u299f', 0}, 1, true case "ange": // ANGLE WITH UNDERBAR - return rune(0x29a4), true + return {'\u29a4', 0}, 1, true case "angle": // ANGLE - return rune(0x2220), true + return {'\u2220', 0}, 1, true case "angles": // ANGLE WITH S INSIDE - return rune(0x299e), true + return {'\u299e', 0}, 1, true case "angmsd": // MEASURED ANGLE - return rune(0x2221), true + return {'\u2221', 0}, 1, true case "angmsdaa": // MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING UP AND RIGHT - return rune(0x29a8), true + return {'\u29a8', 0}, 1, true case "angmsdab": // MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING UP AND LEFT - return rune(0x29a9), true + return {'\u29a9', 0}, 1, true case "angmsdac": // MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING DOWN AND RIGHT - return rune(0x29aa), true + return {'\u29aa', 0}, 1, true case "angmsdad": // MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING DOWN AND LEFT - return rune(0x29ab), true + return {'\u29ab', 0}, 1, true case "angmsdae": // MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING RIGHT AND UP - return rune(0x29ac), true + return {'\u29ac', 0}, 1, true case "angmsdaf": // MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING LEFT AND UP - return rune(0x29ad), true + return {'\u29ad', 0}, 1, true case "angmsdag": // MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING RIGHT AND DOWN - return rune(0x29ae), true + return {'\u29ae', 0}, 1, true case "angmsdah": // MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING LEFT AND DOWN - return rune(0x29af), true + return {'\u29af', 0}, 1, true case "angrt": // RIGHT ANGLE - return rune(0x221f), true + return {'\u221f', 0}, 1, true case "angrtvb": // RIGHT ANGLE WITH ARC - return rune(0x22be), true + return {'\u22be', 0}, 1, true case "angrtvbd": // MEASURED RIGHT ANGLE WITH DOT - return rune(0x299d), true + return {'\u299d', 0}, 1, true case "angsph": // SPHERICAL ANGLE - return rune(0x2222), true + return {'\u2222', 0}, 1, true case "angst": // LATIN CAPITAL LETTER A WITH RING ABOVE - return rune(0xc5), true + return {'Å', 0}, 1, true case "angupl": // REVERSED ANGLE - return rune(0x29a3), true + return {'\u29a3', 0}, 1, true case "angzarr": // RIGHT ANGLE WITH DOWNWARDS ZIGZAG ARROW - return rune(0x237c), true + return {'\u237c', 0}, 1, true case "aogon": // LATIN SMALL LETTER A WITH OGONEK - return rune(0x0105), true + return {'\u0105', 0}, 1, true case "aopf": // MATHEMATICAL DOUBLE-STRUCK SMALL A - return rune(0x01d552), true + return {'\U0001d552', 0}, 1, true case "ap": // ALMOST EQUAL TO - return rune(0x2248), true + return {'\u2248', 0}, 1, true case "apE": // APPROXIMATELY EQUAL OR EQUAL TO - return rune(0x2a70), true + return {'\u2a70', 0}, 1, true case "apacir": // ALMOST EQUAL TO WITH CIRCUMFLEX ACCENT - return rune(0x2a6f), true + return {'\u2a6f', 0}, 1, true case "ape": // ALMOST EQUAL OR EQUAL TO - return rune(0x224a), true + return {'\u224a', 0}, 1, true case "apid": // TRIPLE TILDE - return rune(0x224b), true + return {'\u224b', 0}, 1, true case "apos": // APOSTROPHE - return rune(0x27), true + return {'\'', 0}, 1, true case "approx": // ALMOST EQUAL TO - return rune(0x2248), true + return {'\u2248', 0}, 1, true case "approxeq": // ALMOST EQUAL OR EQUAL TO - return rune(0x224a), true + return {'\u224a', 0}, 1, true case "aring": // LATIN SMALL LETTER A WITH RING ABOVE - return rune(0xe5), true + return {'å', 0}, 1, true case "arrllsr": // LEFTWARDS ARROW ABOVE SHORT RIGHTWARDS ARROW - return rune(0x2943), true + return {'\u2943', 0}, 1, true case "arrlrsl": // RIGHTWARDS ARROW ABOVE SHORT LEFTWARDS ARROW - return rune(0x2942), true + return {'\u2942', 0}, 1, true case "arrsrll": // SHORT RIGHTWARDS ARROW ABOVE LEFTWARDS ARROW - return rune(0x2944), true + return {'\u2944', 0}, 1, true case "ascr": // MATHEMATICAL SCRIPT SMALL A - return rune(0x01d4b6), true + return {'\U0001d4b6', 0}, 1, true case "ast": // ASTERISK - return rune(0x2a), true + return {'*', 0}, 1, true case "astb": // SQUARED ASTERISK - return rune(0x29c6), true + return {'\u29c6', 0}, 1, true case "asymp": // ALMOST EQUAL TO - return rune(0x2248), true + return {'\u2248', 0}, 1, true case "asympeq": // EQUIVALENT TO - return rune(0x224d), true + return {'\u224d', 0}, 1, true case "atilde": // LATIN SMALL LETTER A WITH TILDE - return rune(0xe3), true + return {'ã', 0}, 1, true case "auml": // LATIN SMALL LETTER A WITH DIAERESIS - return rune(0xe4), true + return {'ä', 0}, 1, true case "awconint": // ANTICLOCKWISE CONTOUR INTEGRAL - return rune(0x2233), true + return {'\u2233', 0}, 1, true case "awint": // ANTICLOCKWISE INTEGRATION - return rune(0x2a11), true + return {'\u2a11', 0}, 1, true } case 'b': switch name { case "b.Delta": // MATHEMATICAL BOLD CAPITAL DELTA - return rune(0x01d6ab), true + return {'\U0001d6ab', 0}, 1, true case "b.Gamma": // MATHEMATICAL BOLD CAPITAL GAMMA - return rune(0x01d6aa), true + return {'\U0001d6aa', 0}, 1, true case "b.Gammad": // MATHEMATICAL BOLD CAPITAL DIGAMMA - return rune(0x01d7ca), true + return {'\U0001d7ca', 0}, 1, true case "b.Lambda": // MATHEMATICAL BOLD CAPITAL LAMDA - return rune(0x01d6b2), true + return {'\U0001d6b2', 0}, 1, true case "b.Omega": // MATHEMATICAL BOLD CAPITAL OMEGA - return rune(0x01d6c0), true + return {'\U0001d6c0', 0}, 1, true case "b.Phi": // MATHEMATICAL BOLD CAPITAL PHI - return rune(0x01d6bd), true + return {'\U0001d6bd', 0}, 1, true case "b.Pi": // MATHEMATICAL BOLD CAPITAL PI - return rune(0x01d6b7), true + return {'\U0001d6b7', 0}, 1, true case "b.Psi": // MATHEMATICAL BOLD CAPITAL PSI - return rune(0x01d6bf), true + return {'\U0001d6bf', 0}, 1, true case "b.Sigma": // MATHEMATICAL BOLD CAPITAL SIGMA - return rune(0x01d6ba), true + return {'\U0001d6ba', 0}, 1, true case "b.Theta": // MATHEMATICAL BOLD CAPITAL THETA - return rune(0x01d6af), true + return {'\U0001d6af', 0}, 1, true case "b.Upsi": // MATHEMATICAL BOLD CAPITAL UPSILON - return rune(0x01d6bc), true + return {'\U0001d6bc', 0}, 1, true case "b.Xi": // MATHEMATICAL BOLD CAPITAL XI - return rune(0x01d6b5), true + return {'\U0001d6b5', 0}, 1, true case "b.alpha": // MATHEMATICAL BOLD SMALL ALPHA - return rune(0x01d6c2), true + return {'\U0001d6c2', 0}, 1, true case "b.beta": // MATHEMATICAL BOLD SMALL BETA - return rune(0x01d6c3), true + return {'\U0001d6c3', 0}, 1, true case "b.chi": // MATHEMATICAL BOLD SMALL CHI - return rune(0x01d6d8), true + return {'\U0001d6d8', 0}, 1, true case "b.delta": // MATHEMATICAL BOLD SMALL DELTA - return rune(0x01d6c5), true + return {'\U0001d6c5', 0}, 1, true case "b.epsi": // MATHEMATICAL BOLD SMALL EPSILON - return rune(0x01d6c6), true + return {'\U0001d6c6', 0}, 1, true case "b.epsiv": // MATHEMATICAL BOLD EPSILON SYMBOL - return rune(0x01d6dc), true + return {'\U0001d6dc', 0}, 1, true case "b.eta": // MATHEMATICAL BOLD SMALL ETA - return rune(0x01d6c8), true + return {'\U0001d6c8', 0}, 1, true case "b.gamma": // MATHEMATICAL BOLD SMALL GAMMA - return rune(0x01d6c4), true + return {'\U0001d6c4', 0}, 1, true case "b.gammad": // MATHEMATICAL BOLD SMALL DIGAMMA - return rune(0x01d7cb), true + return {'\U0001d7cb', 0}, 1, true case "b.iota": // MATHEMATICAL BOLD SMALL IOTA - return rune(0x01d6ca), true + return {'\U0001d6ca', 0}, 1, true case "b.kappa": // MATHEMATICAL BOLD SMALL KAPPA - return rune(0x01d6cb), true + return {'\U0001d6cb', 0}, 1, true case "b.kappav": // MATHEMATICAL BOLD KAPPA SYMBOL - return rune(0x01d6de), true + return {'\U0001d6de', 0}, 1, true case "b.lambda": // MATHEMATICAL BOLD SMALL LAMDA - return rune(0x01d6cc), true + return {'\U0001d6cc', 0}, 1, true case "b.mu": // MATHEMATICAL BOLD SMALL MU - return rune(0x01d6cd), true + return {'\U0001d6cd', 0}, 1, true case "b.nu": // MATHEMATICAL BOLD SMALL NU - return rune(0x01d6ce), true + return {'\U0001d6ce', 0}, 1, true case "b.omega": // MATHEMATICAL BOLD SMALL OMEGA - return rune(0x01d6da), true + return {'\U0001d6da', 0}, 1, true case "b.phi": // MATHEMATICAL BOLD SMALL PHI - return rune(0x01d6d7), true + return {'\U0001d6d7', 0}, 1, true case "b.phiv": // MATHEMATICAL BOLD PHI SYMBOL - return rune(0x01d6df), true + return {'\U0001d6df', 0}, 1, true case "b.pi": // MATHEMATICAL BOLD SMALL PI - return rune(0x01d6d1), true + return {'\U0001d6d1', 0}, 1, true case "b.piv": // MATHEMATICAL BOLD PI SYMBOL - return rune(0x01d6e1), true + return {'\U0001d6e1', 0}, 1, true case "b.psi": // MATHEMATICAL BOLD SMALL PSI - return rune(0x01d6d9), true + return {'\U0001d6d9', 0}, 1, true case "b.rho": // MATHEMATICAL BOLD SMALL RHO - return rune(0x01d6d2), true + return {'\U0001d6d2', 0}, 1, true case "b.rhov": // MATHEMATICAL BOLD RHO SYMBOL - return rune(0x01d6e0), true + return {'\U0001d6e0', 0}, 1, true case "b.sigma": // MATHEMATICAL BOLD SMALL SIGMA - return rune(0x01d6d4), true + return {'\U0001d6d4', 0}, 1, true case "b.sigmav": // MATHEMATICAL BOLD SMALL FINAL SIGMA - return rune(0x01d6d3), true + return {'\U0001d6d3', 0}, 1, true case "b.tau": // MATHEMATICAL BOLD SMALL TAU - return rune(0x01d6d5), true + return {'\U0001d6d5', 0}, 1, true case "b.thetas": // MATHEMATICAL BOLD SMALL THETA - return rune(0x01d6c9), true + return {'\U0001d6c9', 0}, 1, true case "b.thetav": // MATHEMATICAL BOLD THETA SYMBOL - return rune(0x01d6dd), true + return {'\U0001d6dd', 0}, 1, true case "b.upsi": // MATHEMATICAL BOLD SMALL UPSILON - return rune(0x01d6d6), true + return {'\U0001d6d6', 0}, 1, true case "b.xi": // MATHEMATICAL BOLD SMALL XI - return rune(0x01d6cf), true + return {'\U0001d6cf', 0}, 1, true case "b.zeta": // MATHEMATICAL BOLD SMALL ZETA - return rune(0x01d6c7), true + return {'\U0001d6c7', 0}, 1, true case "bNot": // REVERSED DOUBLE STROKE NOT SIGN - return rune(0x2aed), true + return {'\u2aed', 0}, 1, true case "backcong": // ALL EQUAL TO - return rune(0x224c), true + return {'\u224c', 0}, 1, true case "backepsilon": // GREEK REVERSED LUNATE EPSILON SYMBOL - return rune(0x03f6), true + return {'\u03f6', 0}, 1, true case "backprime": // REVERSED PRIME - return rune(0x2035), true + return {'\u2035', 0}, 1, true case "backsim": // REVERSED TILDE - return rune(0x223d), true + return {'\u223d', 0}, 1, true case "backsimeq": // REVERSED TILDE EQUALS - return rune(0x22cd), true + return {'\u22cd', 0}, 1, true case "barV": // DOUBLE DOWN TACK - return rune(0x2aea), true + return {'\u2aea', 0}, 1, true case "barvee": // NOR - return rune(0x22bd), true + return {'\u22bd', 0}, 1, true case "barwed": // PROJECTIVE - return rune(0x2305), true + return {'\u2305', 0}, 1, true case "barwedge": // PROJECTIVE - return rune(0x2305), true + return {'\u2305', 0}, 1, true case "bbrk": // BOTTOM SQUARE BRACKET - return rune(0x23b5), true + return {'\u23b5', 0}, 1, true case "bbrktbrk": // BOTTOM SQUARE BRACKET OVER TOP SQUARE BRACKET - return rune(0x23b6), true + return {'\u23b6', 0}, 1, true case "bcong": // ALL EQUAL TO - return rune(0x224c), true + return {'\u224c', 0}, 1, true case "bcy": // CYRILLIC SMALL LETTER BE - return rune(0x0431), true + return {'\u0431', 0}, 1, true case "bdlhar": // DOWNWARDS HARPOON WITH BARB LEFT FROM BAR - return rune(0x2961), true + return {'\u2961', 0}, 1, true case "bdquo": // DOUBLE LOW-9 QUOTATION MARK - return rune(0x201e), true + return {'\u201e', 0}, 1, true case "bdrhar": // DOWNWARDS HARPOON WITH BARB RIGHT FROM BAR - return rune(0x295d), true + return {'\u295d', 0}, 1, true case "becaus": // BECAUSE - return rune(0x2235), true + return {'\u2235', 0}, 1, true case "because": // BECAUSE - return rune(0x2235), true + return {'\u2235', 0}, 1, true case "bemptyv": // REVERSED EMPTY SET - return rune(0x29b0), true + return {'\u29b0', 0}, 1, true case "bepsi": // GREEK REVERSED LUNATE EPSILON SYMBOL - return rune(0x03f6), true + return {'\u03f6', 0}, 1, true case "bernou": // SCRIPT CAPITAL B - return rune(0x212c), true + return {'\u212c', 0}, 1, true case "beta": // GREEK SMALL LETTER BETA - return rune(0x03b2), true + return {'\u03b2', 0}, 1, true case "beth": // BET SYMBOL - return rune(0x2136), true + return {'\u2136', 0}, 1, true case "between": // BETWEEN - return rune(0x226c), true + return {'\u226c', 0}, 1, true case "bfr": // MATHEMATICAL FRAKTUR SMALL B - return rune(0x01d51f), true + return {'\U0001d51f', 0}, 1, true case "bgr": // GREEK SMALL LETTER BETA - return rune(0x03b2), true + return {'\u03b2', 0}, 1, true case "bigcap": // N-ARY INTERSECTION - return rune(0x22c2), true + return {'\u22c2', 0}, 1, true case "bigcirc": // LARGE CIRCLE - return rune(0x25ef), true + return {'\u25ef', 0}, 1, true case "bigcup": // N-ARY UNION - return rune(0x22c3), true + return {'\u22c3', 0}, 1, true case "bigodot": // N-ARY CIRCLED DOT OPERATOR - return rune(0x2a00), true + return {'\u2a00', 0}, 1, true case "bigoplus": // N-ARY CIRCLED PLUS OPERATOR - return rune(0x2a01), true + return {'\u2a01', 0}, 1, true case "bigotimes": // N-ARY CIRCLED TIMES OPERATOR - return rune(0x2a02), true + return {'\u2a02', 0}, 1, true case "bigsqcup": // N-ARY SQUARE UNION OPERATOR - return rune(0x2a06), true + return {'\u2a06', 0}, 1, true case "bigstar": // BLACK STAR - return rune(0x2605), true + return {'\u2605', 0}, 1, true case "bigtriangledown": // WHITE DOWN-POINTING TRIANGLE - return rune(0x25bd), true + return {'\u25bd', 0}, 1, true case "bigtriangleup": // WHITE UP-POINTING TRIANGLE - return rune(0x25b3), true + return {'\u25b3', 0}, 1, true case "biguplus": // N-ARY UNION OPERATOR WITH PLUS - return rune(0x2a04), true + return {'\u2a04', 0}, 1, true case "bigvee": // N-ARY LOGICAL OR - return rune(0x22c1), true + return {'\u22c1', 0}, 1, true case "bigwedge": // N-ARY LOGICAL AND - return rune(0x22c0), true + return {'\u22c0', 0}, 1, true case "bkarow": // RIGHTWARDS DOUBLE DASH ARROW - return rune(0x290d), true + return {'\u290d', 0}, 1, true case "blacklozenge": // BLACK LOZENGE - return rune(0x29eb), true + return {'\u29eb', 0}, 1, true case "blacksquare": // BLACK SMALL SQUARE - return rune(0x25aa), true + return {'\u25aa', 0}, 1, true case "blacktriangle": // BLACK UP-POINTING SMALL TRIANGLE - return rune(0x25b4), true + return {'\u25b4', 0}, 1, true case "blacktriangledown": // BLACK DOWN-POINTING SMALL TRIANGLE - return rune(0x25be), true + return {'\u25be', 0}, 1, true case "blacktriangleleft": // BLACK LEFT-POINTING SMALL TRIANGLE - return rune(0x25c2), true + return {'\u25c2', 0}, 1, true case "blacktriangleright": // BLACK RIGHT-POINTING SMALL TRIANGLE - return rune(0x25b8), true + return {'\u25b8', 0}, 1, true case "blank": // BLANK SYMBOL - return rune(0x2422), true + return {'\u2422', 0}, 1, true case "bldhar": // LEFTWARDS HARPOON WITH BARB DOWN FROM BAR - return rune(0x295e), true + return {'\u295e', 0}, 1, true case "blk12": // MEDIUM SHADE - return rune(0x2592), true + return {'\u2592', 0}, 1, true case "blk14": // LIGHT SHADE - return rune(0x2591), true + return {'\u2591', 0}, 1, true case "blk34": // DARK SHADE - return rune(0x2593), true + return {'\u2593', 0}, 1, true case "block": // FULL BLOCK - return rune(0x2588), true + return {'\u2588', 0}, 1, true case "bluhar": // LEFTWARDS HARPOON WITH BARB UP FROM BAR - return rune(0x295a), true + return {'\u295a', 0}, 1, true case "bne": // EQUALS SIGN with reverse slash - return rune(0x3d), true + return {'=', '\u20e5'}, 2, true case "bnequiv": // IDENTICAL TO with reverse slash - return rune(0x2261), true + return {'\u2261', '\u20e5'}, 2, true case "bnot": // REVERSED NOT SIGN - return rune(0x2310), true + return {'\u2310', 0}, 1, true case "bopf": // MATHEMATICAL DOUBLE-STRUCK SMALL B - return rune(0x01d553), true + return {'\U0001d553', 0}, 1, true case "bot": // UP TACK - return rune(0x22a5), true + return {'\u22a5', 0}, 1, true case "bottom": // UP TACK - return rune(0x22a5), true + return {'\u22a5', 0}, 1, true case "bowtie": // BOWTIE - return rune(0x22c8), true + return {'\u22c8', 0}, 1, true case "boxDL": // BOX DRAWINGS DOUBLE DOWN AND LEFT - return rune(0x2557), true + return {'\u2557', 0}, 1, true case "boxDR": // BOX DRAWINGS DOUBLE DOWN AND RIGHT - return rune(0x2554), true + return {'\u2554', 0}, 1, true case "boxDl": // BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE - return rune(0x2556), true + return {'\u2556', 0}, 1, true case "boxDr": // BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE - return rune(0x2553), true + return {'\u2553', 0}, 1, true case "boxH": // BOX DRAWINGS DOUBLE HORIZONTAL - return rune(0x2550), true + return {'\u2550', 0}, 1, true case "boxHD": // BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL - return rune(0x2566), true + return {'\u2566', 0}, 1, true case "boxHU": // BOX DRAWINGS DOUBLE UP AND HORIZONTAL - return rune(0x2569), true + return {'\u2569', 0}, 1, true case "boxHd": // BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE - return rune(0x2564), true + return {'\u2564', 0}, 1, true case "boxHu": // BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE - return rune(0x2567), true + return {'\u2567', 0}, 1, true case "boxUL": // BOX DRAWINGS DOUBLE UP AND LEFT - return rune(0x255d), true + return {'\u255d', 0}, 1, true case "boxUR": // BOX DRAWINGS DOUBLE UP AND RIGHT - return rune(0x255a), true + return {'\u255a', 0}, 1, true case "boxUl": // BOX DRAWINGS UP DOUBLE AND LEFT SINGLE - return rune(0x255c), true + return {'\u255c', 0}, 1, true case "boxUr": // BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE - return rune(0x2559), true + return {'\u2559', 0}, 1, true case "boxV": // BOX DRAWINGS DOUBLE VERTICAL - return rune(0x2551), true + return {'\u2551', 0}, 1, true case "boxVH": // BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL - return rune(0x256c), true + return {'\u256c', 0}, 1, true case "boxVL": // BOX DRAWINGS DOUBLE VERTICAL AND LEFT - return rune(0x2563), true + return {'\u2563', 0}, 1, true case "boxVR": // BOX DRAWINGS DOUBLE VERTICAL AND RIGHT - return rune(0x2560), true + return {'\u2560', 0}, 1, true case "boxVh": // BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE - return rune(0x256b), true + return {'\u256b', 0}, 1, true case "boxVl": // BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE - return rune(0x2562), true + return {'\u2562', 0}, 1, true case "boxVr": // BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE - return rune(0x255f), true + return {'\u255f', 0}, 1, true case "boxbox": // TWO JOINED SQUARES - return rune(0x29c9), true + return {'\u29c9', 0}, 1, true case "boxdL": // BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE - return rune(0x2555), true + return {'\u2555', 0}, 1, true case "boxdR": // BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE - return rune(0x2552), true + return {'\u2552', 0}, 1, true case "boxdl": // BOX DRAWINGS LIGHT DOWN AND LEFT - return rune(0x2510), true + return {'\u2510', 0}, 1, true case "boxdr": // BOX DRAWINGS LIGHT DOWN AND RIGHT - return rune(0x250c), true + return {'\u250c', 0}, 1, true case "boxh": // BOX DRAWINGS LIGHT HORIZONTAL - return rune(0x2500), true + return {'\u2500', 0}, 1, true case "boxhD": // BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE - return rune(0x2565), true + return {'\u2565', 0}, 1, true case "boxhU": // BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE - return rune(0x2568), true + return {'\u2568', 0}, 1, true case "boxhd": // BOX DRAWINGS LIGHT DOWN AND HORIZONTAL - return rune(0x252c), true + return {'\u252c', 0}, 1, true case "boxhu": // BOX DRAWINGS LIGHT UP AND HORIZONTAL - return rune(0x2534), true + return {'\u2534', 0}, 1, true case "boxminus": // SQUARED MINUS - return rune(0x229f), true + return {'\u229f', 0}, 1, true case "boxplus": // SQUARED PLUS - return rune(0x229e), true + return {'\u229e', 0}, 1, true case "boxtimes": // SQUARED TIMES - return rune(0x22a0), true + return {'\u22a0', 0}, 1, true case "boxuL": // BOX DRAWINGS UP SINGLE AND LEFT DOUBLE - return rune(0x255b), true + return {'\u255b', 0}, 1, true case "boxuR": // BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE - return rune(0x2558), true + return {'\u2558', 0}, 1, true case "boxul": // BOX DRAWINGS LIGHT UP AND LEFT - return rune(0x2518), true + return {'\u2518', 0}, 1, true case "boxur": // BOX DRAWINGS LIGHT UP AND RIGHT - return rune(0x2514), true + return {'\u2514', 0}, 1, true case "boxv": // BOX DRAWINGS LIGHT VERTICAL - return rune(0x2502), true + return {'\u2502', 0}, 1, true case "boxvH": // BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE - return rune(0x256a), true + return {'\u256a', 0}, 1, true case "boxvL": // BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE - return rune(0x2561), true + return {'\u2561', 0}, 1, true case "boxvR": // BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE - return rune(0x255e), true + return {'\u255e', 0}, 1, true case "boxvh": // BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL - return rune(0x253c), true + return {'\u253c', 0}, 1, true case "boxvl": // BOX DRAWINGS LIGHT VERTICAL AND LEFT - return rune(0x2524), true + return {'\u2524', 0}, 1, true case "boxvr": // BOX DRAWINGS LIGHT VERTICAL AND RIGHT - return rune(0x251c), true + return {'\u251c', 0}, 1, true case "bprime": // REVERSED PRIME - return rune(0x2035), true + return {'\u2035', 0}, 1, true case "brdhar": // RIGHTWARDS HARPOON WITH BARB DOWN FROM BAR - return rune(0x295f), true + return {'\u295f', 0}, 1, true case "breve": // BREVE - return rune(0x02d8), true + return {'\u02d8', 0}, 1, true case "bruhar": // RIGHTWARDS HARPOON WITH BARB UP FROM BAR - return rune(0x295b), true + return {'\u295b', 0}, 1, true case "brvbar": // BROKEN BAR - return rune(0xa6), true + return {'¦', 0}, 1, true case "bscr": // MATHEMATICAL SCRIPT SMALL B - return rune(0x01d4b7), true + return {'\U0001d4b7', 0}, 1, true case "bsemi": // REVERSED SEMICOLON - return rune(0x204f), true + return {'\u204f', 0}, 1, true case "bsim": // REVERSED TILDE - return rune(0x223d), true + return {'\u223d', 0}, 1, true case "bsime": // REVERSED TILDE EQUALS - return rune(0x22cd), true + return {'\u22cd', 0}, 1, true case "bsol": // REVERSE SOLIDUS - return rune(0x5c), true + return {'\\', 0}, 1, true case "bsolb": // SQUARED FALLING DIAGONAL SLASH - return rune(0x29c5), true + return {'\u29c5', 0}, 1, true case "bsolhsub": // REVERSE SOLIDUS PRECEDING SUBSET - return rune(0x27c8), true + return {'\u27c8', 0}, 1, true case "btimes": // SEMIDIRECT PRODUCT WITH BOTTOM CLOSED - return rune(0x2a32), true + return {'\u2a32', 0}, 1, true case "bulhar": // UPWARDS HARPOON WITH BARB LEFT FROM BAR - return rune(0x2960), true + return {'\u2960', 0}, 1, true case "bull": // BULLET - return rune(0x2022), true + return {'\u2022', 0}, 1, true case "bullet": // BULLET - return rune(0x2022), true + return {'\u2022', 0}, 1, true case "bump": // GEOMETRICALLY EQUIVALENT TO - return rune(0x224e), true + return {'\u224e', 0}, 1, true case "bumpE": // EQUALS SIGN WITH BUMPY ABOVE - return rune(0x2aae), true + return {'\u2aae', 0}, 1, true case "bumpe": // DIFFERENCE BETWEEN - return rune(0x224f), true + return {'\u224f', 0}, 1, true case "bumpeq": // DIFFERENCE BETWEEN - return rune(0x224f), true + return {'\u224f', 0}, 1, true case "burhar": // UPWARDS HARPOON WITH BARB RIGHT FROM BAR - return rune(0x295c), true + return {'\u295c', 0}, 1, true } case 'c': switch name { case "cacute": // LATIN SMALL LETTER C WITH ACUTE - return rune(0x0107), true + return {'\u0107', 0}, 1, true case "cap": // INTERSECTION - return rune(0x2229), true + return {'\u2229', 0}, 1, true case "capand": // INTERSECTION WITH LOGICAL AND - return rune(0x2a44), true + return {'\u2a44', 0}, 1, true case "capbrcup": // INTERSECTION ABOVE BAR ABOVE UNION - return rune(0x2a49), true + return {'\u2a49', 0}, 1, true case "capcap": // INTERSECTION BESIDE AND JOINED WITH INTERSECTION - return rune(0x2a4b), true + return {'\u2a4b', 0}, 1, true case "capcup": // INTERSECTION ABOVE UNION - return rune(0x2a47), true + return {'\u2a47', 0}, 1, true case "capdot": // INTERSECTION WITH DOT - return rune(0x2a40), true + return {'\u2a40', 0}, 1, true case "capint": // INTEGRAL WITH INTERSECTION - return rune(0x2a19), true + return {'\u2a19', 0}, 1, true case "caps": // INTERSECTION with serifs - return rune(0x2229), true + return {'\u2229', '\ufe00'}, 2, true case "caret": // CARET INSERTION POINT - return rune(0x2041), true + return {'\u2041', 0}, 1, true case "caron": // CARON - return rune(0x02c7), true + return {'\u02c7', 0}, 1, true case "ccaps": // CLOSED INTERSECTION WITH SERIFS - return rune(0x2a4d), true + return {'\u2a4d', 0}, 1, true case "ccaron": // LATIN SMALL LETTER C WITH CARON - return rune(0x010d), true + return {'\u010d', 0}, 1, true case "ccedil": // LATIN SMALL LETTER C WITH CEDILLA - return rune(0xe7), true + return {'ç', 0}, 1, true case "ccirc": // LATIN SMALL LETTER C WITH CIRCUMFLEX - return rune(0x0109), true + return {'\u0109', 0}, 1, true case "ccups": // CLOSED UNION WITH SERIFS - return rune(0x2a4c), true + return {'\u2a4c', 0}, 1, true case "ccupssm": // CLOSED UNION WITH SERIFS AND SMASH PRODUCT - return rune(0x2a50), true + return {'\u2a50', 0}, 1, true case "cdot": // LATIN SMALL LETTER C WITH DOT ABOVE - return rune(0x010b), true + return {'\u010b', 0}, 1, true case "cedil": // CEDILLA - return rune(0xb8), true + return {'¸', 0}, 1, true case "cemptyv": // EMPTY SET WITH SMALL CIRCLE ABOVE - return rune(0x29b2), true + return {'\u29b2', 0}, 1, true case "cent": // CENT SIGN - return rune(0xa2), true + return {'¢', 0}, 1, true case "centerdot": // MIDDLE DOT - return rune(0xb7), true + return {'·', 0}, 1, true case "cfr": // MATHEMATICAL FRAKTUR SMALL C - return rune(0x01d520), true + return {'\U0001d520', 0}, 1, true case "chcy": // CYRILLIC SMALL LETTER CHE - return rune(0x0447), true + return {'\u0447', 0}, 1, true case "check": // CHECK MARK - return rune(0x2713), true + return {'\u2713', 0}, 1, true case "checkmark": // CHECK MARK - return rune(0x2713), true + return {'\u2713', 0}, 1, true case "chi": // GREEK SMALL LETTER CHI - return rune(0x03c7), true + return {'\u03c7', 0}, 1, true case "cir": // WHITE CIRCLE - return rune(0x25cb), true + return {'\u25cb', 0}, 1, true case "cirE": // CIRCLE WITH TWO HORIZONTAL STROKES TO THE RIGHT - return rune(0x29c3), true + return {'\u29c3', 0}, 1, true case "cirb": // SQUARED SMALL CIRCLE - return rune(0x29c7), true + return {'\u29c7', 0}, 1, true case "circ": // MODIFIER LETTER CIRCUMFLEX ACCENT - return rune(0x02c6), true + return {'\u02c6', 0}, 1, true case "circeq": // RING EQUAL TO - return rune(0x2257), true + return {'\u2257', 0}, 1, true case "circlearrowleft": // ANTICLOCKWISE OPEN CIRCLE ARROW - return rune(0x21ba), true + return {'\u21ba', 0}, 1, true case "circlearrowright": // CLOCKWISE OPEN CIRCLE ARROW - return rune(0x21bb), true + return {'\u21bb', 0}, 1, true case "circledR": // REGISTERED SIGN - return rune(0xae), true + return {'®', 0}, 1, true case "circledS": // CIRCLED LATIN CAPITAL LETTER S - return rune(0x24c8), true + return {'\u24c8', 0}, 1, true case "circledast": // CIRCLED ASTERISK OPERATOR - return rune(0x229b), true + return {'\u229b', 0}, 1, true case "circledcirc": // CIRCLED RING OPERATOR - return rune(0x229a), true + return {'\u229a', 0}, 1, true case "circleddash": // CIRCLED DASH - return rune(0x229d), true + return {'\u229d', 0}, 1, true case "cirdarr": // WHITE CIRCLE WITH DOWN ARROW - return rune(0x29ec), true + return {'\u29ec', 0}, 1, true case "cire": // RING EQUAL TO - return rune(0x2257), true + return {'\u2257', 0}, 1, true case "cirerr": // ERROR-BARRED WHITE CIRCLE - return rune(0x29f2), true + return {'\u29f2', 0}, 1, true case "cirfdarr": // BLACK CIRCLE WITH DOWN ARROW - return rune(0x29ed), true + return {'\u29ed', 0}, 1, true case "cirferr": // ERROR-BARRED BLACK CIRCLE - return rune(0x29f3), true + return {'\u29f3', 0}, 1, true case "cirfnint": // CIRCULATION FUNCTION - return rune(0x2a10), true + return {'\u2a10', 0}, 1, true case "cirmid": // VERTICAL LINE WITH CIRCLE ABOVE - return rune(0x2aef), true + return {'\u2aef', 0}, 1, true case "cirscir": // CIRCLE WITH SMALL CIRCLE TO THE RIGHT - return rune(0x29c2), true + return {'\u29c2', 0}, 1, true case "closur": // CLOSE UP - return rune(0x2050), true + return {'\u2050', 0}, 1, true case "clubs": // BLACK CLUB SUIT - return rune(0x2663), true + return {'\u2663', 0}, 1, true case "clubsuit": // BLACK CLUB SUIT - return rune(0x2663), true + return {'\u2663', 0}, 1, true case "colon": // COLON - return rune(0x3a), true + return {':', 0}, 1, true case "colone": // COLON EQUALS - return rune(0x2254), true + return {'\u2254', 0}, 1, true case "coloneq": // COLON EQUALS - return rune(0x2254), true + return {'\u2254', 0}, 1, true case "comma": // COMMA - return rune(0x2c), true + return {',', 0}, 1, true case "commat": // COMMERCIAL AT - return rune(0x40), true + return {'@', 0}, 1, true case "comp": // COMPLEMENT - return rune(0x2201), true + return {'\u2201', 0}, 1, true case "compfn": // RING OPERATOR - return rune(0x2218), true + return {'\u2218', 0}, 1, true case "complement": // COMPLEMENT - return rune(0x2201), true + return {'\u2201', 0}, 1, true case "complexes": // DOUBLE-STRUCK CAPITAL C - return rune(0x2102), true + return {'\u2102', 0}, 1, true case "cong": // APPROXIMATELY EQUAL TO - return rune(0x2245), true + return {'\u2245', 0}, 1, true case "congdot": // CONGRUENT WITH DOT ABOVE - return rune(0x2a6d), true + return {'\u2a6d', 0}, 1, true case "conint": // CONTOUR INTEGRAL - return rune(0x222e), true + return {'\u222e', 0}, 1, true case "copf": // MATHEMATICAL DOUBLE-STRUCK SMALL C - return rune(0x01d554), true + return {'\U0001d554', 0}, 1, true case "coprod": // N-ARY COPRODUCT - return rune(0x2210), true + return {'\u2210', 0}, 1, true case "copy": // COPYRIGHT SIGN - return rune(0xa9), true + return {'©', 0}, 1, true case "copysr": // SOUND RECORDING COPYRIGHT - return rune(0x2117), true + return {'\u2117', 0}, 1, true case "crarr": // DOWNWARDS ARROW WITH CORNER LEFTWARDS - return rune(0x21b5), true + return {'\u21b5', 0}, 1, true case "cross": // BALLOT X - return rune(0x2717), true + return {'\u2717', 0}, 1, true case "cscr": // MATHEMATICAL SCRIPT SMALL C - return rune(0x01d4b8), true + return {'\U0001d4b8', 0}, 1, true case "csub": // CLOSED SUBSET - return rune(0x2acf), true + return {'\u2acf', 0}, 1, true case "csube": // CLOSED SUBSET OR EQUAL TO - return rune(0x2ad1), true + return {'\u2ad1', 0}, 1, true case "csup": // CLOSED SUPERSET - return rune(0x2ad0), true + return {'\u2ad0', 0}, 1, true case "csupe": // CLOSED SUPERSET OR EQUAL TO - return rune(0x2ad2), true + return {'\u2ad2', 0}, 1, true case "ctdot": // MIDLINE HORIZONTAL ELLIPSIS - return rune(0x22ef), true + return {'\u22ef', 0}, 1, true case "cudarrl": // RIGHT-SIDE ARC CLOCKWISE ARROW - return rune(0x2938), true + return {'\u2938', 0}, 1, true case "cudarrr": // ARROW POINTING RIGHTWARDS THEN CURVING DOWNWARDS - return rune(0x2935), true + return {'\u2935', 0}, 1, true case "cuepr": // EQUAL TO OR PRECEDES - return rune(0x22de), true + return {'\u22de', 0}, 1, true case "cuesc": // EQUAL TO OR SUCCEEDS - return rune(0x22df), true + return {'\u22df', 0}, 1, true case "cularr": // ANTICLOCKWISE TOP SEMICIRCLE ARROW - return rune(0x21b6), true + return {'\u21b6', 0}, 1, true case "cularrp": // TOP ARC ANTICLOCKWISE ARROW WITH PLUS - return rune(0x293d), true + return {'\u293d', 0}, 1, true case "cup": // UNION - return rune(0x222a), true + return {'\u222a', 0}, 1, true case "cupbrcap": // UNION ABOVE BAR ABOVE INTERSECTION - return rune(0x2a48), true + return {'\u2a48', 0}, 1, true case "cupcap": // UNION ABOVE INTERSECTION - return rune(0x2a46), true + return {'\u2a46', 0}, 1, true case "cupcup": // UNION BESIDE AND JOINED WITH UNION - return rune(0x2a4a), true + return {'\u2a4a', 0}, 1, true case "cupdot": // MULTISET MULTIPLICATION - return rune(0x228d), true + return {'\u228d', 0}, 1, true case "cupint": // INTEGRAL WITH UNION - return rune(0x2a1a), true + return {'\u2a1a', 0}, 1, true case "cupor": // UNION WITH LOGICAL OR - return rune(0x2a45), true + return {'\u2a45', 0}, 1, true case "cupre": // PRECEDES OR EQUAL TO - return rune(0x227c), true + return {'\u227c', 0}, 1, true case "cups": // UNION with serifs - return rune(0x222a), true + return {'\u222a', '\ufe00'}, 2, true case "curarr": // CLOCKWISE TOP SEMICIRCLE ARROW - return rune(0x21b7), true + return {'\u21b7', 0}, 1, true case "curarrm": // TOP ARC CLOCKWISE ARROW WITH MINUS - return rune(0x293c), true + return {'\u293c', 0}, 1, true case "curlyeqprec": // EQUAL TO OR PRECEDES - return rune(0x22de), true + return {'\u22de', 0}, 1, true case "curlyeqsucc": // EQUAL TO OR SUCCEEDS - return rune(0x22df), true + return {'\u22df', 0}, 1, true case "curlyvee": // CURLY LOGICAL OR - return rune(0x22ce), true + return {'\u22ce', 0}, 1, true case "curlywedge": // CURLY LOGICAL AND - return rune(0x22cf), true + return {'\u22cf', 0}, 1, true case "curren": // CURRENCY SIGN - return rune(0xa4), true + return {'¤', 0}, 1, true case "curvearrowleft": // ANTICLOCKWISE TOP SEMICIRCLE ARROW - return rune(0x21b6), true + return {'\u21b6', 0}, 1, true case "curvearrowright": // CLOCKWISE TOP SEMICIRCLE ARROW - return rune(0x21b7), true + return {'\u21b7', 0}, 1, true case "cuvee": // CURLY LOGICAL OR - return rune(0x22ce), true + return {'\u22ce', 0}, 1, true case "cuwed": // CURLY LOGICAL AND - return rune(0x22cf), true + return {'\u22cf', 0}, 1, true case "cwconint": // CLOCKWISE CONTOUR INTEGRAL - return rune(0x2232), true + return {'\u2232', 0}, 1, true case "cwint": // CLOCKWISE INTEGRAL - return rune(0x2231), true + return {'\u2231', 0}, 1, true case "cylcty": // CYLINDRICITY - return rune(0x232d), true + return {'\u232d', 0}, 1, true } case 'd': switch name { case "dAarr": // DOWNWARDS TRIPLE ARROW - return rune(0x290b), true + return {'\u290b', 0}, 1, true case "dArr": // DOWNWARDS DOUBLE ARROW - return rune(0x21d3), true + return {'\u21d3', 0}, 1, true case "dHar": // DOWNWARDS HARPOON WITH BARB LEFT BESIDE DOWNWARDS HARPOON WITH BARB RIGHT - return rune(0x2965), true + return {'\u2965', 0}, 1, true case "dagger": // DAGGER - return rune(0x2020), true + return {'\u2020', 0}, 1, true case "dalembrt": // SQUARE WITH CONTOURED OUTLINE - return rune(0x29e0), true + return {'\u29e0', 0}, 1, true case "daleth": // DALET SYMBOL - return rune(0x2138), true + return {'\u2138', 0}, 1, true case "darr": // DOWNWARDS ARROW - return rune(0x2193), true + return {'\u2193', 0}, 1, true case "darr2": // DOWNWARDS PAIRED ARROWS - return rune(0x21ca), true + return {'\u21ca', 0}, 1, true case "darrb": // DOWNWARDS ARROW TO BAR - return rune(0x2913), true + return {'\u2913', 0}, 1, true case "darrln": // DOWNWARDS ARROW WITH HORIZONTAL STROKE - return rune(0x2908), true + return {'\u2908', 0}, 1, true case "dash": // HYPHEN - return rune(0x2010), true + return {'\u2010', 0}, 1, true case "dashV": // DOUBLE VERTICAL BAR LEFT TURNSTILE - return rune(0x2ae3), true + return {'\u2ae3', 0}, 1, true case "dashv": // LEFT TACK - return rune(0x22a3), true + return {'\u22a3', 0}, 1, true case "dbkarow": // RIGHTWARDS TRIPLE DASH ARROW - return rune(0x290f), true + return {'\u290f', 0}, 1, true case "dblac": // DOUBLE ACUTE ACCENT - return rune(0x02dd), true + return {'\u02dd', 0}, 1, true case "dcaron": // LATIN SMALL LETTER D WITH CARON - return rune(0x010f), true + return {'\u010f', 0}, 1, true case "dcy": // CYRILLIC SMALL LETTER DE - return rune(0x0434), true + return {'\u0434', 0}, 1, true case "dd": // DOUBLE-STRUCK ITALIC SMALL D - return rune(0x2146), true + return {'\u2146', 0}, 1, true case "ddagger": // DOUBLE DAGGER - return rune(0x2021), true + return {'\u2021', 0}, 1, true case "ddarr": // DOWNWARDS PAIRED ARROWS - return rune(0x21ca), true + return {'\u21ca', 0}, 1, true case "ddotseq": // EQUALS SIGN WITH TWO DOTS ABOVE AND TWO DOTS BELOW - return rune(0x2a77), true + return {'\u2a77', 0}, 1, true case "deg": // DEGREE SIGN - return rune(0xb0), true + return {'°', 0}, 1, true case "delta": // GREEK SMALL LETTER DELTA - return rune(0x03b4), true + return {'\u03b4', 0}, 1, true case "demptyv": // EMPTY SET WITH OVERBAR - return rune(0x29b1), true + return {'\u29b1', 0}, 1, true case "dfisht": // DOWN FISH TAIL - return rune(0x297f), true + return {'\u297f', 0}, 1, true case "dfr": // MATHEMATICAL FRAKTUR SMALL D - return rune(0x01d521), true + return {'\U0001d521', 0}, 1, true case "dgr": // GREEK SMALL LETTER DELTA - return rune(0x03b4), true + return {'\u03b4', 0}, 1, true case "dharl": // DOWNWARDS HARPOON WITH BARB LEFTWARDS - return rune(0x21c3), true + return {'\u21c3', 0}, 1, true case "dharr": // DOWNWARDS HARPOON WITH BARB RIGHTWARDS - return rune(0x21c2), true + return {'\u21c2', 0}, 1, true case "diam": // DIAMOND OPERATOR - return rune(0x22c4), true + return {'\u22c4', 0}, 1, true case "diamdarr": // BLACK DIAMOND WITH DOWN ARROW - return rune(0x29ea), true + return {'\u29ea', 0}, 1, true case "diamerr": // ERROR-BARRED WHITE DIAMOND - return rune(0x29f0), true + return {'\u29f0', 0}, 1, true case "diamerrf": // ERROR-BARRED BLACK DIAMOND - return rune(0x29f1), true + return {'\u29f1', 0}, 1, true case "diamond": // DIAMOND OPERATOR - return rune(0x22c4), true + return {'\u22c4', 0}, 1, true case "diamondsuit": // BLACK DIAMOND SUIT - return rune(0x2666), true + return {'\u2666', 0}, 1, true case "diams": // BLACK DIAMOND SUIT - return rune(0x2666), true + return {'\u2666', 0}, 1, true case "die": // DIAERESIS - return rune(0xa8), true + return {'¨', 0}, 1, true case "digamma": // GREEK SMALL LETTER DIGAMMA - return rune(0x03dd), true + return {'\u03dd', 0}, 1, true case "disin": // ELEMENT OF WITH LONG HORIZONTAL STROKE - return rune(0x22f2), true + return {'\u22f2', 0}, 1, true case "div": // DIVISION SIGN - return rune(0xf7), true + return {'÷', 0}, 1, true case "divide": // DIVISION SIGN - return rune(0xf7), true + return {'÷', 0}, 1, true case "divideontimes": // DIVISION TIMES - return rune(0x22c7), true + return {'\u22c7', 0}, 1, true case "divonx": // DIVISION TIMES - return rune(0x22c7), true + return {'\u22c7', 0}, 1, true case "djcy": // CYRILLIC SMALL LETTER DJE - return rune(0x0452), true + return {'\u0452', 0}, 1, true case "dlarr": // SOUTH WEST ARROW - return rune(0x2199), true + return {'\u2199', 0}, 1, true case "dlcorn": // BOTTOM LEFT CORNER - return rune(0x231e), true + return {'\u231e', 0}, 1, true case "dlcrop": // BOTTOM LEFT CROP - return rune(0x230d), true + return {'\u230d', 0}, 1, true case "dlharb": // DOWNWARDS HARPOON WITH BARB LEFT TO BAR - return rune(0x2959), true + return {'\u2959', 0}, 1, true case "dollar": // DOLLAR SIGN - return rune(0x24), true + return {'$', 0}, 1, true case "dopf": // MATHEMATICAL DOUBLE-STRUCK SMALL D - return rune(0x01d555), true + return {'\U0001d555', 0}, 1, true case "dot": // DOT ABOVE - return rune(0x02d9), true + return {'\u02d9', 0}, 1, true case "doteq": // APPROACHES THE LIMIT - return rune(0x2250), true + return {'\u2250', 0}, 1, true case "doteqdot": // GEOMETRICALLY EQUAL TO - return rune(0x2251), true + return {'\u2251', 0}, 1, true case "dotminus": // DOT MINUS - return rune(0x2238), true + return {'\u2238', 0}, 1, true case "dotplus": // DOT PLUS - return rune(0x2214), true + return {'\u2214', 0}, 1, true case "dotsquare": // SQUARED DOT OPERATOR - return rune(0x22a1), true + return {'\u22a1', 0}, 1, true case "doublebarwedge": // PERSPECTIVE - return rune(0x2306), true + return {'\u2306', 0}, 1, true case "downarrow": // DOWNWARDS ARROW - return rune(0x2193), true + return {'\u2193', 0}, 1, true case "downdownarrows": // DOWNWARDS PAIRED ARROWS - return rune(0x21ca), true + return {'\u21ca', 0}, 1, true case "downharpoonleft": // DOWNWARDS HARPOON WITH BARB LEFTWARDS - return rune(0x21c3), true + return {'\u21c3', 0}, 1, true case "downharpoonright": // DOWNWARDS HARPOON WITH BARB RIGHTWARDS - return rune(0x21c2), true + return {'\u21c2', 0}, 1, true case "drarr": // SOUTH EAST ARROW - return rune(0x2198), true + return {'\u2198', 0}, 1, true case "drbkarow": // RIGHTWARDS TWO-HEADED TRIPLE DASH ARROW - return rune(0x2910), true + return {'\u2910', 0}, 1, true case "drcorn": // BOTTOM RIGHT CORNER - return rune(0x231f), true + return {'\u231f', 0}, 1, true case "drcrop": // BOTTOM RIGHT CROP - return rune(0x230c), true + return {'\u230c', 0}, 1, true case "drharb": // DOWNWARDS HARPOON WITH BARB RIGHT TO BAR - return rune(0x2955), true + return {'\u2955', 0}, 1, true case "dscr": // MATHEMATICAL SCRIPT SMALL D - return rune(0x01d4b9), true + return {'\U0001d4b9', 0}, 1, true case "dscy": // CYRILLIC SMALL LETTER DZE - return rune(0x0455), true + return {'\u0455', 0}, 1, true case "dsol": // SOLIDUS WITH OVERBAR - return rune(0x29f6), true + return {'\u29f6', 0}, 1, true case "dstrok": // LATIN SMALL LETTER D WITH STROKE - return rune(0x0111), true + return {'\u0111', 0}, 1, true case "dtdot": // DOWN RIGHT DIAGONAL ELLIPSIS - return rune(0x22f1), true + return {'\u22f1', 0}, 1, true case "dtri": // WHITE DOWN-POINTING SMALL TRIANGLE - return rune(0x25bf), true + return {'\u25bf', 0}, 1, true case "dtrif": // BLACK DOWN-POINTING SMALL TRIANGLE - return rune(0x25be), true + return {'\u25be', 0}, 1, true case "dtrilf": // DOWN-POINTING TRIANGLE WITH LEFT HALF BLACK - return rune(0x29e8), true + return {'\u29e8', 0}, 1, true case "dtrirf": // DOWN-POINTING TRIANGLE WITH RIGHT HALF BLACK - return rune(0x29e9), true + return {'\u29e9', 0}, 1, true case "duarr": // DOWNWARDS ARROW LEFTWARDS OF UPWARDS ARROW - return rune(0x21f5), true + return {'\u21f5', 0}, 1, true case "duhar": // DOWNWARDS HARPOON WITH BARB LEFT BESIDE UPWARDS HARPOON WITH BARB RIGHT - return rune(0x296f), true + return {'\u296f', 0}, 1, true case "dumap": // DOUBLE-ENDED MULTIMAP - return rune(0x29df), true + return {'\u29df', 0}, 1, true case "dwangle": // OBLIQUE ANGLE OPENING UP - return rune(0x29a6), true + return {'\u29a6', 0}, 1, true case "dzcy": // CYRILLIC SMALL LETTER DZHE - return rune(0x045f), true + return {'\u045f', 0}, 1, true case "dzigrarr": // LONG RIGHTWARDS SQUIGGLE ARROW - return rune(0x27ff), true + return {'\u27ff', 0}, 1, true } case 'e': switch name { case "eDDot": // EQUALS SIGN WITH TWO DOTS ABOVE AND TWO DOTS BELOW - return rune(0x2a77), true + return {'\u2a77', 0}, 1, true case "eDot": // GEOMETRICALLY EQUAL TO - return rune(0x2251), true + return {'\u2251', 0}, 1, true case "eacgr": // GREEK SMALL LETTER EPSILON WITH TONOS - return rune(0x03ad), true + return {'\u03ad', 0}, 1, true case "eacute": // LATIN SMALL LETTER E WITH ACUTE - return rune(0xe9), true + return {'é', 0}, 1, true case "easter": // EQUALS WITH ASTERISK - return rune(0x2a6e), true + return {'\u2a6e', 0}, 1, true case "ecaron": // LATIN SMALL LETTER E WITH CARON - return rune(0x011b), true + return {'\u011b', 0}, 1, true case "ecir": // RING IN EQUAL TO - return rune(0x2256), true + return {'\u2256', 0}, 1, true case "ecirc": // LATIN SMALL LETTER E WITH CIRCUMFLEX - return rune(0xea), true + return {'ê', 0}, 1, true case "ecolon": // EQUALS COLON - return rune(0x2255), true + return {'\u2255', 0}, 1, true case "ecy": // CYRILLIC SMALL LETTER E - return rune(0x044d), true + return {'\u044d', 0}, 1, true case "edot": // LATIN SMALL LETTER E WITH DOT ABOVE - return rune(0x0117), true + return {'\u0117', 0}, 1, true case "ee": // DOUBLE-STRUCK ITALIC SMALL E - return rune(0x2147), true + return {'\u2147', 0}, 1, true case "eeacgr": // GREEK SMALL LETTER ETA WITH TONOS - return rune(0x03ae), true + return {'\u03ae', 0}, 1, true case "eegr": // GREEK SMALL LETTER ETA - return rune(0x03b7), true + return {'\u03b7', 0}, 1, true case "efDot": // APPROXIMATELY EQUAL TO OR THE IMAGE OF - return rune(0x2252), true + return {'\u2252', 0}, 1, true case "efr": // MATHEMATICAL FRAKTUR SMALL E - return rune(0x01d522), true + return {'\U0001d522', 0}, 1, true case "eg": // DOUBLE-LINE EQUAL TO OR GREATER-THAN - return rune(0x2a9a), true + return {'\u2a9a', 0}, 1, true case "egr": // GREEK SMALL LETTER EPSILON - return rune(0x03b5), true + return {'\u03b5', 0}, 1, true case "egrave": // LATIN SMALL LETTER E WITH GRAVE - return rune(0xe8), true + return {'è', 0}, 1, true case "egs": // SLANTED EQUAL TO OR GREATER-THAN - return rune(0x2a96), true + return {'\u2a96', 0}, 1, true case "egsdot": // SLANTED EQUAL TO OR GREATER-THAN WITH DOT INSIDE - return rune(0x2a98), true + return {'\u2a98', 0}, 1, true case "el": // DOUBLE-LINE EQUAL TO OR LESS-THAN - return rune(0x2a99), true + return {'\u2a99', 0}, 1, true case "elinters": // ELECTRICAL INTERSECTION - return rune(0x23e7), true + return {'\u23e7', 0}, 1, true case "ell": // SCRIPT SMALL L - return rune(0x2113), true + return {'\u2113', 0}, 1, true case "els": // SLANTED EQUAL TO OR LESS-THAN - return rune(0x2a95), true + return {'\u2a95', 0}, 1, true case "elsdot": // SLANTED EQUAL TO OR LESS-THAN WITH DOT INSIDE - return rune(0x2a97), true + return {'\u2a97', 0}, 1, true case "emacr": // LATIN SMALL LETTER E WITH MACRON - return rune(0x0113), true + return {'\u0113', 0}, 1, true case "empty": // EMPTY SET - return rune(0x2205), true + return {'\u2205', 0}, 1, true case "emptyset": // EMPTY SET - return rune(0x2205), true + return {'\u2205', 0}, 1, true case "emptyv": // EMPTY SET - return rune(0x2205), true + return {'\u2205', 0}, 1, true case "emsp": // EM SPACE - return rune(0x2003), true + return {'\u2003', 0}, 1, true case "emsp13": // THREE-PER-EM SPACE - return rune(0x2004), true + return {'\u2004', 0}, 1, true case "emsp14": // FOUR-PER-EM SPACE - return rune(0x2005), true + return {'\u2005', 0}, 1, true case "eng": // LATIN SMALL LETTER ENG - return rune(0x014b), true + return {'\u014b', 0}, 1, true case "ensp": // EN SPACE - return rune(0x2002), true + return {'\u2002', 0}, 1, true case "eogon": // LATIN SMALL LETTER E WITH OGONEK - return rune(0x0119), true + return {'\u0119', 0}, 1, true case "eopf": // MATHEMATICAL DOUBLE-STRUCK SMALL E - return rune(0x01d556), true + return {'\U0001d556', 0}, 1, true case "epar": // EQUAL AND PARALLEL TO - return rune(0x22d5), true + return {'\u22d5', 0}, 1, true case "eparsl": // EQUALS SIGN AND SLANTED PARALLEL - return rune(0x29e3), true + return {'\u29e3', 0}, 1, true case "eplus": // EQUALS SIGN ABOVE PLUS SIGN - return rune(0x2a71), true + return {'\u2a71', 0}, 1, true case "epsi": // GREEK SMALL LETTER EPSILON - return rune(0x03b5), true + return {'\u03b5', 0}, 1, true case "epsilon": // GREEK SMALL LETTER EPSILON - return rune(0x03b5), true + return {'\u03b5', 0}, 1, true case "epsis": // GREEK LUNATE EPSILON SYMBOL - return rune(0x03f5), true + return {'\u03f5', 0}, 1, true case "epsiv": // GREEK LUNATE EPSILON SYMBOL - return rune(0x03f5), true + return {'\u03f5', 0}, 1, true case "eqcirc": // RING IN EQUAL TO - return rune(0x2256), true + return {'\u2256', 0}, 1, true case "eqcolon": // EQUALS COLON - return rune(0x2255), true + return {'\u2255', 0}, 1, true case "eqeq": // TWO CONSECUTIVE EQUALS SIGNS - return rune(0x2a75), true + return {'\u2a75', 0}, 1, true case "eqsim": // MINUS TILDE - return rune(0x2242), true + return {'\u2242', 0}, 1, true case "eqslantgtr": // SLANTED EQUAL TO OR GREATER-THAN - return rune(0x2a96), true + return {'\u2a96', 0}, 1, true case "eqslantless": // SLANTED EQUAL TO OR LESS-THAN - return rune(0x2a95), true + return {'\u2a95', 0}, 1, true case "equals": // EQUALS SIGN - return rune(0x3d), true + return {'=', 0}, 1, true case "equest": // QUESTIONED EQUAL TO - return rune(0x225f), true + return {'\u225f', 0}, 1, true case "equiv": // IDENTICAL TO - return rune(0x2261), true + return {'\u2261', 0}, 1, true case "equivDD": // EQUIVALENT WITH FOUR DOTS ABOVE - return rune(0x2a78), true + return {'\u2a78', 0}, 1, true case "eqvparsl": // IDENTICAL TO AND SLANTED PARALLEL - return rune(0x29e5), true + return {'\u29e5', 0}, 1, true case "erDot": // IMAGE OF OR APPROXIMATELY EQUAL TO - return rune(0x2253), true + return {'\u2253', 0}, 1, true case "erarr": // EQUALS SIGN ABOVE RIGHTWARDS ARROW - return rune(0x2971), true + return {'\u2971', 0}, 1, true case "escr": // SCRIPT SMALL E - return rune(0x212f), true + return {'\u212f', 0}, 1, true case "esdot": // APPROACHES THE LIMIT - return rune(0x2250), true + return {'\u2250', 0}, 1, true case "esim": // MINUS TILDE - return rune(0x2242), true + return {'\u2242', 0}, 1, true case "eta": // GREEK SMALL LETTER ETA - return rune(0x03b7), true + return {'\u03b7', 0}, 1, true case "eth": // LATIN SMALL LETTER ETH - return rune(0xf0), true + return {'ð', 0}, 1, true case "euml": // LATIN SMALL LETTER E WITH DIAERESIS - return rune(0xeb), true + return {'ë', 0}, 1, true case "euro": // EURO SIGN - return rune(0x20ac), true + return {'\u20ac', 0}, 1, true case "excl": // EXCLAMATION MARK - return rune(0x21), true + return {'!', 0}, 1, true case "exist": // THERE EXISTS - return rune(0x2203), true + return {'\u2203', 0}, 1, true case "expectation": // SCRIPT CAPITAL E - return rune(0x2130), true + return {'\u2130', 0}, 1, true case "exponentiale": // DOUBLE-STRUCK ITALIC SMALL E - return rune(0x2147), true + return {'\u2147', 0}, 1, true } case 'f': switch name { case "fallingdotseq": // APPROXIMATELY EQUAL TO OR THE IMAGE OF - return rune(0x2252), true + return {'\u2252', 0}, 1, true case "fbowtie": // BLACK BOWTIE - return rune(0x29d3), true + return {'\u29d3', 0}, 1, true case "fcy": // CYRILLIC SMALL LETTER EF - return rune(0x0444), true + return {'\u0444', 0}, 1, true case "fdiag": // BOX DRAWINGS LIGHT DIAGONAL UPPER LEFT TO LOWER RIGHT - return rune(0x2572), true + return {'\u2572', 0}, 1, true case "fdiordi": // FALLING DIAGONAL CROSSING RISING DIAGONAL - return rune(0x292c), true + return {'\u292c', 0}, 1, true case "fdonearr": // FALLING DIAGONAL CROSSING NORTH EAST ARROW - return rune(0x292f), true + return {'\u292f', 0}, 1, true case "female": // FEMALE SIGN - return rune(0x2640), true + return {'\u2640', 0}, 1, true case "ffilig": // LATIN SMALL LIGATURE FFI - return rune(0xfb03), true + return {'\ufb03', 0}, 1, true case "fflig": // LATIN SMALL LIGATURE FF - return rune(0xfb00), true + return {'\ufb00', 0}, 1, true case "ffllig": // LATIN SMALL LIGATURE FFL - return rune(0xfb04), true + return {'\ufb04', 0}, 1, true case "ffr": // MATHEMATICAL FRAKTUR SMALL F - return rune(0x01d523), true + return {'\U0001d523', 0}, 1, true case "fhrglass": // BLACK HOURGLASS - return rune(0x29d7), true + return {'\u29d7', 0}, 1, true case "filig": // LATIN SMALL LIGATURE FI - return rune(0xfb01), true + return {'\ufb01', 0}, 1, true case "fjlig": // fj ligature - return rune(0x66), true + return {'f', 'j'}, 2, true case "flat": // MUSIC FLAT SIGN - return rune(0x266d), true + return {'\u266d', 0}, 1, true case "fllig": // LATIN SMALL LIGATURE FL - return rune(0xfb02), true + return {'\ufb02', 0}, 1, true case "fltns": // WHITE PARALLELOGRAM - return rune(0x25b1), true + return {'\u25b1', 0}, 1, true case "fnof": // LATIN SMALL LETTER F WITH HOOK - return rune(0x0192), true + return {'\u0192', 0}, 1, true case "fopf": // MATHEMATICAL DOUBLE-STRUCK SMALL F - return rune(0x01d557), true + return {'\U0001d557', 0}, 1, true case "forall": // FOR ALL - return rune(0x2200), true + return {'\u2200', 0}, 1, true case "fork": // PITCHFORK - return rune(0x22d4), true + return {'\u22d4', 0}, 1, true case "forkv": // ELEMENT OF OPENING DOWNWARDS - return rune(0x2ad9), true + return {'\u2ad9', 0}, 1, true case "fpartint": // FINITE PART INTEGRAL - return rune(0x2a0d), true + return {'\u2a0d', 0}, 1, true case "frac12": // VULGAR FRACTION ONE HALF - return rune(0xbd), true + return {'½', 0}, 1, true case "frac13": // VULGAR FRACTION ONE THIRD - return rune(0x2153), true + return {'\u2153', 0}, 1, true case "frac14": // VULGAR FRACTION ONE QUARTER - return rune(0xbc), true + return {'¼', 0}, 1, true case "frac15": // VULGAR FRACTION ONE FIFTH - return rune(0x2155), true + return {'\u2155', 0}, 1, true case "frac16": // VULGAR FRACTION ONE SIXTH - return rune(0x2159), true + return {'\u2159', 0}, 1, true case "frac18": // VULGAR FRACTION ONE EIGHTH - return rune(0x215b), true + return {'\u215b', 0}, 1, true case "frac23": // VULGAR FRACTION TWO THIRDS - return rune(0x2154), true + return {'\u2154', 0}, 1, true case "frac25": // VULGAR FRACTION TWO FIFTHS - return rune(0x2156), true + return {'\u2156', 0}, 1, true case "frac34": // VULGAR FRACTION THREE QUARTERS - return rune(0xbe), true + return {'¾', 0}, 1, true case "frac35": // VULGAR FRACTION THREE FIFTHS - return rune(0x2157), true + return {'\u2157', 0}, 1, true case "frac38": // VULGAR FRACTION THREE EIGHTHS - return rune(0x215c), true + return {'\u215c', 0}, 1, true case "frac45": // VULGAR FRACTION FOUR FIFTHS - return rune(0x2158), true + return {'\u2158', 0}, 1, true case "frac56": // VULGAR FRACTION FIVE SIXTHS - return rune(0x215a), true + return {'\u215a', 0}, 1, true case "frac58": // VULGAR FRACTION FIVE EIGHTHS - return rune(0x215d), true + return {'\u215d', 0}, 1, true case "frac78": // VULGAR FRACTION SEVEN EIGHTHS - return rune(0x215e), true + return {'\u215e', 0}, 1, true case "frasl": // FRACTION SLASH - return rune(0x2044), true + return {'\u2044', 0}, 1, true case "frown": // FROWN - return rune(0x2322), true + return {'\u2322', 0}, 1, true case "fscr": // MATHEMATICAL SCRIPT SMALL F - return rune(0x01d4bb), true + return {'\U0001d4bb', 0}, 1, true } case 'g': switch name { case "gE": // GREATER-THAN OVER EQUAL TO - return rune(0x2267), true + return {'\u2267', 0}, 1, true case "gEl": // GREATER-THAN ABOVE DOUBLE-LINE EQUAL ABOVE LESS-THAN - return rune(0x2a8c), true + return {'\u2a8c', 0}, 1, true case "gacute": // LATIN SMALL LETTER G WITH ACUTE - return rune(0x01f5), true + return {'\u01f5', 0}, 1, true case "gamma": // GREEK SMALL LETTER GAMMA - return rune(0x03b3), true + return {'\u03b3', 0}, 1, true case "gammad": // GREEK SMALL LETTER DIGAMMA - return rune(0x03dd), true + return {'\u03dd', 0}, 1, true case "gap": // GREATER-THAN OR APPROXIMATE - return rune(0x2a86), true + return {'\u2a86', 0}, 1, true case "gbreve": // LATIN SMALL LETTER G WITH BREVE - return rune(0x011f), true + return {'\u011f', 0}, 1, true case "gcedil": // LATIN SMALL LETTER G WITH CEDILLA - return rune(0x0123), true + return {'\u0123', 0}, 1, true case "gcirc": // LATIN SMALL LETTER G WITH CIRCUMFLEX - return rune(0x011d), true + return {'\u011d', 0}, 1, true case "gcy": // CYRILLIC SMALL LETTER GHE - return rune(0x0433), true + return {'\u0433', 0}, 1, true case "gdot": // LATIN SMALL LETTER G WITH DOT ABOVE - return rune(0x0121), true + return {'\u0121', 0}, 1, true case "ge": // GREATER-THAN OR EQUAL TO - return rune(0x2265), true + return {'\u2265', 0}, 1, true case "gel": // GREATER-THAN EQUAL TO OR LESS-THAN - return rune(0x22db), true + return {'\u22db', 0}, 1, true case "geq": // GREATER-THAN OR EQUAL TO - return rune(0x2265), true + return {'\u2265', 0}, 1, true case "geqq": // GREATER-THAN OVER EQUAL TO - return rune(0x2267), true + return {'\u2267', 0}, 1, true case "geqslant": // GREATER-THAN OR SLANTED EQUAL TO - return rune(0x2a7e), true + return {'\u2a7e', 0}, 1, true case "ges": // GREATER-THAN OR SLANTED EQUAL TO - return rune(0x2a7e), true + return {'\u2a7e', 0}, 1, true case "gescc": // GREATER-THAN CLOSED BY CURVE ABOVE SLANTED EQUAL - return rune(0x2aa9), true + return {'\u2aa9', 0}, 1, true case "gesdot": // GREATER-THAN OR SLANTED EQUAL TO WITH DOT INSIDE - return rune(0x2a80), true + return {'\u2a80', 0}, 1, true case "gesdoto": // GREATER-THAN OR SLANTED EQUAL TO WITH DOT ABOVE - return rune(0x2a82), true + return {'\u2a82', 0}, 1, true case "gesdotol": // GREATER-THAN OR SLANTED EQUAL TO WITH DOT ABOVE LEFT - return rune(0x2a84), true + return {'\u2a84', 0}, 1, true case "gesl": // GREATER-THAN slanted EQUAL TO OR LESS-THAN - return rune(0x22db), true + return {'\u22db', '\ufe00'}, 2, true case "gesles": // GREATER-THAN ABOVE SLANTED EQUAL ABOVE LESS-THAN ABOVE SLANTED EQUAL - return rune(0x2a94), true + return {'\u2a94', 0}, 1, true case "gfr": // MATHEMATICAL FRAKTUR SMALL G - return rune(0x01d524), true + return {'\U0001d524', 0}, 1, true case "gg": // MUCH GREATER-THAN - return rune(0x226b), true + return {'\u226b', 0}, 1, true case "ggg": // VERY MUCH GREATER-THAN - return rune(0x22d9), true + return {'\u22d9', 0}, 1, true case "ggr": // GREEK SMALL LETTER GAMMA - return rune(0x03b3), true + return {'\u03b3', 0}, 1, true case "gimel": // GIMEL SYMBOL - return rune(0x2137), true + return {'\u2137', 0}, 1, true case "gjcy": // CYRILLIC SMALL LETTER GJE - return rune(0x0453), true + return {'\u0453', 0}, 1, true case "gl": // GREATER-THAN OR LESS-THAN - return rune(0x2277), true + return {'\u2277', 0}, 1, true case "glE": // GREATER-THAN ABOVE LESS-THAN ABOVE DOUBLE-LINE EQUAL - return rune(0x2a92), true + return {'\u2a92', 0}, 1, true case "gla": // GREATER-THAN BESIDE LESS-THAN - return rune(0x2aa5), true + return {'\u2aa5', 0}, 1, true case "glj": // GREATER-THAN OVERLAPPING LESS-THAN - return rune(0x2aa4), true + return {'\u2aa4', 0}, 1, true case "gnE": // GREATER-THAN BUT NOT EQUAL TO - return rune(0x2269), true + return {'\u2269', 0}, 1, true case "gnap": // GREATER-THAN AND NOT APPROXIMATE - return rune(0x2a8a), true + return {'\u2a8a', 0}, 1, true case "gnapprox": // GREATER-THAN AND NOT APPROXIMATE - return rune(0x2a8a), true + return {'\u2a8a', 0}, 1, true case "gne": // GREATER-THAN AND SINGLE-LINE NOT EQUAL TO - return rune(0x2a88), true + return {'\u2a88', 0}, 1, true case "gneq": // GREATER-THAN AND SINGLE-LINE NOT EQUAL TO - return rune(0x2a88), true + return {'\u2a88', 0}, 1, true case "gneqq": // GREATER-THAN BUT NOT EQUAL TO - return rune(0x2269), true + return {'\u2269', 0}, 1, true case "gnsim": // GREATER-THAN BUT NOT EQUIVALENT TO - return rune(0x22e7), true + return {'\u22e7', 0}, 1, true case "gopf": // MATHEMATICAL DOUBLE-STRUCK SMALL G - return rune(0x01d558), true + return {'\U0001d558', 0}, 1, true case "grave": // GRAVE ACCENT - return rune(0x60), true + return {'`', 0}, 1, true case "gscr": // SCRIPT SMALL G - return rune(0x210a), true + return {'\u210a', 0}, 1, true case "gsdot": // GREATER-THAN WITH DOT - return rune(0x22d7), true + return {'\u22d7', 0}, 1, true case "gsim": // GREATER-THAN OR EQUIVALENT TO - return rune(0x2273), true + return {'\u2273', 0}, 1, true case "gsime": // GREATER-THAN ABOVE SIMILAR OR EQUAL - return rune(0x2a8e), true + return {'\u2a8e', 0}, 1, true case "gsiml": // GREATER-THAN ABOVE SIMILAR ABOVE LESS-THAN - return rune(0x2a90), true + return {'\u2a90', 0}, 1, true case "gt": // GREATER-THAN SIGN - return rune(0x3e), true + return {'>', 0}, 1, true case "gtcc": // GREATER-THAN CLOSED BY CURVE - return rune(0x2aa7), true + return {'\u2aa7', 0}, 1, true case "gtcir": // GREATER-THAN WITH CIRCLE INSIDE - return rune(0x2a7a), true + return {'\u2a7a', 0}, 1, true case "gtdot": // GREATER-THAN WITH DOT - return rune(0x22d7), true + return {'\u22d7', 0}, 1, true case "gtlPar": // DOUBLE LEFT ARC GREATER-THAN BRACKET - return rune(0x2995), true + return {'\u2995', 0}, 1, true case "gtquest": // GREATER-THAN WITH QUESTION MARK ABOVE - return rune(0x2a7c), true + return {'\u2a7c', 0}, 1, true case "gtrapprox": // GREATER-THAN OR APPROXIMATE - return rune(0x2a86), true + return {'\u2a86', 0}, 1, true case "gtrarr": // GREATER-THAN ABOVE RIGHTWARDS ARROW - return rune(0x2978), true + return {'\u2978', 0}, 1, true case "gtrdot": // GREATER-THAN WITH DOT - return rune(0x22d7), true + return {'\u22d7', 0}, 1, true case "gtreqless": // GREATER-THAN EQUAL TO OR LESS-THAN - return rune(0x22db), true + return {'\u22db', 0}, 1, true case "gtreqqless": // GREATER-THAN ABOVE DOUBLE-LINE EQUAL ABOVE LESS-THAN - return rune(0x2a8c), true + return {'\u2a8c', 0}, 1, true case "gtrless": // GREATER-THAN OR LESS-THAN - return rune(0x2277), true + return {'\u2277', 0}, 1, true case "gtrpar": // SPHERICAL ANGLE OPENING LEFT - return rune(0x29a0), true + return {'\u29a0', 0}, 1, true case "gtrsim": // GREATER-THAN OR EQUIVALENT TO - return rune(0x2273), true + return {'\u2273', 0}, 1, true case "gvertneqq": // GREATER-THAN BUT NOT EQUAL TO - with vertical stroke - return rune(0x2269), true + return {'\u2269', '\ufe00'}, 2, true case "gvnE": // GREATER-THAN BUT NOT EQUAL TO - with vertical stroke - return rune(0x2269), true + return {'\u2269', '\ufe00'}, 2, true } case 'h': switch name { case "hArr": // LEFT RIGHT DOUBLE ARROW - return rune(0x21d4), true + return {'\u21d4', 0}, 1, true case "hairsp": // HAIR SPACE - return rune(0x200a), true + return {'\u200a', 0}, 1, true case "half": // VULGAR FRACTION ONE HALF - return rune(0xbd), true + return {'½', 0}, 1, true case "hamilt": // SCRIPT CAPITAL H - return rune(0x210b), true + return {'\u210b', 0}, 1, true case "hardcy": // CYRILLIC SMALL LETTER HARD SIGN - return rune(0x044a), true + return {'\u044a', 0}, 1, true case "harr": // LEFT RIGHT ARROW - return rune(0x2194), true + return {'\u2194', 0}, 1, true case "harrcir": // LEFT RIGHT ARROW THROUGH SMALL CIRCLE - return rune(0x2948), true + return {'\u2948', 0}, 1, true case "harrw": // LEFT RIGHT WAVE ARROW - return rune(0x21ad), true + return {'\u21ad', 0}, 1, true case "hbar": // PLANCK CONSTANT OVER TWO PI - return rune(0x210f), true + return {'\u210f', 0}, 1, true case "hcirc": // LATIN SMALL LETTER H WITH CIRCUMFLEX - return rune(0x0125), true + return {'\u0125', 0}, 1, true case "hearts": // BLACK HEART SUIT - return rune(0x2665), true + return {'\u2665', 0}, 1, true case "heartsuit": // BLACK HEART SUIT - return rune(0x2665), true + return {'\u2665', 0}, 1, true case "hellip": // HORIZONTAL ELLIPSIS - return rune(0x2026), true + return {'\u2026', 0}, 1, true case "hercon": // HERMITIAN CONJUGATE MATRIX - return rune(0x22b9), true + return {'\u22b9', 0}, 1, true case "hfr": // MATHEMATICAL FRAKTUR SMALL H - return rune(0x01d525), true + return {'\U0001d525', 0}, 1, true case "hksearow": // SOUTH EAST ARROW WITH HOOK - return rune(0x2925), true + return {'\u2925', 0}, 1, true case "hkswarow": // SOUTH WEST ARROW WITH HOOK - return rune(0x2926), true + return {'\u2926', 0}, 1, true case "hoarr": // LEFT RIGHT OPEN-HEADED ARROW - return rune(0x21ff), true + return {'\u21ff', 0}, 1, true case "homtht": // HOMOTHETIC - return rune(0x223b), true + return {'\u223b', 0}, 1, true case "hookleftarrow": // LEFTWARDS ARROW WITH HOOK - return rune(0x21a9), true + return {'\u21a9', 0}, 1, true case "hookrightarrow": // RIGHTWARDS ARROW WITH HOOK - return rune(0x21aa), true + return {'\u21aa', 0}, 1, true case "hopf": // MATHEMATICAL DOUBLE-STRUCK SMALL H - return rune(0x01d559), true + return {'\U0001d559', 0}, 1, true case "horbar": // HORIZONTAL BAR - return rune(0x2015), true + return {'\u2015', 0}, 1, true case "hrglass": // WHITE HOURGLASS - return rune(0x29d6), true + return {'\u29d6', 0}, 1, true case "hscr": // MATHEMATICAL SCRIPT SMALL H - return rune(0x01d4bd), true + return {'\U0001d4bd', 0}, 1, true case "hslash": // PLANCK CONSTANT OVER TWO PI - return rune(0x210f), true + return {'\u210f', 0}, 1, true case "hstrok": // LATIN SMALL LETTER H WITH STROKE - return rune(0x0127), true + return {'\u0127', 0}, 1, true case "htimes": // VECTOR OR CROSS PRODUCT - return rune(0x2a2f), true + return {'\u2a2f', 0}, 1, true case "hybull": // HYPHEN BULLET - return rune(0x2043), true + return {'\u2043', 0}, 1, true case "hyphen": // HYPHEN - return rune(0x2010), true + return {'\u2010', 0}, 1, true } case 'i': switch name { case "iacgr": // GREEK SMALL LETTER IOTA WITH TONOS - return rune(0x03af), true + return {'\u03af', 0}, 1, true case "iacute": // LATIN SMALL LETTER I WITH ACUTE - return rune(0xed), true + return {'í', 0}, 1, true case "ic": // INVISIBLE SEPARATOR - return rune(0x2063), true + return {'\u2063', 0}, 1, true case "icirc": // LATIN SMALL LETTER I WITH CIRCUMFLEX - return rune(0xee), true + return {'î', 0}, 1, true case "icy": // CYRILLIC SMALL LETTER I - return rune(0x0438), true + return {'\u0438', 0}, 1, true case "idiagr": // GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS - return rune(0x0390), true + return {'\u0390', 0}, 1, true case "idigr": // GREEK SMALL LETTER IOTA WITH DIALYTIKA - return rune(0x03ca), true + return {'\u03ca', 0}, 1, true case "iecy": // CYRILLIC SMALL LETTER IE - return rune(0x0435), true + return {'\u0435', 0}, 1, true case "iexcl": // INVERTED EXCLAMATION MARK - return rune(0xa1), true + return {'¡', 0}, 1, true case "iff": // LEFT RIGHT DOUBLE ARROW - return rune(0x21d4), true + return {'\u21d4', 0}, 1, true case "ifr": // MATHEMATICAL FRAKTUR SMALL I - return rune(0x01d526), true + return {'\U0001d526', 0}, 1, true case "igr": // GREEK SMALL LETTER IOTA - return rune(0x03b9), true + return {'\u03b9', 0}, 1, true case "igrave": // LATIN SMALL LETTER I WITH GRAVE - return rune(0xec), true + return {'ì', 0}, 1, true case "ii": // DOUBLE-STRUCK ITALIC SMALL I - return rune(0x2148), true + return {'\u2148', 0}, 1, true case "iiiint": // QUADRUPLE INTEGRAL OPERATOR - return rune(0x2a0c), true + return {'\u2a0c', 0}, 1, true case "iiint": // TRIPLE INTEGRAL - return rune(0x222d), true + return {'\u222d', 0}, 1, true case "iinfin": // INCOMPLETE INFINITY - return rune(0x29dc), true + return {'\u29dc', 0}, 1, true case "iiota": // TURNED GREEK SMALL LETTER IOTA - return rune(0x2129), true + return {'\u2129', 0}, 1, true case "ijlig": // LATIN SMALL LIGATURE IJ - return rune(0x0133), true + return {'\u0133', 0}, 1, true case "imacr": // LATIN SMALL LETTER I WITH MACRON - return rune(0x012b), true + return {'\u012b', 0}, 1, true case "image": // BLACK-LETTER CAPITAL I - return rune(0x2111), true + return {'\u2111', 0}, 1, true case "imagline": // SCRIPT CAPITAL I - return rune(0x2110), true + return {'\u2110', 0}, 1, true case "imagpart": // BLACK-LETTER CAPITAL I - return rune(0x2111), true + return {'\u2111', 0}, 1, true case "imath": // LATIN SMALL LETTER DOTLESS I - return rune(0x0131), true + return {'\u0131', 0}, 1, true case "imof": // IMAGE OF - return rune(0x22b7), true + return {'\u22b7', 0}, 1, true case "imped": // LATIN CAPITAL LETTER Z WITH STROKE - return rune(0x01b5), true + return {'\u01b5', 0}, 1, true case "in": // ELEMENT OF - return rune(0x2208), true + return {'\u2208', 0}, 1, true case "incare": // CARE OF - return rune(0x2105), true + return {'\u2105', 0}, 1, true case "infin": // INFINITY - return rune(0x221e), true + return {'\u221e', 0}, 1, true case "infintie": // TIE OVER INFINITY - return rune(0x29dd), true + return {'\u29dd', 0}, 1, true case "inodot": // LATIN SMALL LETTER DOTLESS I - return rune(0x0131), true + return {'\u0131', 0}, 1, true case "int": // INTEGRAL - return rune(0x222b), true + return {'\u222b', 0}, 1, true case "intcal": // INTERCALATE - return rune(0x22ba), true + return {'\u22ba', 0}, 1, true case "integers": // DOUBLE-STRUCK CAPITAL Z - return rune(0x2124), true + return {'\u2124', 0}, 1, true case "intercal": // INTERCALATE - return rune(0x22ba), true + return {'\u22ba', 0}, 1, true case "intlarhk": // INTEGRAL WITH LEFTWARDS ARROW WITH HOOK - return rune(0x2a17), true + return {'\u2a17', 0}, 1, true case "intprod": // INTERIOR PRODUCT - return rune(0x2a3c), true + return {'\u2a3c', 0}, 1, true case "iocy": // CYRILLIC SMALL LETTER IO - return rune(0x0451), true + return {'\u0451', 0}, 1, true case "iogon": // LATIN SMALL LETTER I WITH OGONEK - return rune(0x012f), true + return {'\u012f', 0}, 1, true case "iopf": // MATHEMATICAL DOUBLE-STRUCK SMALL I - return rune(0x01d55a), true + return {'\U0001d55a', 0}, 1, true case "iota": // GREEK SMALL LETTER IOTA - return rune(0x03b9), true + return {'\u03b9', 0}, 1, true case "iprod": // INTERIOR PRODUCT - return rune(0x2a3c), true + return {'\u2a3c', 0}, 1, true case "iprodr": // RIGHTHAND INTERIOR PRODUCT - return rune(0x2a3d), true + return {'\u2a3d', 0}, 1, true case "iquest": // INVERTED QUESTION MARK - return rune(0xbf), true + return {'¿', 0}, 1, true case "iscr": // MATHEMATICAL SCRIPT SMALL I - return rune(0x01d4be), true + return {'\U0001d4be', 0}, 1, true case "isin": // ELEMENT OF - return rune(0x2208), true + return {'\u2208', 0}, 1, true case "isinE": // ELEMENT OF WITH TWO HORIZONTAL STROKES - return rune(0x22f9), true + return {'\u22f9', 0}, 1, true case "isindot": // ELEMENT OF WITH DOT ABOVE - return rune(0x22f5), true + return {'\u22f5', 0}, 1, true case "isins": // SMALL ELEMENT OF WITH VERTICAL BAR AT END OF HORIZONTAL STROKE - return rune(0x22f4), true + return {'\u22f4', 0}, 1, true case "isinsv": // ELEMENT OF WITH VERTICAL BAR AT END OF HORIZONTAL STROKE - return rune(0x22f3), true + return {'\u22f3', 0}, 1, true case "isinv": // ELEMENT OF - return rune(0x2208), true + return {'\u2208', 0}, 1, true case "isinvb": // ELEMENT OF WITH UNDERBAR - return rune(0x22f8), true + return {'\u22f8', 0}, 1, true case "it": // INVISIBLE TIMES - return rune(0x2062), true + return {'\u2062', 0}, 1, true case "itilde": // LATIN SMALL LETTER I WITH TILDE - return rune(0x0129), true + return {'\u0129', 0}, 1, true case "iukcy": // CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I - return rune(0x0456), true + return {'\u0456', 0}, 1, true case "iuml": // LATIN SMALL LETTER I WITH DIAERESIS - return rune(0xef), true + return {'ï', 0}, 1, true } case 'j': switch name { case "jcirc": // LATIN SMALL LETTER J WITH CIRCUMFLEX - return rune(0x0135), true + return {'\u0135', 0}, 1, true case "jcy": // CYRILLIC SMALL LETTER SHORT I - return rune(0x0439), true + return {'\u0439', 0}, 1, true case "jfr": // MATHEMATICAL FRAKTUR SMALL J - return rune(0x01d527), true + return {'\U0001d527', 0}, 1, true case "jmath": // LATIN SMALL LETTER DOTLESS J - return rune(0x0237), true + return {'\u0237', 0}, 1, true case "jnodot": // LATIN SMALL LETTER DOTLESS J - return rune(0x0237), true + return {'\u0237', 0}, 1, true case "jopf": // MATHEMATICAL DOUBLE-STRUCK SMALL J - return rune(0x01d55b), true + return {'\U0001d55b', 0}, 1, true case "jscr": // MATHEMATICAL SCRIPT SMALL J - return rune(0x01d4bf), true + return {'\U0001d4bf', 0}, 1, true case "jsercy": // CYRILLIC SMALL LETTER JE - return rune(0x0458), true + return {'\u0458', 0}, 1, true case "jukcy": // CYRILLIC SMALL LETTER UKRAINIAN IE - return rune(0x0454), true + return {'\u0454', 0}, 1, true } case 'k': switch name { case "kappa": // GREEK SMALL LETTER KAPPA - return rune(0x03ba), true + return {'\u03ba', 0}, 1, true case "kappav": // GREEK KAPPA SYMBOL - return rune(0x03f0), true + return {'\u03f0', 0}, 1, true case "kcedil": // LATIN SMALL LETTER K WITH CEDILLA - return rune(0x0137), true + return {'\u0137', 0}, 1, true case "kcy": // CYRILLIC SMALL LETTER KA - return rune(0x043a), true + return {'\u043a', 0}, 1, true case "kfr": // MATHEMATICAL FRAKTUR SMALL K - return rune(0x01d528), true + return {'\U0001d528', 0}, 1, true case "kgr": // GREEK SMALL LETTER KAPPA - return rune(0x03ba), true + return {'\u03ba', 0}, 1, true case "kgreen": // LATIN SMALL LETTER KRA - return rune(0x0138), true + return {'\u0138', 0}, 1, true case "khcy": // CYRILLIC SMALL LETTER HA - return rune(0x0445), true + return {'\u0445', 0}, 1, true case "khgr": // GREEK SMALL LETTER CHI - return rune(0x03c7), true + return {'\u03c7', 0}, 1, true case "kjcy": // CYRILLIC SMALL LETTER KJE - return rune(0x045c), true + return {'\u045c', 0}, 1, true case "kopf": // MATHEMATICAL DOUBLE-STRUCK SMALL K - return rune(0x01d55c), true + return {'\U0001d55c', 0}, 1, true case "koppa": // GREEK LETTER KOPPA - return rune(0x03de), true + return {'\u03de', 0}, 1, true case "kscr": // MATHEMATICAL SCRIPT SMALL K - return rune(0x01d4c0), true + return {'\U0001d4c0', 0}, 1, true } case 'l': switch name { case "lAarr": // LEFTWARDS TRIPLE ARROW - return rune(0x21da), true + return {'\u21da', 0}, 1, true case "lArr": // LEFTWARDS DOUBLE ARROW - return rune(0x21d0), true + return {'\u21d0', 0}, 1, true case "lAtail": // LEFTWARDS DOUBLE ARROW-TAIL - return rune(0x291b), true + return {'\u291b', 0}, 1, true case "lBarr": // LEFTWARDS TRIPLE DASH ARROW - return rune(0x290e), true + return {'\u290e', 0}, 1, true case "lE": // LESS-THAN OVER EQUAL TO - return rune(0x2266), true + return {'\u2266', 0}, 1, true case "lEg": // LESS-THAN ABOVE DOUBLE-LINE EQUAL ABOVE GREATER-THAN - return rune(0x2a8b), true + return {'\u2a8b', 0}, 1, true case "lHar": // LEFTWARDS HARPOON WITH BARB UP ABOVE LEFTWARDS HARPOON WITH BARB DOWN - return rune(0x2962), true + return {'\u2962', 0}, 1, true case "lacute": // LATIN SMALL LETTER L WITH ACUTE - return rune(0x013a), true + return {'\u013a', 0}, 1, true case "laemptyv": // EMPTY SET WITH LEFT ARROW ABOVE - return rune(0x29b4), true + return {'\u29b4', 0}, 1, true case "lagran": // SCRIPT CAPITAL L - return rune(0x2112), true + return {'\u2112', 0}, 1, true case "lambda": // GREEK SMALL LETTER LAMDA - return rune(0x03bb), true + return {'\u03bb', 0}, 1, true case "lang": // MATHEMATICAL LEFT ANGLE BRACKET - return rune(0x27e8), true + return {'\u27e8', 0}, 1, true case "langd": // LEFT ANGLE BRACKET WITH DOT - return rune(0x2991), true + return {'\u2991', 0}, 1, true case "langle": // MATHEMATICAL LEFT ANGLE BRACKET - return rune(0x27e8), true + return {'\u27e8', 0}, 1, true case "lap": // LESS-THAN OR APPROXIMATE - return rune(0x2a85), true + return {'\u2a85', 0}, 1, true case "laquo": // LEFT-POINTING DOUBLE ANGLE QUOTATION MARK - return rune(0xab), true + return {'«', 0}, 1, true case "larr": // LEFTWARDS ARROW - return rune(0x2190), true + return {'\u2190', 0}, 1, true case "larr2": // LEFTWARDS PAIRED ARROWS - return rune(0x21c7), true + return {'\u21c7', 0}, 1, true case "larrb": // LEFTWARDS ARROW TO BAR - return rune(0x21e4), true + return {'\u21e4', 0}, 1, true case "larrbfs": // LEFTWARDS ARROW FROM BAR TO BLACK DIAMOND - return rune(0x291f), true + return {'\u291f', 0}, 1, true case "larrfs": // LEFTWARDS ARROW TO BLACK DIAMOND - return rune(0x291d), true + return {'\u291d', 0}, 1, true case "larrhk": // LEFTWARDS ARROW WITH HOOK - return rune(0x21a9), true + return {'\u21a9', 0}, 1, true case "larrlp": // LEFTWARDS ARROW WITH LOOP - return rune(0x21ab), true + return {'\u21ab', 0}, 1, true case "larrpl": // LEFT-SIDE ARC ANTICLOCKWISE ARROW - return rune(0x2939), true + return {'\u2939', 0}, 1, true case "larrsim": // LEFTWARDS ARROW ABOVE TILDE OPERATOR - return rune(0x2973), true + return {'\u2973', 0}, 1, true case "larrtl": // LEFTWARDS ARROW WITH TAIL - return rune(0x21a2), true + return {'\u21a2', 0}, 1, true case "lat": // LARGER THAN - return rune(0x2aab), true + return {'\u2aab', 0}, 1, true case "latail": // LEFTWARDS ARROW-TAIL - return rune(0x2919), true + return {'\u2919', 0}, 1, true case "late": // LARGER THAN OR EQUAL TO - return rune(0x2aad), true + return {'\u2aad', 0}, 1, true case "lates": // LARGER THAN OR slanted EQUAL - return rune(0x2aad), true + return {'\u2aad', '\ufe00'}, 2, true case "lbarr": // LEFTWARDS DOUBLE DASH ARROW - return rune(0x290c), true + return {'\u290c', 0}, 1, true case "lbbrk": // LIGHT LEFT TORTOISE SHELL BRACKET ORNAMENT - return rune(0x2772), true + return {'\u2772', 0}, 1, true case "lbrace": // LEFT CURLY BRACKET - return rune(0x7b), true + return {'{', 0}, 1, true case "lbrack": // LEFT SQUARE BRACKET - return rune(0x5b), true + return {'[', 0}, 1, true case "lbrke": // LEFT SQUARE BRACKET WITH UNDERBAR - return rune(0x298b), true + return {'\u298b', 0}, 1, true case "lbrksld": // LEFT SQUARE BRACKET WITH TICK IN BOTTOM CORNER - return rune(0x298f), true + return {'\u298f', 0}, 1, true case "lbrkslu": // LEFT SQUARE BRACKET WITH TICK IN TOP CORNER - return rune(0x298d), true + return {'\u298d', 0}, 1, true case "lcaron": // LATIN SMALL LETTER L WITH CARON - return rune(0x013e), true + return {'\u013e', 0}, 1, true case "lcedil": // LATIN SMALL LETTER L WITH CEDILLA - return rune(0x013c), true + return {'\u013c', 0}, 1, true case "lceil": // LEFT CEILING - return rune(0x2308), true + return {'\u2308', 0}, 1, true case "lcub": // LEFT CURLY BRACKET - return rune(0x7b), true + return {'{', 0}, 1, true case "lcy": // CYRILLIC SMALL LETTER EL - return rune(0x043b), true + return {'\u043b', 0}, 1, true case "ldca": // ARROW POINTING DOWNWARDS THEN CURVING LEFTWARDS - return rune(0x2936), true + return {'\u2936', 0}, 1, true case "ldharb": // LEFTWARDS HARPOON WITH BARB DOWN TO BAR - return rune(0x2956), true + return {'\u2956', 0}, 1, true case "ldot": // LESS-THAN WITH DOT - return rune(0x22d6), true + return {'\u22d6', 0}, 1, true case "ldquo": // LEFT DOUBLE QUOTATION MARK - return rune(0x201c), true + return {'\u201c', 0}, 1, true case "ldquor": // DOUBLE LOW-9 QUOTATION MARK - return rune(0x201e), true + return {'\u201e', 0}, 1, true case "ldrdhar": // LEFTWARDS HARPOON WITH BARB DOWN ABOVE RIGHTWARDS HARPOON WITH BARB DOWN - return rune(0x2967), true + return {'\u2967', 0}, 1, true case "ldrdshar": // LEFT BARB DOWN RIGHT BARB DOWN HARPOON - return rune(0x2950), true + return {'\u2950', 0}, 1, true case "ldrushar": // LEFT BARB DOWN RIGHT BARB UP HARPOON - return rune(0x294b), true + return {'\u294b', 0}, 1, true case "ldsh": // DOWNWARDS ARROW WITH TIP LEFTWARDS - return rune(0x21b2), true + return {'\u21b2', 0}, 1, true case "le": // LESS-THAN OR EQUAL TO - return rune(0x2264), true + return {'\u2264', 0}, 1, true case "leftarrow": // LEFTWARDS ARROW - return rune(0x2190), true + return {'\u2190', 0}, 1, true case "leftarrowtail": // LEFTWARDS ARROW WITH TAIL - return rune(0x21a2), true + return {'\u21a2', 0}, 1, true case "leftharpoondown": // LEFTWARDS HARPOON WITH BARB DOWNWARDS - return rune(0x21bd), true + return {'\u21bd', 0}, 1, true case "leftharpoonup": // LEFTWARDS HARPOON WITH BARB UPWARDS - return rune(0x21bc), true + return {'\u21bc', 0}, 1, true case "leftleftarrows": // LEFTWARDS PAIRED ARROWS - return rune(0x21c7), true + return {'\u21c7', 0}, 1, true case "leftrightarrow": // LEFT RIGHT ARROW - return rune(0x2194), true + return {'\u2194', 0}, 1, true case "leftrightarrows": // LEFTWARDS ARROW OVER RIGHTWARDS ARROW - return rune(0x21c6), true + return {'\u21c6', 0}, 1, true case "leftrightharpoons": // LEFTWARDS HARPOON OVER RIGHTWARDS HARPOON - return rune(0x21cb), true + return {'\u21cb', 0}, 1, true case "leftrightsquigarrow": // LEFT RIGHT WAVE ARROW - return rune(0x21ad), true + return {'\u21ad', 0}, 1, true case "leftthreetimes": // LEFT SEMIDIRECT PRODUCT - return rune(0x22cb), true + return {'\u22cb', 0}, 1, true case "leg": // LESS-THAN EQUAL TO OR GREATER-THAN - return rune(0x22da), true + return {'\u22da', 0}, 1, true case "leq": // LESS-THAN OR EQUAL TO - return rune(0x2264), true + return {'\u2264', 0}, 1, true case "leqq": // LESS-THAN OVER EQUAL TO - return rune(0x2266), true + return {'\u2266', 0}, 1, true case "leqslant": // LESS-THAN OR SLANTED EQUAL TO - return rune(0x2a7d), true + return {'\u2a7d', 0}, 1, true case "les": // LESS-THAN OR SLANTED EQUAL TO - return rune(0x2a7d), true + return {'\u2a7d', 0}, 1, true case "lescc": // LESS-THAN CLOSED BY CURVE ABOVE SLANTED EQUAL - return rune(0x2aa8), true + return {'\u2aa8', 0}, 1, true case "lesdot": // LESS-THAN OR SLANTED EQUAL TO WITH DOT INSIDE - return rune(0x2a7f), true + return {'\u2a7f', 0}, 1, true case "lesdoto": // LESS-THAN OR SLANTED EQUAL TO WITH DOT ABOVE - return rune(0x2a81), true + return {'\u2a81', 0}, 1, true case "lesdotor": // LESS-THAN OR SLANTED EQUAL TO WITH DOT ABOVE RIGHT - return rune(0x2a83), true + return {'\u2a83', 0}, 1, true case "lesg": // LESS-THAN slanted EQUAL TO OR GREATER-THAN - return rune(0x22da), true + return {'\u22da', '\ufe00'}, 2, true case "lesges": // LESS-THAN ABOVE SLANTED EQUAL ABOVE GREATER-THAN ABOVE SLANTED EQUAL - return rune(0x2a93), true + return {'\u2a93', 0}, 1, true case "lessapprox": // LESS-THAN OR APPROXIMATE - return rune(0x2a85), true + return {'\u2a85', 0}, 1, true case "lessdot": // LESS-THAN WITH DOT - return rune(0x22d6), true + return {'\u22d6', 0}, 1, true case "lesseqgtr": // LESS-THAN EQUAL TO OR GREATER-THAN - return rune(0x22da), true + return {'\u22da', 0}, 1, true case "lesseqqgtr": // LESS-THAN ABOVE DOUBLE-LINE EQUAL ABOVE GREATER-THAN - return rune(0x2a8b), true + return {'\u2a8b', 0}, 1, true case "lessgtr": // LESS-THAN OR GREATER-THAN - return rune(0x2276), true + return {'\u2276', 0}, 1, true case "lesssim": // LESS-THAN OR EQUIVALENT TO - return rune(0x2272), true + return {'\u2272', 0}, 1, true case "lfbowtie": // BOWTIE WITH LEFT HALF BLACK - return rune(0x29d1), true + return {'\u29d1', 0}, 1, true case "lfisht": // LEFT FISH TAIL - return rune(0x297c), true + return {'\u297c', 0}, 1, true case "lfloor": // LEFT FLOOR - return rune(0x230a), true + return {'\u230a', 0}, 1, true case "lfr": // MATHEMATICAL FRAKTUR SMALL L - return rune(0x01d529), true + return {'\U0001d529', 0}, 1, true case "lftimes": // TIMES WITH LEFT HALF BLACK - return rune(0x29d4), true + return {'\u29d4', 0}, 1, true case "lg": // LESS-THAN OR GREATER-THAN - return rune(0x2276), true + return {'\u2276', 0}, 1, true case "lgE": // LESS-THAN ABOVE GREATER-THAN ABOVE DOUBLE-LINE EQUAL - return rune(0x2a91), true + return {'\u2a91', 0}, 1, true case "lgr": // GREEK SMALL LETTER LAMDA - return rune(0x03bb), true + return {'\u03bb', 0}, 1, true case "lhard": // LEFTWARDS HARPOON WITH BARB DOWNWARDS - return rune(0x21bd), true + return {'\u21bd', 0}, 1, true case "lharu": // LEFTWARDS HARPOON WITH BARB UPWARDS - return rune(0x21bc), true + return {'\u21bc', 0}, 1, true case "lharul": // LEFTWARDS HARPOON WITH BARB UP ABOVE LONG DASH - return rune(0x296a), true + return {'\u296a', 0}, 1, true case "lhblk": // LOWER HALF BLOCK - return rune(0x2584), true + return {'\u2584', 0}, 1, true case "ljcy": // CYRILLIC SMALL LETTER LJE - return rune(0x0459), true + return {'\u0459', 0}, 1, true case "ll": // MUCH LESS-THAN - return rune(0x226a), true + return {'\u226a', 0}, 1, true case "llarr": // LEFTWARDS PAIRED ARROWS - return rune(0x21c7), true + return {'\u21c7', 0}, 1, true case "llcorner": // BOTTOM LEFT CORNER - return rune(0x231e), true + return {'\u231e', 0}, 1, true case "llhard": // LEFTWARDS HARPOON WITH BARB DOWN BELOW LONG DASH - return rune(0x296b), true + return {'\u296b', 0}, 1, true case "lltri": // LOWER LEFT TRIANGLE - return rune(0x25fa), true + return {'\u25fa', 0}, 1, true case "lltrif": // BLACK LOWER LEFT TRIANGLE - return rune(0x25e3), true + return {'\u25e3', 0}, 1, true case "lmidot": // LATIN SMALL LETTER L WITH MIDDLE DOT - return rune(0x0140), true + return {'\u0140', 0}, 1, true case "lmoust": // UPPER LEFT OR LOWER RIGHT CURLY BRACKET SECTION - return rune(0x23b0), true + return {'\u23b0', 0}, 1, true case "lmoustache": // UPPER LEFT OR LOWER RIGHT CURLY BRACKET SECTION - return rune(0x23b0), true + return {'\u23b0', 0}, 1, true case "lnE": // LESS-THAN BUT NOT EQUAL TO - return rune(0x2268), true + return {'\u2268', 0}, 1, true case "lnap": // LESS-THAN AND NOT APPROXIMATE - return rune(0x2a89), true + return {'\u2a89', 0}, 1, true case "lnapprox": // LESS-THAN AND NOT APPROXIMATE - return rune(0x2a89), true + return {'\u2a89', 0}, 1, true case "lne": // LESS-THAN AND SINGLE-LINE NOT EQUAL TO - return rune(0x2a87), true + return {'\u2a87', 0}, 1, true case "lneq": // LESS-THAN AND SINGLE-LINE NOT EQUAL TO - return rune(0x2a87), true + return {'\u2a87', 0}, 1, true case "lneqq": // LESS-THAN BUT NOT EQUAL TO - return rune(0x2268), true + return {'\u2268', 0}, 1, true case "lnsim": // LESS-THAN BUT NOT EQUIVALENT TO - return rune(0x22e6), true + return {'\u22e6', 0}, 1, true case "loang": // MATHEMATICAL LEFT WHITE TORTOISE SHELL BRACKET - return rune(0x27ec), true + return {'\u27ec', 0}, 1, true case "loarr": // LEFTWARDS OPEN-HEADED ARROW - return rune(0x21fd), true + return {'\u21fd', 0}, 1, true case "lobrk": // MATHEMATICAL LEFT WHITE SQUARE BRACKET - return rune(0x27e6), true + return {'\u27e6', 0}, 1, true case "locub": // LEFT WHITE CURLY BRACKET - return rune(0x2983), true + return {'\u2983', 0}, 1, true case "longleftarrow": // LONG LEFTWARDS ARROW - return rune(0x27f5), true + return {'\u27f5', 0}, 1, true case "longleftrightarrow": // LONG LEFT RIGHT ARROW - return rune(0x27f7), true + return {'\u27f7', 0}, 1, true case "longmapsto": // LONG RIGHTWARDS ARROW FROM BAR - return rune(0x27fc), true + return {'\u27fc', 0}, 1, true case "longrightarrow": // LONG RIGHTWARDS ARROW - return rune(0x27f6), true + return {'\u27f6', 0}, 1, true case "looparrowleft": // LEFTWARDS ARROW WITH LOOP - return rune(0x21ab), true + return {'\u21ab', 0}, 1, true case "looparrowright": // RIGHTWARDS ARROW WITH LOOP - return rune(0x21ac), true + return {'\u21ac', 0}, 1, true case "lopar": // LEFT WHITE PARENTHESIS - return rune(0x2985), true + return {'\u2985', 0}, 1, true case "lopf": // MATHEMATICAL DOUBLE-STRUCK SMALL L - return rune(0x01d55d), true + return {'\U0001d55d', 0}, 1, true case "loplus": // PLUS SIGN IN LEFT HALF CIRCLE - return rune(0x2a2d), true + return {'\u2a2d', 0}, 1, true case "lotimes": // MULTIPLICATION SIGN IN LEFT HALF CIRCLE - return rune(0x2a34), true + return {'\u2a34', 0}, 1, true case "lowast": // LOW ASTERISK - return rune(0x204e), true + return {'\u204e', 0}, 1, true case "lowbar": // LOW LINE - return rune(0x5f), true + return {'_', 0}, 1, true case "lowint": // INTEGRAL WITH UNDERBAR - return rune(0x2a1c), true + return {'\u2a1c', 0}, 1, true case "loz": // LOZENGE - return rune(0x25ca), true + return {'\u25ca', 0}, 1, true case "lozenge": // LOZENGE - return rune(0x25ca), true + return {'\u25ca', 0}, 1, true case "lozf": // BLACK LOZENGE - return rune(0x29eb), true + return {'\u29eb', 0}, 1, true case "lpar": // LEFT PARENTHESIS - return rune(0x28), true + return {'(', 0}, 1, true case "lpargt": // SPHERICAL ANGLE OPENING LEFT - return rune(0x29a0), true + return {'\u29a0', 0}, 1, true case "lparlt": // LEFT ARC LESS-THAN BRACKET - return rune(0x2993), true + return {'\u2993', 0}, 1, true case "lrarr": // LEFTWARDS ARROW OVER RIGHTWARDS ARROW - return rune(0x21c6), true + return {'\u21c6', 0}, 1, true case "lrarr2": // LEFTWARDS ARROW OVER RIGHTWARDS ARROW - return rune(0x21c6), true + return {'\u21c6', 0}, 1, true case "lrcorner": // BOTTOM RIGHT CORNER - return rune(0x231f), true + return {'\u231f', 0}, 1, true case "lrhar": // LEFTWARDS HARPOON OVER RIGHTWARDS HARPOON - return rune(0x21cb), true + return {'\u21cb', 0}, 1, true case "lrhar2": // LEFTWARDS HARPOON OVER RIGHTWARDS HARPOON - return rune(0x21cb), true + return {'\u21cb', 0}, 1, true case "lrhard": // RIGHTWARDS HARPOON WITH BARB DOWN BELOW LONG DASH - return rune(0x296d), true + return {'\u296d', 0}, 1, true case "lrm": // LEFT-TO-RIGHT MARK - return rune(0x200e), true + return {'\u200e', 0}, 1, true case "lrtri": // RIGHT TRIANGLE - return rune(0x22bf), true + return {'\u22bf', 0}, 1, true case "lsaquo": // SINGLE LEFT-POINTING ANGLE QUOTATION MARK - return rune(0x2039), true + return {'\u2039', 0}, 1, true case "lscr": // MATHEMATICAL SCRIPT SMALL L - return rune(0x01d4c1), true + return {'\U0001d4c1', 0}, 1, true case "lsh": // UPWARDS ARROW WITH TIP LEFTWARDS - return rune(0x21b0), true + return {'\u21b0', 0}, 1, true case "lsim": // LESS-THAN OR EQUIVALENT TO - return rune(0x2272), true + return {'\u2272', 0}, 1, true case "lsime": // LESS-THAN ABOVE SIMILAR OR EQUAL - return rune(0x2a8d), true + return {'\u2a8d', 0}, 1, true case "lsimg": // LESS-THAN ABOVE SIMILAR ABOVE GREATER-THAN - return rune(0x2a8f), true + return {'\u2a8f', 0}, 1, true case "lsqb": // LEFT SQUARE BRACKET - return rune(0x5b), true + return {'[', 0}, 1, true case "lsquo": // LEFT SINGLE QUOTATION MARK - return rune(0x2018), true + return {'\u2018', 0}, 1, true case "lsquor": // SINGLE LOW-9 QUOTATION MARK - return rune(0x201a), true + return {'\u201a', 0}, 1, true case "lstrok": // LATIN SMALL LETTER L WITH STROKE - return rune(0x0142), true + return {'\u0142', 0}, 1, true case "lt": // LESS-THAN SIGN - return rune(0x3c), true + return {'<', 0}, 1, true case "ltcc": // LESS-THAN CLOSED BY CURVE - return rune(0x2aa6), true + return {'\u2aa6', 0}, 1, true case "ltcir": // LESS-THAN WITH CIRCLE INSIDE - return rune(0x2a79), true + return {'\u2a79', 0}, 1, true case "ltdot": // LESS-THAN WITH DOT - return rune(0x22d6), true + return {'\u22d6', 0}, 1, true case "lthree": // LEFT SEMIDIRECT PRODUCT - return rune(0x22cb), true + return {'\u22cb', 0}, 1, true case "ltimes": // LEFT NORMAL FACTOR SEMIDIRECT PRODUCT - return rune(0x22c9), true + return {'\u22c9', 0}, 1, true case "ltlarr": // LESS-THAN ABOVE LEFTWARDS ARROW - return rune(0x2976), true + return {'\u2976', 0}, 1, true case "ltquest": // LESS-THAN WITH QUESTION MARK ABOVE - return rune(0x2a7b), true + return {'\u2a7b', 0}, 1, true case "ltrPar": // DOUBLE RIGHT ARC LESS-THAN BRACKET - return rune(0x2996), true + return {'\u2996', 0}, 1, true case "ltri": // WHITE LEFT-POINTING SMALL TRIANGLE - return rune(0x25c3), true + return {'\u25c3', 0}, 1, true case "ltrie": // NORMAL SUBGROUP OF OR EQUAL TO - return rune(0x22b4), true + return {'\u22b4', 0}, 1, true case "ltrif": // BLACK LEFT-POINTING SMALL TRIANGLE - return rune(0x25c2), true + return {'\u25c2', 0}, 1, true case "ltrivb": // LEFT TRIANGLE BESIDE VERTICAL BAR - return rune(0x29cf), true + return {'\u29cf', 0}, 1, true case "luharb": // LEFTWARDS HARPOON WITH BARB UP TO BAR - return rune(0x2952), true + return {'\u2952', 0}, 1, true case "lurdshar": // LEFT BARB UP RIGHT BARB DOWN HARPOON - return rune(0x294a), true + return {'\u294a', 0}, 1, true case "luruhar": // LEFTWARDS HARPOON WITH BARB UP ABOVE RIGHTWARDS HARPOON WITH BARB UP - return rune(0x2966), true + return {'\u2966', 0}, 1, true case "lurushar": // LEFT BARB UP RIGHT BARB UP HARPOON - return rune(0x294e), true + return {'\u294e', 0}, 1, true case "lvertneqq": // LESS-THAN BUT NOT EQUAL TO - with vertical stroke - return rune(0x2268), true + return {'\u2268', '\ufe00'}, 2, true case "lvnE": // LESS-THAN BUT NOT EQUAL TO - with vertical stroke - return rune(0x2268), true + return {'\u2268', '\ufe00'}, 2, true } case 'm': switch name { case "mDDot": // GEOMETRIC PROPORTION - return rune(0x223a), true + return {'\u223a', 0}, 1, true case "macr": // MACRON - return rune(0xaf), true + return {'¯', 0}, 1, true case "male": // MALE SIGN - return rune(0x2642), true + return {'\u2642', 0}, 1, true case "malt": // MALTESE CROSS - return rune(0x2720), true + return {'\u2720', 0}, 1, true case "maltese": // MALTESE CROSS - return rune(0x2720), true + return {'\u2720', 0}, 1, true case "map": // RIGHTWARDS ARROW FROM BAR - return rune(0x21a6), true + return {'\u21a6', 0}, 1, true case "mapsto": // RIGHTWARDS ARROW FROM BAR - return rune(0x21a6), true + return {'\u21a6', 0}, 1, true case "mapstodown": // DOWNWARDS ARROW FROM BAR - return rune(0x21a7), true + return {'\u21a7', 0}, 1, true case "mapstoleft": // LEFTWARDS ARROW FROM BAR - return rune(0x21a4), true + return {'\u21a4', 0}, 1, true case "mapstoup": // UPWARDS ARROW FROM BAR - return rune(0x21a5), true + return {'\u21a5', 0}, 1, true case "marker": // BLACK VERTICAL RECTANGLE - return rune(0x25ae), true + return {'\u25ae', 0}, 1, true case "mcomma": // MINUS SIGN WITH COMMA ABOVE - return rune(0x2a29), true + return {'\u2a29', 0}, 1, true case "mcy": // CYRILLIC SMALL LETTER EM - return rune(0x043c), true + return {'\u043c', 0}, 1, true case "mdash": // EM DASH - return rune(0x2014), true + return {'\u2014', 0}, 1, true case "measuredangle": // MEASURED ANGLE - return rune(0x2221), true + return {'\u2221', 0}, 1, true case "mfr": // MATHEMATICAL FRAKTUR SMALL M - return rune(0x01d52a), true + return {'\U0001d52a', 0}, 1, true case "mgr": // GREEK SMALL LETTER MU - return rune(0x03bc), true + return {'\u03bc', 0}, 1, true case "mho": // INVERTED OHM SIGN - return rune(0x2127), true + return {'\u2127', 0}, 1, true case "micro": // MICRO SIGN - return rune(0xb5), true + return {'µ', 0}, 1, true case "mid": // DIVIDES - return rune(0x2223), true + return {'\u2223', 0}, 1, true case "midast": // ASTERISK - return rune(0x2a), true + return {'*', 0}, 1, true case "midcir": // VERTICAL LINE WITH CIRCLE BELOW - return rune(0x2af0), true + return {'\u2af0', 0}, 1, true case "middot": // MIDDLE DOT - return rune(0xb7), true + return {'·', 0}, 1, true case "minus": // MINUS SIGN - return rune(0x2212), true + return {'\u2212', 0}, 1, true case "minusb": // SQUARED MINUS - return rune(0x229f), true + return {'\u229f', 0}, 1, true case "minusd": // DOT MINUS - return rune(0x2238), true + return {'\u2238', 0}, 1, true case "minusdu": // MINUS SIGN WITH DOT BELOW - return rune(0x2a2a), true + return {'\u2a2a', 0}, 1, true case "mlcp": // TRANSVERSAL INTERSECTION - return rune(0x2adb), true + return {'\u2adb', 0}, 1, true case "mldr": // HORIZONTAL ELLIPSIS - return rune(0x2026), true + return {'\u2026', 0}, 1, true case "mnplus": // MINUS-OR-PLUS SIGN - return rune(0x2213), true + return {'\u2213', 0}, 1, true case "models": // MODELS - return rune(0x22a7), true + return {'\u22a7', 0}, 1, true case "mopf": // MATHEMATICAL DOUBLE-STRUCK SMALL M - return rune(0x01d55e), true + return {'\U0001d55e', 0}, 1, true case "mp": // MINUS-OR-PLUS SIGN - return rune(0x2213), true + return {'\u2213', 0}, 1, true case "mscr": // MATHEMATICAL SCRIPT SMALL M - return rune(0x01d4c2), true + return {'\U0001d4c2', 0}, 1, true case "mstpos": // INVERTED LAZY S - return rune(0x223e), true + return {'\u223e', 0}, 1, true case "mu": // GREEK SMALL LETTER MU - return rune(0x03bc), true + return {'\u03bc', 0}, 1, true case "multimap": // MULTIMAP - return rune(0x22b8), true + return {'\u22b8', 0}, 1, true case "mumap": // MULTIMAP - return rune(0x22b8), true + return {'\u22b8', 0}, 1, true } case 'n': switch name { case "nGg": // VERY MUCH GREATER-THAN with slash - return rune(0x22d9), true + return {'\u22d9', '\u0338'}, 2, true case "nGt": // MUCH GREATER THAN with vertical line - return rune(0x226b), true + return {'\u226b', '\u20d2'}, 2, true case "nGtv": // MUCH GREATER THAN with slash - return rune(0x226b), true + return {'\u226b', '\u0338'}, 2, true case "nLeftarrow": // LEFTWARDS DOUBLE ARROW WITH STROKE - return rune(0x21cd), true + return {'\u21cd', 0}, 1, true case "nLeftrightarrow": // LEFT RIGHT DOUBLE ARROW WITH STROKE - return rune(0x21ce), true + return {'\u21ce', 0}, 1, true case "nLl": // VERY MUCH LESS-THAN with slash - return rune(0x22d8), true + return {'\u22d8', '\u0338'}, 2, true case "nLt": // MUCH LESS THAN with vertical line - return rune(0x226a), true + return {'\u226a', '\u20d2'}, 2, true case "nLtv": // MUCH LESS THAN with slash - return rune(0x226a), true + return {'\u226a', '\u0338'}, 2, true case "nRightarrow": // RIGHTWARDS DOUBLE ARROW WITH STROKE - return rune(0x21cf), true + return {'\u21cf', 0}, 1, true case "nVDash": // NEGATED DOUBLE VERTICAL BAR DOUBLE RIGHT TURNSTILE - return rune(0x22af), true + return {'\u22af', 0}, 1, true case "nVdash": // DOES NOT FORCE - return rune(0x22ae), true + return {'\u22ae', 0}, 1, true case "nabla": // NABLA - return rune(0x2207), true + return {'\u2207', 0}, 1, true case "nacute": // LATIN SMALL LETTER N WITH ACUTE - return rune(0x0144), true + return {'\u0144', 0}, 1, true case "nang": // ANGLE with vertical line - return rune(0x2220), true + return {'\u2220', '\u20d2'}, 2, true case "nap": // NOT ALMOST EQUAL TO - return rune(0x2249), true + return {'\u2249', 0}, 1, true case "napE": // APPROXIMATELY EQUAL OR EQUAL TO with slash - return rune(0x2a70), true + return {'\u2a70', '\u0338'}, 2, true case "napid": // TRIPLE TILDE with slash - return rune(0x224b), true + return {'\u224b', '\u0338'}, 2, true case "napos": // LATIN SMALL LETTER N PRECEDED BY APOSTROPHE - return rune(0x0149), true + return {'\u0149', 0}, 1, true case "napprox": // NOT ALMOST EQUAL TO - return rune(0x2249), true + return {'\u2249', 0}, 1, true case "natur": // MUSIC NATURAL SIGN - return rune(0x266e), true + return {'\u266e', 0}, 1, true case "natural": // MUSIC NATURAL SIGN - return rune(0x266e), true + return {'\u266e', 0}, 1, true case "naturals": // DOUBLE-STRUCK CAPITAL N - return rune(0x2115), true + return {'\u2115', 0}, 1, true case "nbsp": // NO-BREAK SPACE - return rune(0xa0), true + return {'\u00a0', 0}, 1, true case "nbump": // GEOMETRICALLY EQUIVALENT TO with slash - return rune(0x224e), true + return {'\u224e', '\u0338'}, 2, true case "nbumpe": // DIFFERENCE BETWEEN with slash - return rune(0x224f), true + return {'\u224f', '\u0338'}, 2, true case "ncap": // INTERSECTION WITH OVERBAR - return rune(0x2a43), true + return {'\u2a43', 0}, 1, true case "ncaron": // LATIN SMALL LETTER N WITH CARON - return rune(0x0148), true + return {'\u0148', 0}, 1, true case "ncedil": // LATIN SMALL LETTER N WITH CEDILLA - return rune(0x0146), true + return {'\u0146', 0}, 1, true case "ncong": // NEITHER APPROXIMATELY NOR ACTUALLY EQUAL TO - return rune(0x2247), true + return {'\u2247', 0}, 1, true case "ncongdot": // CONGRUENT WITH DOT ABOVE with slash - return rune(0x2a6d), true + return {'\u2a6d', '\u0338'}, 2, true case "ncup": // UNION WITH OVERBAR - return rune(0x2a42), true + return {'\u2a42', 0}, 1, true case "ncy": // CYRILLIC SMALL LETTER EN - return rune(0x043d), true + return {'\u043d', 0}, 1, true case "ndash": // EN DASH - return rune(0x2013), true + return {'\u2013', 0}, 1, true case "ne": // NOT EQUAL TO - return rune(0x2260), true + return {'\u2260', 0}, 1, true case "neArr": // NORTH EAST DOUBLE ARROW - return rune(0x21d7), true + return {'\u21d7', 0}, 1, true case "nearhk": // NORTH EAST ARROW WITH HOOK - return rune(0x2924), true + return {'\u2924', 0}, 1, true case "nearr": // NORTH EAST ARROW - return rune(0x2197), true + return {'\u2197', 0}, 1, true case "nearrow": // NORTH EAST ARROW - return rune(0x2197), true + return {'\u2197', 0}, 1, true case "nedot": // APPROACHES THE LIMIT with slash - return rune(0x2250), true + return {'\u2250', '\u0338'}, 2, true case "neonwarr": // NORTH EAST ARROW CROSSING NORTH WEST ARROW - return rune(0x2931), true + return {'\u2931', 0}, 1, true case "neosearr": // NORTH EAST ARROW CROSSING SOUTH EAST ARROW - return rune(0x292e), true + return {'\u292e', 0}, 1, true case "nequiv": // NOT IDENTICAL TO - return rune(0x2262), true + return {'\u2262', 0}, 1, true case "nesear": // NORTH EAST ARROW AND SOUTH EAST ARROW - return rune(0x2928), true + return {'\u2928', 0}, 1, true case "nesim": // MINUS TILDE with slash - return rune(0x2242), true + return {'\u2242', '\u0338'}, 2, true case "neswsarr": // NORTH EAST AND SOUTH WEST ARROW - return rune(0x2922), true + return {'\u2922', 0}, 1, true case "nexist": // THERE DOES NOT EXIST - return rune(0x2204), true + return {'\u2204', 0}, 1, true case "nexists": // THERE DOES NOT EXIST - return rune(0x2204), true + return {'\u2204', 0}, 1, true case "nfr": // MATHEMATICAL FRAKTUR SMALL N - return rune(0x01d52b), true + return {'\U0001d52b', 0}, 1, true case "ngE": // GREATER-THAN OVER EQUAL TO with slash - return rune(0x2267), true + return {'\u2267', '\u0338'}, 2, true case "nge": // NEITHER GREATER-THAN NOR EQUAL TO - return rune(0x2271), true + return {'\u2271', 0}, 1, true case "ngeq": // NEITHER GREATER-THAN NOR EQUAL TO - return rune(0x2271), true + return {'\u2271', 0}, 1, true case "ngeqq": // GREATER-THAN OVER EQUAL TO with slash - return rune(0x2267), true + return {'\u2267', '\u0338'}, 2, true case "ngeqslant": // GREATER-THAN OR SLANTED EQUAL TO with slash - return rune(0x2a7e), true + return {'\u2a7e', '\u0338'}, 2, true case "nges": // GREATER-THAN OR SLANTED EQUAL TO with slash - return rune(0x2a7e), true + return {'\u2a7e', '\u0338'}, 2, true case "ngr": // GREEK SMALL LETTER NU - return rune(0x03bd), true + return {'\u03bd', 0}, 1, true case "ngsim": // NEITHER GREATER-THAN NOR EQUIVALENT TO - return rune(0x2275), true + return {'\u2275', 0}, 1, true case "ngt": // NOT GREATER-THAN - return rune(0x226f), true + return {'\u226f', 0}, 1, true case "ngtr": // NOT GREATER-THAN - return rune(0x226f), true + return {'\u226f', 0}, 1, true case "nhArr": // LEFT RIGHT DOUBLE ARROW WITH STROKE - return rune(0x21ce), true + return {'\u21ce', 0}, 1, true case "nharr": // LEFT RIGHT ARROW WITH STROKE - return rune(0x21ae), true + return {'\u21ae', 0}, 1, true case "nhpar": // PARALLEL WITH HORIZONTAL STROKE - return rune(0x2af2), true + return {'\u2af2', 0}, 1, true case "ni": // CONTAINS AS MEMBER - return rune(0x220b), true + return {'\u220b', 0}, 1, true case "nis": // SMALL CONTAINS WITH VERTICAL BAR AT END OF HORIZONTAL STROKE - return rune(0x22fc), true + return {'\u22fc', 0}, 1, true case "nisd": // CONTAINS WITH LONG HORIZONTAL STROKE - return rune(0x22fa), true + return {'\u22fa', 0}, 1, true case "niv": // CONTAINS AS MEMBER - return rune(0x220b), true + return {'\u220b', 0}, 1, true case "njcy": // CYRILLIC SMALL LETTER NJE - return rune(0x045a), true + return {'\u045a', 0}, 1, true case "nlArr": // LEFTWARDS DOUBLE ARROW WITH STROKE - return rune(0x21cd), true + return {'\u21cd', 0}, 1, true case "nlE": // LESS-THAN OVER EQUAL TO with slash - return rune(0x2266), true + return {'\u2266', '\u0338'}, 2, true case "nlarr": // LEFTWARDS ARROW WITH STROKE - return rune(0x219a), true + return {'\u219a', 0}, 1, true case "nldr": // TWO DOT LEADER - return rune(0x2025), true + return {'\u2025', 0}, 1, true case "nle": // NEITHER LESS-THAN NOR EQUAL TO - return rune(0x2270), true + return {'\u2270', 0}, 1, true case "nleftarrow": // LEFTWARDS ARROW WITH STROKE - return rune(0x219a), true + return {'\u219a', 0}, 1, true case "nleftrightarrow": // LEFT RIGHT ARROW WITH STROKE - return rune(0x21ae), true + return {'\u21ae', 0}, 1, true case "nleq": // NEITHER LESS-THAN NOR EQUAL TO - return rune(0x2270), true + return {'\u2270', 0}, 1, true case "nleqq": // LESS-THAN OVER EQUAL TO with slash - return rune(0x2266), true + return {'\u2266', '\u0338'}, 2, true case "nleqslant": // LESS-THAN OR SLANTED EQUAL TO with slash - return rune(0x2a7d), true + return {'\u2a7d', '\u0338'}, 2, true case "nles": // LESS-THAN OR SLANTED EQUAL TO with slash - return rune(0x2a7d), true + return {'\u2a7d', '\u0338'}, 2, true case "nless": // NOT LESS-THAN - return rune(0x226e), true + return {'\u226e', 0}, 1, true case "nlsim": // NEITHER LESS-THAN NOR EQUIVALENT TO - return rune(0x2274), true + return {'\u2274', 0}, 1, true case "nlt": // NOT LESS-THAN - return rune(0x226e), true + return {'\u226e', 0}, 1, true case "nltri": // NOT NORMAL SUBGROUP OF - return rune(0x22ea), true + return {'\u22ea', 0}, 1, true case "nltrie": // NOT NORMAL SUBGROUP OF OR EQUAL TO - return rune(0x22ec), true + return {'\u22ec', 0}, 1, true case "nltrivb": // LEFT TRIANGLE BESIDE VERTICAL BAR with slash - return rune(0x29cf), true + return {'\u29cf', '\u0338'}, 2, true case "nmid": // DOES NOT DIVIDE - return rune(0x2224), true + return {'\u2224', 0}, 1, true case "nopf": // MATHEMATICAL DOUBLE-STRUCK SMALL N - return rune(0x01d55f), true + return {'\U0001d55f', 0}, 1, true case "not": // NOT SIGN - return rune(0xac), true + return {'¬', 0}, 1, true case "notin": // NOT AN ELEMENT OF - return rune(0x2209), true + return {'\u2209', 0}, 1, true case "notinE": // ELEMENT OF WITH TWO HORIZONTAL STROKES with slash - return rune(0x22f9), true + return {'\u22f9', '\u0338'}, 2, true case "notindot": // ELEMENT OF WITH DOT ABOVE with slash - return rune(0x22f5), true + return {'\u22f5', '\u0338'}, 2, true case "notinva": // NOT AN ELEMENT OF - return rune(0x2209), true + return {'\u2209', 0}, 1, true case "notinvb": // SMALL ELEMENT OF WITH OVERBAR - return rune(0x22f7), true + return {'\u22f7', 0}, 1, true case "notinvc": // ELEMENT OF WITH OVERBAR - return rune(0x22f6), true + return {'\u22f6', 0}, 1, true case "notni": // DOES NOT CONTAIN AS MEMBER - return rune(0x220c), true + return {'\u220c', 0}, 1, true case "notniva": // DOES NOT CONTAIN AS MEMBER - return rune(0x220c), true + return {'\u220c', 0}, 1, true case "notnivb": // SMALL CONTAINS WITH OVERBAR - return rune(0x22fe), true + return {'\u22fe', 0}, 1, true case "notnivc": // CONTAINS WITH OVERBAR - return rune(0x22fd), true + return {'\u22fd', 0}, 1, true case "npar": // NOT PARALLEL TO - return rune(0x2226), true + return {'\u2226', 0}, 1, true case "nparallel": // NOT PARALLEL TO - return rune(0x2226), true + return {'\u2226', 0}, 1, true case "nparsl": // DOUBLE SOLIDUS OPERATOR with reverse slash - return rune(0x2afd), true + return {'\u2afd', '\u20e5'}, 2, true case "npart": // PARTIAL DIFFERENTIAL with slash - return rune(0x2202), true + return {'\u2202', '\u0338'}, 2, true case "npolint": // LINE INTEGRATION NOT INCLUDING THE POLE - return rune(0x2a14), true + return {'\u2a14', 0}, 1, true case "npr": // DOES NOT PRECEDE - return rune(0x2280), true + return {'\u2280', 0}, 1, true case "nprcue": // DOES NOT PRECEDE OR EQUAL - return rune(0x22e0), true + return {'\u22e0', 0}, 1, true case "npre": // PRECEDES ABOVE SINGLE-LINE EQUALS SIGN with slash - return rune(0x2aaf), true + return {'\u2aaf', '\u0338'}, 2, true case "nprec": // DOES NOT PRECEDE - return rune(0x2280), true + return {'\u2280', 0}, 1, true case "npreceq": // PRECEDES ABOVE SINGLE-LINE EQUALS SIGN with slash - return rune(0x2aaf), true + return {'\u2aaf', '\u0338'}, 2, true case "nprsim": // PRECEDES OR EQUIVALENT TO with slash - return rune(0x227e), true + return {'\u227e', '\u0338'}, 2, true case "nrArr": // RIGHTWARDS DOUBLE ARROW WITH STROKE - return rune(0x21cf), true + return {'\u21cf', 0}, 1, true case "nrarr": // RIGHTWARDS ARROW WITH STROKE - return rune(0x219b), true + return {'\u219b', 0}, 1, true case "nrarrc": // WAVE ARROW POINTING DIRECTLY RIGHT with slash - return rune(0x2933), true + return {'\u2933', '\u0338'}, 2, true case "nrarrw": // RIGHTWARDS WAVE ARROW with slash - return rune(0x219d), true + return {'\u219d', '\u0338'}, 2, true case "nrightarrow": // RIGHTWARDS ARROW WITH STROKE - return rune(0x219b), true + return {'\u219b', 0}, 1, true case "nrtri": // DOES NOT CONTAIN AS NORMAL SUBGROUP - return rune(0x22eb), true + return {'\u22eb', 0}, 1, true case "nrtrie": // DOES NOT CONTAIN AS NORMAL SUBGROUP OR EQUAL - return rune(0x22ed), true + return {'\u22ed', 0}, 1, true case "nsGt": // DOUBLE NESTED GREATER-THAN with slash - return rune(0x2aa2), true + return {'\u2aa2', '\u0338'}, 2, true case "nsLt": // DOUBLE NESTED LESS-THAN with slash - return rune(0x2aa1), true + return {'\u2aa1', '\u0338'}, 2, true case "nsc": // DOES NOT SUCCEED - return rune(0x2281), true + return {'\u2281', 0}, 1, true case "nsccue": // DOES NOT SUCCEED OR EQUAL - return rune(0x22e1), true + return {'\u22e1', 0}, 1, true case "nsce": // SUCCEEDS ABOVE SINGLE-LINE EQUALS SIGN with slash - return rune(0x2ab0), true + return {'\u2ab0', '\u0338'}, 2, true case "nscr": // MATHEMATICAL SCRIPT SMALL N - return rune(0x01d4c3), true + return {'\U0001d4c3', 0}, 1, true case "nscsim": // SUCCEEDS OR EQUIVALENT TO with slash - return rune(0x227f), true + return {'\u227f', '\u0338'}, 2, true case "nshortmid": // DOES NOT DIVIDE - return rune(0x2224), true + return {'\u2224', 0}, 1, true case "nshortparallel": // NOT PARALLEL TO - return rune(0x2226), true + return {'\u2226', 0}, 1, true case "nsim": // NOT TILDE - return rune(0x2241), true + return {'\u2241', 0}, 1, true case "nsime": // NOT ASYMPTOTICALLY EQUAL TO - return rune(0x2244), true + return {'\u2244', 0}, 1, true case "nsimeq": // NOT ASYMPTOTICALLY EQUAL TO - return rune(0x2244), true + return {'\u2244', 0}, 1, true case "nsmid": // DOES NOT DIVIDE - return rune(0x2224), true + return {'\u2224', 0}, 1, true case "nspar": // NOT PARALLEL TO - return rune(0x2226), true + return {'\u2226', 0}, 1, true case "nsqsub": // SQUARE IMAGE OF with slash - return rune(0x228f), true + return {'\u228f', '\u0338'}, 2, true case "nsqsube": // NOT SQUARE IMAGE OF OR EQUAL TO - return rune(0x22e2), true + return {'\u22e2', 0}, 1, true case "nsqsup": // SQUARE ORIGINAL OF with slash - return rune(0x2290), true + return {'\u2290', '\u0338'}, 2, true case "nsqsupe": // NOT SQUARE ORIGINAL OF OR EQUAL TO - return rune(0x22e3), true + return {'\u22e3', 0}, 1, true case "nsub": // NOT A SUBSET OF - return rune(0x2284), true + return {'\u2284', 0}, 1, true case "nsubE": // SUBSET OF ABOVE EQUALS SIGN with slash - return rune(0x2ac5), true + return {'\u2ac5', '\u0338'}, 2, true case "nsube": // NEITHER A SUBSET OF NOR EQUAL TO - return rune(0x2288), true + return {'\u2288', 0}, 1, true case "nsubset": // SUBSET OF with vertical line - return rune(0x2282), true + return {'\u2282', '\u20d2'}, 2, true case "nsubseteq": // NEITHER A SUBSET OF NOR EQUAL TO - return rune(0x2288), true + return {'\u2288', 0}, 1, true case "nsubseteqq": // SUBSET OF ABOVE EQUALS SIGN with slash - return rune(0x2ac5), true + return {'\u2ac5', '\u0338'}, 2, true case "nsucc": // DOES NOT SUCCEED - return rune(0x2281), true + return {'\u2281', 0}, 1, true case "nsucceq": // SUCCEEDS ABOVE SINGLE-LINE EQUALS SIGN with slash - return rune(0x2ab0), true + return {'\u2ab0', '\u0338'}, 2, true case "nsup": // NOT A SUPERSET OF - return rune(0x2285), true + return {'\u2285', 0}, 1, true case "nsupE": // SUPERSET OF ABOVE EQUALS SIGN with slash - return rune(0x2ac6), true + return {'\u2ac6', '\u0338'}, 2, true case "nsupe": // NEITHER A SUPERSET OF NOR EQUAL TO - return rune(0x2289), true + return {'\u2289', 0}, 1, true case "nsupset": // SUPERSET OF with vertical line - return rune(0x2283), true + return {'\u2283', '\u20d2'}, 2, true case "nsupseteq": // NEITHER A SUPERSET OF NOR EQUAL TO - return rune(0x2289), true + return {'\u2289', 0}, 1, true case "nsupseteqq": // SUPERSET OF ABOVE EQUALS SIGN with slash - return rune(0x2ac6), true + return {'\u2ac6', '\u0338'}, 2, true case "ntgl": // NEITHER GREATER-THAN NOR LESS-THAN - return rune(0x2279), true + return {'\u2279', 0}, 1, true case "ntilde": // LATIN SMALL LETTER N WITH TILDE - return rune(0xf1), true + return {'ñ', 0}, 1, true case "ntlg": // NEITHER LESS-THAN NOR GREATER-THAN - return rune(0x2278), true + return {'\u2278', 0}, 1, true case "ntriangleleft": // NOT NORMAL SUBGROUP OF - return rune(0x22ea), true + return {'\u22ea', 0}, 1, true case "ntrianglelefteq": // NOT NORMAL SUBGROUP OF OR EQUAL TO - return rune(0x22ec), true + return {'\u22ec', 0}, 1, true case "ntriangleright": // DOES NOT CONTAIN AS NORMAL SUBGROUP - return rune(0x22eb), true + return {'\u22eb', 0}, 1, true case "ntrianglerighteq": // DOES NOT CONTAIN AS NORMAL SUBGROUP OR EQUAL - return rune(0x22ed), true + return {'\u22ed', 0}, 1, true case "nu": // GREEK SMALL LETTER NU - return rune(0x03bd), true + return {'\u03bd', 0}, 1, true case "num": // NUMBER SIGN - return rune(0x23), true + return {'#', 0}, 1, true case "numero": // NUMERO SIGN - return rune(0x2116), true + return {'\u2116', 0}, 1, true case "numsp": // FIGURE SPACE - return rune(0x2007), true + return {'\u2007', 0}, 1, true case "nvDash": // NOT TRUE - return rune(0x22ad), true + return {'\u22ad', 0}, 1, true case "nvHarr": // LEFT RIGHT DOUBLE ARROW WITH VERTICAL STROKE - return rune(0x2904), true + return {'\u2904', 0}, 1, true case "nvap": // EQUIVALENT TO with vertical line - return rune(0x224d), true + return {'\u224d', '\u20d2'}, 2, true case "nvbrtri": // VERTICAL BAR BESIDE RIGHT TRIANGLE with slash - return rune(0x29d0), true + return {'\u29d0', '\u0338'}, 2, true case "nvdash": // DOES NOT PROVE - return rune(0x22ac), true + return {'\u22ac', 0}, 1, true case "nvge": // GREATER-THAN OR EQUAL TO with vertical line - return rune(0x2265), true + return {'\u2265', '\u20d2'}, 2, true case "nvgt": // GREATER-THAN SIGN with vertical line - return rune(0x3e), true + return {'>', '\u20d2'}, 2, true case "nvinfin": // INFINITY NEGATED WITH VERTICAL BAR - return rune(0x29de), true + return {'\u29de', 0}, 1, true case "nvlArr": // LEFTWARDS DOUBLE ARROW WITH VERTICAL STROKE - return rune(0x2902), true + return {'\u2902', 0}, 1, true case "nvle": // LESS-THAN OR EQUAL TO with vertical line - return rune(0x2264), true + return {'\u2264', '\u20d2'}, 2, true case "nvlt": // LESS-THAN SIGN with vertical line - return rune(0x3c), true + return {'<', '\u20d2'}, 2, true case "nvltrie": // NORMAL SUBGROUP OF OR EQUAL TO with vertical line - return rune(0x22b4), true + return {'\u22b4', '\u20d2'}, 2, true case "nvrArr": // RIGHTWARDS DOUBLE ARROW WITH VERTICAL STROKE - return rune(0x2903), true + return {'\u2903', 0}, 1, true case "nvrtrie": // CONTAINS AS NORMAL SUBGROUP OR EQUAL TO with vertical line - return rune(0x22b5), true + return {'\u22b5', '\u20d2'}, 2, true case "nvsim": // TILDE OPERATOR with vertical line - return rune(0x223c), true + return {'\u223c', '\u20d2'}, 2, true case "nwArr": // NORTH WEST DOUBLE ARROW - return rune(0x21d6), true + return {'\u21d6', 0}, 1, true case "nwarhk": // NORTH WEST ARROW WITH HOOK - return rune(0x2923), true + return {'\u2923', 0}, 1, true case "nwarr": // NORTH WEST ARROW - return rune(0x2196), true + return {'\u2196', 0}, 1, true case "nwarrow": // NORTH WEST ARROW - return rune(0x2196), true + return {'\u2196', 0}, 1, true case "nwnear": // NORTH WEST ARROW AND NORTH EAST ARROW - return rune(0x2927), true + return {'\u2927', 0}, 1, true case "nwonearr": // NORTH WEST ARROW CROSSING NORTH EAST ARROW - return rune(0x2932), true + return {'\u2932', 0}, 1, true case "nwsesarr": // NORTH WEST AND SOUTH EAST ARROW - return rune(0x2921), true + return {'\u2921', 0}, 1, true } case 'o': switch name { case "oS": // CIRCLED LATIN CAPITAL LETTER S - return rune(0x24c8), true + return {'\u24c8', 0}, 1, true case "oacgr": // GREEK SMALL LETTER OMICRON WITH TONOS - return rune(0x03cc), true + return {'\u03cc', 0}, 1, true case "oacute": // LATIN SMALL LETTER O WITH ACUTE - return rune(0xf3), true + return {'ó', 0}, 1, true case "oast": // CIRCLED ASTERISK OPERATOR - return rune(0x229b), true + return {'\u229b', 0}, 1, true case "obsol": // CIRCLED REVERSE SOLIDUS - return rune(0x29b8), true + return {'\u29b8', 0}, 1, true case "ocir": // CIRCLED RING OPERATOR - return rune(0x229a), true + return {'\u229a', 0}, 1, true case "ocirc": // LATIN SMALL LETTER O WITH CIRCUMFLEX - return rune(0xf4), true + return {'ô', 0}, 1, true case "ocy": // CYRILLIC SMALL LETTER O - return rune(0x043e), true + return {'\u043e', 0}, 1, true case "odash": // CIRCLED DASH - return rune(0x229d), true + return {'\u229d', 0}, 1, true case "odblac": // LATIN SMALL LETTER O WITH DOUBLE ACUTE - return rune(0x0151), true + return {'\u0151', 0}, 1, true case "odiv": // CIRCLED DIVISION SIGN - return rune(0x2a38), true + return {'\u2a38', 0}, 1, true case "odot": // CIRCLED DOT OPERATOR - return rune(0x2299), true + return {'\u2299', 0}, 1, true case "odsold": // CIRCLED ANTICLOCKWISE-ROTATED DIVISION SIGN - return rune(0x29bc), true + return {'\u29bc', 0}, 1, true case "oelig": // LATIN SMALL LIGATURE OE - return rune(0x0153), true + return {'\u0153', 0}, 1, true case "ofcir": // CIRCLED BULLET - return rune(0x29bf), true + return {'\u29bf', 0}, 1, true case "ofr": // MATHEMATICAL FRAKTUR SMALL O - return rune(0x01d52c), true + return {'\U0001d52c', 0}, 1, true case "ogon": // OGONEK - return rune(0x02db), true + return {'\u02db', 0}, 1, true case "ogr": // GREEK SMALL LETTER OMICRON - return rune(0x03bf), true + return {'\u03bf', 0}, 1, true case "ograve": // LATIN SMALL LETTER O WITH GRAVE - return rune(0xf2), true + return {'ò', 0}, 1, true case "ogt": // CIRCLED GREATER-THAN - return rune(0x29c1), true + return {'\u29c1', 0}, 1, true case "ohacgr": // GREEK SMALL LETTER OMEGA WITH TONOS - return rune(0x03ce), true + return {'\u03ce', 0}, 1, true case "ohbar": // CIRCLE WITH HORIZONTAL BAR - return rune(0x29b5), true + return {'\u29b5', 0}, 1, true case "ohgr": // GREEK SMALL LETTER OMEGA - return rune(0x03c9), true + return {'\u03c9', 0}, 1, true case "ohm": // GREEK CAPITAL LETTER OMEGA - return rune(0x03a9), true + return {'\u03a9', 0}, 1, true case "oint": // CONTOUR INTEGRAL - return rune(0x222e), true + return {'\u222e', 0}, 1, true case "olarr": // ANTICLOCKWISE OPEN CIRCLE ARROW - return rune(0x21ba), true + return {'\u21ba', 0}, 1, true case "olcir": // CIRCLED WHITE BULLET - return rune(0x29be), true + return {'\u29be', 0}, 1, true case "olcross": // CIRCLE WITH SUPERIMPOSED X - return rune(0x29bb), true + return {'\u29bb', 0}, 1, true case "oline": // OVERLINE - return rune(0x203e), true + return {'\u203e', 0}, 1, true case "olt": // CIRCLED LESS-THAN - return rune(0x29c0), true + return {'\u29c0', 0}, 1, true case "omacr": // LATIN SMALL LETTER O WITH MACRON - return rune(0x014d), true + return {'\u014d', 0}, 1, true case "omega": // GREEK SMALL LETTER OMEGA - return rune(0x03c9), true + return {'\u03c9', 0}, 1, true case "omicron": // GREEK SMALL LETTER OMICRON - return rune(0x03bf), true + return {'\u03bf', 0}, 1, true case "omid": // CIRCLED VERTICAL BAR - return rune(0x29b6), true + return {'\u29b6', 0}, 1, true case "ominus": // CIRCLED MINUS - return rune(0x2296), true + return {'\u2296', 0}, 1, true case "oopf": // MATHEMATICAL DOUBLE-STRUCK SMALL O - return rune(0x01d560), true + return {'\U0001d560', 0}, 1, true case "opar": // CIRCLED PARALLEL - return rune(0x29b7), true + return {'\u29b7', 0}, 1, true case "operp": // CIRCLED PERPENDICULAR - return rune(0x29b9), true + return {'\u29b9', 0}, 1, true case "opfgamma": // DOUBLE-STRUCK SMALL GAMMA - return rune(0x213d), true + return {'\u213d', 0}, 1, true case "opfpi": // DOUBLE-STRUCK CAPITAL PI - return rune(0x213f), true + return {'\u213f', 0}, 1, true case "opfsum": // DOUBLE-STRUCK N-ARY SUMMATION - return rune(0x2140), true + return {'\u2140', 0}, 1, true case "oplus": // CIRCLED PLUS - return rune(0x2295), true + return {'\u2295', 0}, 1, true case "or": // LOGICAL OR - return rune(0x2228), true + return {'\u2228', 0}, 1, true case "orarr": // CLOCKWISE OPEN CIRCLE ARROW - return rune(0x21bb), true + return {'\u21bb', 0}, 1, true case "ord": // LOGICAL OR WITH HORIZONTAL DASH - return rune(0x2a5d), true + return {'\u2a5d', 0}, 1, true case "order": // SCRIPT SMALL O - return rune(0x2134), true + return {'\u2134', 0}, 1, true case "orderof": // SCRIPT SMALL O - return rune(0x2134), true + return {'\u2134', 0}, 1, true case "ordf": // FEMININE ORDINAL INDICATOR - return rune(0xaa), true + return {'ª', 0}, 1, true case "ordm": // MASCULINE ORDINAL INDICATOR - return rune(0xba), true + return {'º', 0}, 1, true case "origof": // ORIGINAL OF - return rune(0x22b6), true + return {'\u22b6', 0}, 1, true case "oror": // TWO INTERSECTING LOGICAL OR - return rune(0x2a56), true + return {'\u2a56', 0}, 1, true case "orslope": // SLOPING LARGE OR - return rune(0x2a57), true + return {'\u2a57', 0}, 1, true case "orv": // LOGICAL OR WITH MIDDLE STEM - return rune(0x2a5b), true + return {'\u2a5b', 0}, 1, true case "oscr": // SCRIPT SMALL O - return rune(0x2134), true + return {'\u2134', 0}, 1, true case "oslash": // LATIN SMALL LETTER O WITH STROKE - return rune(0xf8), true + return {'ø', 0}, 1, true case "osol": // CIRCLED DIVISION SLASH - return rune(0x2298), true + return {'\u2298', 0}, 1, true case "otilde": // LATIN SMALL LETTER O WITH TILDE - return rune(0xf5), true + return {'õ', 0}, 1, true case "otimes": // CIRCLED TIMES - return rune(0x2297), true + return {'\u2297', 0}, 1, true case "otimesas": // CIRCLED MULTIPLICATION SIGN WITH CIRCUMFLEX ACCENT - return rune(0x2a36), true + return {'\u2a36', 0}, 1, true case "ouml": // LATIN SMALL LETTER O WITH DIAERESIS - return rune(0xf6), true + return {'ö', 0}, 1, true case "ovbar": // APL FUNCTIONAL SYMBOL CIRCLE STILE - return rune(0x233d), true + return {'\u233d', 0}, 1, true case "ovrbrk": // TOP SQUARE BRACKET - return rune(0x23b4), true + return {'\u23b4', 0}, 1, true case "ovrcub": // TOP CURLY BRACKET - return rune(0x23de), true + return {'\u23de', 0}, 1, true case "ovrpar": // TOP PARENTHESIS - return rune(0x23dc), true + return {'\u23dc', 0}, 1, true case "oxuarr": // UP ARROW THROUGH CIRCLE - return rune(0x29bd), true + return {'\u29bd', 0}, 1, true } case 'p': switch name { case "par": // PARALLEL TO - return rune(0x2225), true + return {'\u2225', 0}, 1, true case "para": // PILCROW SIGN - return rune(0xb6), true + return {'¶', 0}, 1, true case "parallel": // PARALLEL TO - return rune(0x2225), true + return {'\u2225', 0}, 1, true case "parsim": // PARALLEL WITH TILDE OPERATOR - return rune(0x2af3), true + return {'\u2af3', 0}, 1, true case "parsl": // DOUBLE SOLIDUS OPERATOR - return rune(0x2afd), true + return {'\u2afd', 0}, 1, true case "part": // PARTIAL DIFFERENTIAL - return rune(0x2202), true + return {'\u2202', 0}, 1, true case "pcy": // CYRILLIC SMALL LETTER PE - return rune(0x043f), true + return {'\u043f', 0}, 1, true case "percnt": // PERCENT SIGN - return rune(0x25), true + return {'%', 0}, 1, true case "period": // FULL STOP - return rune(0x2e), true + return {'.', 0}, 1, true case "permil": // PER MILLE SIGN - return rune(0x2030), true + return {'\u2030', 0}, 1, true case "perp": // UP TACK - return rune(0x22a5), true + return {'\u22a5', 0}, 1, true case "pertenk": // PER TEN THOUSAND SIGN - return rune(0x2031), true + return {'\u2031', 0}, 1, true case "pfr": // MATHEMATICAL FRAKTUR SMALL P - return rune(0x01d52d), true + return {'\U0001d52d', 0}, 1, true case "pgr": // GREEK SMALL LETTER PI - return rune(0x03c0), true + return {'\u03c0', 0}, 1, true case "phgr": // GREEK SMALL LETTER PHI - return rune(0x03c6), true + return {'\u03c6', 0}, 1, true case "phi": // GREEK SMALL LETTER PHI - return rune(0x03c6), true + return {'\u03c6', 0}, 1, true case "phis": // GREEK PHI SYMBOL - return rune(0x03d5), true + return {'\u03d5', 0}, 1, true case "phiv": // GREEK PHI SYMBOL - return rune(0x03d5), true + return {'\u03d5', 0}, 1, true case "phmmat": // SCRIPT CAPITAL M - return rune(0x2133), true + return {'\u2133', 0}, 1, true case "phone": // BLACK TELEPHONE - return rune(0x260e), true + return {'\u260e', 0}, 1, true case "pi": // GREEK SMALL LETTER PI - return rune(0x03c0), true + return {'\u03c0', 0}, 1, true case "pitchfork": // PITCHFORK - return rune(0x22d4), true + return {'\u22d4', 0}, 1, true case "piv": // GREEK PI SYMBOL - return rune(0x03d6), true + return {'\u03d6', 0}, 1, true case "planck": // PLANCK CONSTANT OVER TWO PI - return rune(0x210f), true + return {'\u210f', 0}, 1, true case "planckh": // PLANCK CONSTANT - return rune(0x210e), true + return {'\u210e', 0}, 1, true case "plankv": // PLANCK CONSTANT OVER TWO PI - return rune(0x210f), true + return {'\u210f', 0}, 1, true case "plus": // PLUS SIGN - return rune(0x2b), true + return {'+', 0}, 1, true case "plusacir": // PLUS SIGN WITH CIRCUMFLEX ACCENT ABOVE - return rune(0x2a23), true + return {'\u2a23', 0}, 1, true case "plusb": // SQUARED PLUS - return rune(0x229e), true + return {'\u229e', 0}, 1, true case "pluscir": // PLUS SIGN WITH SMALL CIRCLE ABOVE - return rune(0x2a22), true + return {'\u2a22', 0}, 1, true case "plusdo": // DOT PLUS - return rune(0x2214), true + return {'\u2214', 0}, 1, true case "plusdu": // PLUS SIGN WITH DOT BELOW - return rune(0x2a25), true + return {'\u2a25', 0}, 1, true case "pluse": // PLUS SIGN ABOVE EQUALS SIGN - return rune(0x2a72), true + return {'\u2a72', 0}, 1, true case "plusmn": // PLUS-MINUS SIGN - return rune(0xb1), true + return {'±', 0}, 1, true case "plussim": // PLUS SIGN WITH TILDE BELOW - return rune(0x2a26), true + return {'\u2a26', 0}, 1, true case "plustrif": // PLUS SIGN WITH BLACK TRIANGLE - return rune(0x2a28), true + return {'\u2a28', 0}, 1, true case "plustwo": // PLUS SIGN WITH SUBSCRIPT TWO - return rune(0x2a27), true + return {'\u2a27', 0}, 1, true case "pm": // PLUS-MINUS SIGN - return rune(0xb1), true + return {'±', 0}, 1, true case "pointint": // INTEGRAL AROUND A POINT OPERATOR - return rune(0x2a15), true + return {'\u2a15', 0}, 1, true case "popf": // MATHEMATICAL DOUBLE-STRUCK SMALL P - return rune(0x01d561), true + return {'\U0001d561', 0}, 1, true case "pound": // POUND SIGN - return rune(0xa3), true + return {'£', 0}, 1, true case "pr": // PRECEDES - return rune(0x227a), true + return {'\u227a', 0}, 1, true case "prE": // PRECEDES ABOVE EQUALS SIGN - return rune(0x2ab3), true + return {'\u2ab3', 0}, 1, true case "prap": // PRECEDES ABOVE ALMOST EQUAL TO - return rune(0x2ab7), true + return {'\u2ab7', 0}, 1, true case "prcue": // PRECEDES OR EQUAL TO - return rune(0x227c), true + return {'\u227c', 0}, 1, true case "pre": // PRECEDES ABOVE SINGLE-LINE EQUALS SIGN - return rune(0x2aaf), true + return {'\u2aaf', 0}, 1, true case "prec": // PRECEDES - return rune(0x227a), true + return {'\u227a', 0}, 1, true case "precapprox": // PRECEDES ABOVE ALMOST EQUAL TO - return rune(0x2ab7), true + return {'\u2ab7', 0}, 1, true case "preccurlyeq": // PRECEDES OR EQUAL TO - return rune(0x227c), true + return {'\u227c', 0}, 1, true case "preceq": // PRECEDES ABOVE SINGLE-LINE EQUALS SIGN - return rune(0x2aaf), true + return {'\u2aaf', 0}, 1, true case "precnapprox": // PRECEDES ABOVE NOT ALMOST EQUAL TO - return rune(0x2ab9), true + return {'\u2ab9', 0}, 1, true case "precneqq": // PRECEDES ABOVE NOT EQUAL TO - return rune(0x2ab5), true + return {'\u2ab5', 0}, 1, true case "precnsim": // PRECEDES BUT NOT EQUIVALENT TO - return rune(0x22e8), true + return {'\u22e8', 0}, 1, true case "precsim": // PRECEDES OR EQUIVALENT TO - return rune(0x227e), true + return {'\u227e', 0}, 1, true case "prime": // PRIME - return rune(0x2032), true + return {'\u2032', 0}, 1, true case "primes": // DOUBLE-STRUCK CAPITAL P - return rune(0x2119), true + return {'\u2119', 0}, 1, true case "prnE": // PRECEDES ABOVE NOT EQUAL TO - return rune(0x2ab5), true + return {'\u2ab5', 0}, 1, true case "prnap": // PRECEDES ABOVE NOT ALMOST EQUAL TO - return rune(0x2ab9), true + return {'\u2ab9', 0}, 1, true case "prnsim": // PRECEDES BUT NOT EQUIVALENT TO - return rune(0x22e8), true + return {'\u22e8', 0}, 1, true case "prod": // N-ARY PRODUCT - return rune(0x220f), true + return {'\u220f', 0}, 1, true case "profalar": // ALL AROUND-PROFILE - return rune(0x232e), true + return {'\u232e', 0}, 1, true case "profline": // ARC - return rune(0x2312), true + return {'\u2312', 0}, 1, true case "profsurf": // SEGMENT - return rune(0x2313), true + return {'\u2313', 0}, 1, true case "prop": // PROPORTIONAL TO - return rune(0x221d), true + return {'\u221d', 0}, 1, true case "propto": // PROPORTIONAL TO - return rune(0x221d), true + return {'\u221d', 0}, 1, true case "prsim": // PRECEDES OR EQUIVALENT TO - return rune(0x227e), true + return {'\u227e', 0}, 1, true case "prurel": // PRECEDES UNDER RELATION - return rune(0x22b0), true + return {'\u22b0', 0}, 1, true case "pscr": // MATHEMATICAL SCRIPT SMALL P - return rune(0x01d4c5), true + return {'\U0001d4c5', 0}, 1, true case "psgr": // GREEK SMALL LETTER PSI - return rune(0x03c8), true + return {'\u03c8', 0}, 1, true case "psi": // GREEK SMALL LETTER PSI - return rune(0x03c8), true + return {'\u03c8', 0}, 1, true case "puncsp": // PUNCTUATION SPACE - return rune(0x2008), true + return {'\u2008', 0}, 1, true } case 'q': switch name { case "qfr": // MATHEMATICAL FRAKTUR SMALL Q - return rune(0x01d52e), true + return {'\U0001d52e', 0}, 1, true case "qint": // QUADRUPLE INTEGRAL OPERATOR - return rune(0x2a0c), true + return {'\u2a0c', 0}, 1, true case "qopf": // MATHEMATICAL DOUBLE-STRUCK SMALL Q - return rune(0x01d562), true + return {'\U0001d562', 0}, 1, true case "qprime": // QUADRUPLE PRIME - return rune(0x2057), true + return {'\u2057', 0}, 1, true case "qscr": // MATHEMATICAL SCRIPT SMALL Q - return rune(0x01d4c6), true + return {'\U0001d4c6', 0}, 1, true case "quaternions": // DOUBLE-STRUCK CAPITAL H - return rune(0x210d), true + return {'\u210d', 0}, 1, true case "quatint": // QUATERNION INTEGRAL OPERATOR - return rune(0x2a16), true + return {'\u2a16', 0}, 1, true case "quest": // QUESTION MARK - return rune(0x3f), true + return {'?', 0}, 1, true case "questeq": // QUESTIONED EQUAL TO - return rune(0x225f), true + return {'\u225f', 0}, 1, true case "quot": // QUOTATION MARK - return rune(0x22), true + return {'"', 0}, 1, true } case 'r': switch name { case "rAarr": // RIGHTWARDS TRIPLE ARROW - return rune(0x21db), true + return {'\u21db', 0}, 1, true case "rArr": // RIGHTWARDS DOUBLE ARROW - return rune(0x21d2), true + return {'\u21d2', 0}, 1, true case "rAtail": // RIGHTWARDS DOUBLE ARROW-TAIL - return rune(0x291c), true + return {'\u291c', 0}, 1, true case "rBarr": // RIGHTWARDS TRIPLE DASH ARROW - return rune(0x290f), true + return {'\u290f', 0}, 1, true case "rHar": // RIGHTWARDS HARPOON WITH BARB UP ABOVE RIGHTWARDS HARPOON WITH BARB DOWN - return rune(0x2964), true + return {'\u2964', 0}, 1, true case "race": // REVERSED TILDE with underline - return rune(0x223d), true + return {'\u223d', '\u0331'}, 2, true case "racute": // LATIN SMALL LETTER R WITH ACUTE - return rune(0x0155), true + return {'\u0155', 0}, 1, true case "radic": // SQUARE ROOT - return rune(0x221a), true + return {'\u221a', 0}, 1, true case "raemptyv": // EMPTY SET WITH RIGHT ARROW ABOVE - return rune(0x29b3), true + return {'\u29b3', 0}, 1, true case "rang": // MATHEMATICAL RIGHT ANGLE BRACKET - return rune(0x27e9), true + return {'\u27e9', 0}, 1, true case "rangd": // RIGHT ANGLE BRACKET WITH DOT - return rune(0x2992), true + return {'\u2992', 0}, 1, true case "range": // REVERSED ANGLE WITH UNDERBAR - return rune(0x29a5), true + return {'\u29a5', 0}, 1, true case "rangle": // MATHEMATICAL RIGHT ANGLE BRACKET - return rune(0x27e9), true + return {'\u27e9', 0}, 1, true case "raquo": // RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK - return rune(0xbb), true + return {'»', 0}, 1, true case "rarr": // RIGHTWARDS ARROW - return rune(0x2192), true + return {'\u2192', 0}, 1, true case "rarr2": // RIGHTWARDS PAIRED ARROWS - return rune(0x21c9), true + return {'\u21c9', 0}, 1, true case "rarr3": // THREE RIGHTWARDS ARROWS - return rune(0x21f6), true + return {'\u21f6', 0}, 1, true case "rarrap": // RIGHTWARDS ARROW ABOVE ALMOST EQUAL TO - return rune(0x2975), true + return {'\u2975', 0}, 1, true case "rarrb": // RIGHTWARDS ARROW TO BAR - return rune(0x21e5), true + return {'\u21e5', 0}, 1, true case "rarrbfs": // RIGHTWARDS ARROW FROM BAR TO BLACK DIAMOND - return rune(0x2920), true + return {'\u2920', 0}, 1, true case "rarrc": // WAVE ARROW POINTING DIRECTLY RIGHT - return rune(0x2933), true + return {'\u2933', 0}, 1, true case "rarrfs": // RIGHTWARDS ARROW TO BLACK DIAMOND - return rune(0x291e), true + return {'\u291e', 0}, 1, true case "rarrhk": // RIGHTWARDS ARROW WITH HOOK - return rune(0x21aa), true + return {'\u21aa', 0}, 1, true case "rarrlp": // RIGHTWARDS ARROW WITH LOOP - return rune(0x21ac), true + return {'\u21ac', 0}, 1, true case "rarrpl": // RIGHTWARDS ARROW WITH PLUS BELOW - return rune(0x2945), true + return {'\u2945', 0}, 1, true case "rarrsim": // RIGHTWARDS ARROW ABOVE TILDE OPERATOR - return rune(0x2974), true + return {'\u2974', 0}, 1, true case "rarrtl": // RIGHTWARDS ARROW WITH TAIL - return rune(0x21a3), true + return {'\u21a3', 0}, 1, true case "rarrw": // RIGHTWARDS WAVE ARROW - return rune(0x219d), true + return {'\u219d', 0}, 1, true case "rarrx": // RIGHTWARDS ARROW THROUGH X - return rune(0x2947), true + return {'\u2947', 0}, 1, true case "ratail": // RIGHTWARDS ARROW-TAIL - return rune(0x291a), true + return {'\u291a', 0}, 1, true case "ratio": // RATIO - return rune(0x2236), true + return {'\u2236', 0}, 1, true case "rationals": // DOUBLE-STRUCK CAPITAL Q - return rune(0x211a), true + return {'\u211a', 0}, 1, true case "rbarr": // RIGHTWARDS DOUBLE DASH ARROW - return rune(0x290d), true + return {'\u290d', 0}, 1, true case "rbbrk": // LIGHT RIGHT TORTOISE SHELL BRACKET ORNAMENT - return rune(0x2773), true + return {'\u2773', 0}, 1, true case "rbrace": // RIGHT CURLY BRACKET - return rune(0x7d), true + return {'}', 0}, 1, true case "rbrack": // RIGHT SQUARE BRACKET - return rune(0x5d), true + return {']', 0}, 1, true case "rbrke": // RIGHT SQUARE BRACKET WITH UNDERBAR - return rune(0x298c), true + return {'\u298c', 0}, 1, true case "rbrksld": // RIGHT SQUARE BRACKET WITH TICK IN BOTTOM CORNER - return rune(0x298e), true + return {'\u298e', 0}, 1, true case "rbrkslu": // RIGHT SQUARE BRACKET WITH TICK IN TOP CORNER - return rune(0x2990), true + return {'\u2990', 0}, 1, true case "rcaron": // LATIN SMALL LETTER R WITH CARON - return rune(0x0159), true + return {'\u0159', 0}, 1, true case "rcedil": // LATIN SMALL LETTER R WITH CEDILLA - return rune(0x0157), true + return {'\u0157', 0}, 1, true case "rceil": // RIGHT CEILING - return rune(0x2309), true + return {'\u2309', 0}, 1, true case "rcub": // RIGHT CURLY BRACKET - return rune(0x7d), true + return {'}', 0}, 1, true case "rcy": // CYRILLIC SMALL LETTER ER - return rune(0x0440), true + return {'\u0440', 0}, 1, true case "rdca": // ARROW POINTING DOWNWARDS THEN CURVING RIGHTWARDS - return rune(0x2937), true + return {'\u2937', 0}, 1, true case "rdharb": // RIGHTWARDS HARPOON WITH BARB DOWN TO BAR - return rune(0x2957), true + return {'\u2957', 0}, 1, true case "rdiag": // BOX DRAWINGS LIGHT DIAGONAL UPPER RIGHT TO LOWER LEFT - return rune(0x2571), true + return {'\u2571', 0}, 1, true case "rdiofdi": // RISING DIAGONAL CROSSING FALLING DIAGONAL - return rune(0x292b), true + return {'\u292b', 0}, 1, true case "rdldhar": // RIGHTWARDS HARPOON WITH BARB DOWN ABOVE LEFTWARDS HARPOON WITH BARB DOWN - return rune(0x2969), true + return {'\u2969', 0}, 1, true case "rdosearr": // RISING DIAGONAL CROSSING SOUTH EAST ARROW - return rune(0x2930), true + return {'\u2930', 0}, 1, true case "rdquo": // RIGHT DOUBLE QUOTATION MARK - return rune(0x201d), true + return {'\u201d', 0}, 1, true case "rdquor": // RIGHT DOUBLE QUOTATION MARK - return rune(0x201d), true + return {'\u201d', 0}, 1, true case "rdsh": // DOWNWARDS ARROW WITH TIP RIGHTWARDS - return rune(0x21b3), true + return {'\u21b3', 0}, 1, true case "real": // BLACK-LETTER CAPITAL R - return rune(0x211c), true + return {'\u211c', 0}, 1, true case "realine": // SCRIPT CAPITAL R - return rune(0x211b), true + return {'\u211b', 0}, 1, true case "realpart": // BLACK-LETTER CAPITAL R - return rune(0x211c), true + return {'\u211c', 0}, 1, true case "reals": // DOUBLE-STRUCK CAPITAL R - return rune(0x211d), true + return {'\u211d', 0}, 1, true case "rect": // WHITE RECTANGLE - return rune(0x25ad), true + return {'\u25ad', 0}, 1, true case "reg": // REGISTERED SIGN - return rune(0xae), true + return {'®', 0}, 1, true case "rfbowtie": // BOWTIE WITH RIGHT HALF BLACK - return rune(0x29d2), true + return {'\u29d2', 0}, 1, true case "rfisht": // RIGHT FISH TAIL - return rune(0x297d), true + return {'\u297d', 0}, 1, true case "rfloor": // RIGHT FLOOR - return rune(0x230b), true + return {'\u230b', 0}, 1, true case "rfr": // MATHEMATICAL FRAKTUR SMALL R - return rune(0x01d52f), true + return {'\U0001d52f', 0}, 1, true case "rftimes": // TIMES WITH RIGHT HALF BLACK - return rune(0x29d5), true + return {'\u29d5', 0}, 1, true case "rgr": // GREEK SMALL LETTER RHO - return rune(0x03c1), true + return {'\u03c1', 0}, 1, true case "rhard": // RIGHTWARDS HARPOON WITH BARB DOWNWARDS - return rune(0x21c1), true + return {'\u21c1', 0}, 1, true case "rharu": // RIGHTWARDS HARPOON WITH BARB UPWARDS - return rune(0x21c0), true + return {'\u21c0', 0}, 1, true case "rharul": // RIGHTWARDS HARPOON WITH BARB UP ABOVE LONG DASH - return rune(0x296c), true + return {'\u296c', 0}, 1, true case "rho": // GREEK SMALL LETTER RHO - return rune(0x03c1), true + return {'\u03c1', 0}, 1, true case "rhov": // GREEK RHO SYMBOL - return rune(0x03f1), true + return {'\u03f1', 0}, 1, true case "rightarrow": // RIGHTWARDS ARROW - return rune(0x2192), true + return {'\u2192', 0}, 1, true case "rightarrowtail": // RIGHTWARDS ARROW WITH TAIL - return rune(0x21a3), true + return {'\u21a3', 0}, 1, true case "rightharpoondown": // RIGHTWARDS HARPOON WITH BARB DOWNWARDS - return rune(0x21c1), true + return {'\u21c1', 0}, 1, true case "rightharpoonup": // RIGHTWARDS HARPOON WITH BARB UPWARDS - return rune(0x21c0), true + return {'\u21c0', 0}, 1, true case "rightleftarrows": // RIGHTWARDS ARROW OVER LEFTWARDS ARROW - return rune(0x21c4), true + return {'\u21c4', 0}, 1, true case "rightleftharpoons": // RIGHTWARDS HARPOON OVER LEFTWARDS HARPOON - return rune(0x21cc), true + return {'\u21cc', 0}, 1, true case "rightrightarrows": // RIGHTWARDS PAIRED ARROWS - return rune(0x21c9), true + return {'\u21c9', 0}, 1, true case "rightsquigarrow": // RIGHTWARDS WAVE ARROW - return rune(0x219d), true + return {'\u219d', 0}, 1, true case "rightthreetimes": // RIGHT SEMIDIRECT PRODUCT - return rune(0x22cc), true + return {'\u22cc', 0}, 1, true case "rimply": // RIGHT DOUBLE ARROW WITH ROUNDED HEAD - return rune(0x2970), true + return {'\u2970', 0}, 1, true case "ring": // RING ABOVE - return rune(0x02da), true + return {'\u02da', 0}, 1, true case "risingdotseq": // IMAGE OF OR APPROXIMATELY EQUAL TO - return rune(0x2253), true + return {'\u2253', 0}, 1, true case "rlarr": // RIGHTWARDS ARROW OVER LEFTWARDS ARROW - return rune(0x21c4), true + return {'\u21c4', 0}, 1, true case "rlarr2": // RIGHTWARDS ARROW OVER LEFTWARDS ARROW - return rune(0x21c4), true + return {'\u21c4', 0}, 1, true case "rlhar": // RIGHTWARDS HARPOON OVER LEFTWARDS HARPOON - return rune(0x21cc), true + return {'\u21cc', 0}, 1, true case "rlhar2": // RIGHTWARDS HARPOON OVER LEFTWARDS HARPOON - return rune(0x21cc), true + return {'\u21cc', 0}, 1, true case "rlm": // RIGHT-TO-LEFT MARK - return rune(0x200f), true + return {'\u200f', 0}, 1, true case "rmoust": // UPPER RIGHT OR LOWER LEFT CURLY BRACKET SECTION - return rune(0x23b1), true + return {'\u23b1', 0}, 1, true case "rmoustache": // UPPER RIGHT OR LOWER LEFT CURLY BRACKET SECTION - return rune(0x23b1), true + return {'\u23b1', 0}, 1, true case "rnmid": // DOES NOT DIVIDE WITH REVERSED NEGATION SLASH - return rune(0x2aee), true + return {'\u2aee', 0}, 1, true case "roang": // MATHEMATICAL RIGHT WHITE TORTOISE SHELL BRACKET - return rune(0x27ed), true + return {'\u27ed', 0}, 1, true case "roarr": // RIGHTWARDS OPEN-HEADED ARROW - return rune(0x21fe), true + return {'\u21fe', 0}, 1, true case "robrk": // MATHEMATICAL RIGHT WHITE SQUARE BRACKET - return rune(0x27e7), true + return {'\u27e7', 0}, 1, true case "rocub": // RIGHT WHITE CURLY BRACKET - return rune(0x2984), true + return {'\u2984', 0}, 1, true case "ropar": // RIGHT WHITE PARENTHESIS - return rune(0x2986), true + return {'\u2986', 0}, 1, true case "ropf": // MATHEMATICAL DOUBLE-STRUCK SMALL R - return rune(0x01d563), true + return {'\U0001d563', 0}, 1, true case "roplus": // PLUS SIGN IN RIGHT HALF CIRCLE - return rune(0x2a2e), true + return {'\u2a2e', 0}, 1, true case "rotimes": // MULTIPLICATION SIGN IN RIGHT HALF CIRCLE - return rune(0x2a35), true + return {'\u2a35', 0}, 1, true case "rpar": // RIGHT PARENTHESIS - return rune(0x29), true + return {')', 0}, 1, true case "rpargt": // RIGHT ARC GREATER-THAN BRACKET - return rune(0x2994), true + return {'\u2994', 0}, 1, true case "rppolint": // LINE INTEGRATION WITH RECTANGULAR PATH AROUND POLE - return rune(0x2a12), true + return {'\u2a12', 0}, 1, true case "rrarr": // RIGHTWARDS PAIRED ARROWS - return rune(0x21c9), true + return {'\u21c9', 0}, 1, true case "rsaquo": // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK - return rune(0x203a), true + return {'\u203a', 0}, 1, true case "rscr": // MATHEMATICAL SCRIPT SMALL R - return rune(0x01d4c7), true + return {'\U0001d4c7', 0}, 1, true case "rsh": // UPWARDS ARROW WITH TIP RIGHTWARDS - return rune(0x21b1), true + return {'\u21b1', 0}, 1, true case "rsolbar": // REVERSE SOLIDUS WITH HORIZONTAL STROKE - return rune(0x29f7), true + return {'\u29f7', 0}, 1, true case "rsqb": // RIGHT SQUARE BRACKET - return rune(0x5d), true + return {']', 0}, 1, true case "rsquo": // RIGHT SINGLE QUOTATION MARK - return rune(0x2019), true + return {'\u2019', 0}, 1, true case "rsquor": // RIGHT SINGLE QUOTATION MARK - return rune(0x2019), true + return {'\u2019', 0}, 1, true case "rthree": // RIGHT SEMIDIRECT PRODUCT - return rune(0x22cc), true + return {'\u22cc', 0}, 1, true case "rtimes": // RIGHT NORMAL FACTOR SEMIDIRECT PRODUCT - return rune(0x22ca), true + return {'\u22ca', 0}, 1, true case "rtri": // WHITE RIGHT-POINTING SMALL TRIANGLE - return rune(0x25b9), true + return {'\u25b9', 0}, 1, true case "rtrie": // CONTAINS AS NORMAL SUBGROUP OR EQUAL TO - return rune(0x22b5), true + return {'\u22b5', 0}, 1, true case "rtrif": // BLACK RIGHT-POINTING SMALL TRIANGLE - return rune(0x25b8), true + return {'\u25b8', 0}, 1, true case "rtriltri": // RIGHT TRIANGLE ABOVE LEFT TRIANGLE - return rune(0x29ce), true + return {'\u29ce', 0}, 1, true case "ruharb": // RIGHTWARDS HARPOON WITH BARB UP TO BAR - return rune(0x2953), true + return {'\u2953', 0}, 1, true case "ruluhar": // RIGHTWARDS HARPOON WITH BARB UP ABOVE LEFTWARDS HARPOON WITH BARB UP - return rune(0x2968), true + return {'\u2968', 0}, 1, true case "rx": // PRESCRIPTION TAKE - return rune(0x211e), true + return {'\u211e', 0}, 1, true } case 's': switch name { case "sacute": // LATIN SMALL LETTER S WITH ACUTE - return rune(0x015b), true + return {'\u015b', 0}, 1, true case "samalg": // N-ARY COPRODUCT - return rune(0x2210), true + return {'\u2210', 0}, 1, true case "sampi": // GREEK LETTER SAMPI - return rune(0x03e0), true + return {'\u03e0', 0}, 1, true case "sbquo": // SINGLE LOW-9 QUOTATION MARK - return rune(0x201a), true + return {'\u201a', 0}, 1, true case "sbsol": // SMALL REVERSE SOLIDUS - return rune(0xfe68), true + return {'\ufe68', 0}, 1, true case "sc": // SUCCEEDS - return rune(0x227b), true + return {'\u227b', 0}, 1, true case "scE": // SUCCEEDS ABOVE EQUALS SIGN - return rune(0x2ab4), true + return {'\u2ab4', 0}, 1, true case "scap": // SUCCEEDS ABOVE ALMOST EQUAL TO - return rune(0x2ab8), true + return {'\u2ab8', 0}, 1, true case "scaron": // LATIN SMALL LETTER S WITH CARON - return rune(0x0161), true + return {'\u0161', 0}, 1, true case "sccue": // SUCCEEDS OR EQUAL TO - return rune(0x227d), true + return {'\u227d', 0}, 1, true case "sce": // SUCCEEDS ABOVE SINGLE-LINE EQUALS SIGN - return rune(0x2ab0), true + return {'\u2ab0', 0}, 1, true case "scedil": // LATIN SMALL LETTER S WITH CEDILLA - return rune(0x015f), true + return {'\u015f', 0}, 1, true case "scirc": // LATIN SMALL LETTER S WITH CIRCUMFLEX - return rune(0x015d), true + return {'\u015d', 0}, 1, true case "scnE": // SUCCEEDS ABOVE NOT EQUAL TO - return rune(0x2ab6), true + return {'\u2ab6', 0}, 1, true case "scnap": // SUCCEEDS ABOVE NOT ALMOST EQUAL TO - return rune(0x2aba), true + return {'\u2aba', 0}, 1, true case "scnsim": // SUCCEEDS BUT NOT EQUIVALENT TO - return rune(0x22e9), true + return {'\u22e9', 0}, 1, true case "scpolint": // LINE INTEGRATION WITH SEMICIRCULAR PATH AROUND POLE - return rune(0x2a13), true + return {'\u2a13', 0}, 1, true case "scsim": // SUCCEEDS OR EQUIVALENT TO - return rune(0x227f), true + return {'\u227f', 0}, 1, true case "scy": // CYRILLIC SMALL LETTER ES - return rune(0x0441), true + return {'\u0441', 0}, 1, true case "sdot": // DOT OPERATOR - return rune(0x22c5), true + return {'\u22c5', 0}, 1, true case "sdotb": // SQUARED DOT OPERATOR - return rune(0x22a1), true + return {'\u22a1', 0}, 1, true case "sdote": // EQUALS SIGN WITH DOT BELOW - return rune(0x2a66), true + return {'\u2a66', 0}, 1, true case "seArr": // SOUTH EAST DOUBLE ARROW - return rune(0x21d8), true + return {'\u21d8', 0}, 1, true case "searhk": // SOUTH EAST ARROW WITH HOOK - return rune(0x2925), true + return {'\u2925', 0}, 1, true case "searr": // SOUTH EAST ARROW - return rune(0x2198), true + return {'\u2198', 0}, 1, true case "searrow": // SOUTH EAST ARROW - return rune(0x2198), true + return {'\u2198', 0}, 1, true case "sect": // SECTION SIGN - return rune(0xa7), true + return {'§', 0}, 1, true case "semi": // SEMICOLON - return rune(0x3b), true + return {';', 0}, 1, true case "seonearr": // SOUTH EAST ARROW CROSSING NORTH EAST ARROW - return rune(0x292d), true + return {'\u292d', 0}, 1, true case "seswar": // SOUTH EAST ARROW AND SOUTH WEST ARROW - return rune(0x2929), true + return {'\u2929', 0}, 1, true case "setminus": // SET MINUS - return rune(0x2216), true + return {'\u2216', 0}, 1, true case "setmn": // SET MINUS - return rune(0x2216), true + return {'\u2216', 0}, 1, true case "sext": // SIX POINTED BLACK STAR - return rune(0x2736), true + return {'\u2736', 0}, 1, true case "sfgr": // GREEK SMALL LETTER FINAL SIGMA - return rune(0x03c2), true + return {'\u03c2', 0}, 1, true case "sfr": // MATHEMATICAL FRAKTUR SMALL S - return rune(0x01d530), true + return {'\U0001d530', 0}, 1, true case "sfrown": // FROWN - return rune(0x2322), true + return {'\u2322', 0}, 1, true case "sgr": // GREEK SMALL LETTER SIGMA - return rune(0x03c3), true + return {'\u03c3', 0}, 1, true case "sharp": // MUSIC SHARP SIGN - return rune(0x266f), true + return {'\u266f', 0}, 1, true case "shchcy": // CYRILLIC SMALL LETTER SHCHA - return rune(0x0449), true + return {'\u0449', 0}, 1, true case "shcy": // CYRILLIC SMALL LETTER SHA - return rune(0x0448), true + return {'\u0448', 0}, 1, true case "shortmid": // DIVIDES - return rune(0x2223), true + return {'\u2223', 0}, 1, true case "shortparallel": // PARALLEL TO - return rune(0x2225), true + return {'\u2225', 0}, 1, true case "shuffle": // SHUFFLE PRODUCT - return rune(0x29e2), true + return {'\u29e2', 0}, 1, true case "shy": // SOFT HYPHEN - return rune(0xad), true + return {'\u00ad', 0}, 1, true case "sigma": // GREEK SMALL LETTER SIGMA - return rune(0x03c3), true + return {'\u03c3', 0}, 1, true case "sigmaf": // GREEK SMALL LETTER FINAL SIGMA - return rune(0x03c2), true + return {'\u03c2', 0}, 1, true case "sigmav": // GREEK SMALL LETTER FINAL SIGMA - return rune(0x03c2), true + return {'\u03c2', 0}, 1, true case "sim": // TILDE OPERATOR - return rune(0x223c), true + return {'\u223c', 0}, 1, true case "simdot": // TILDE OPERATOR WITH DOT ABOVE - return rune(0x2a6a), true + return {'\u2a6a', 0}, 1, true case "sime": // ASYMPTOTICALLY EQUAL TO - return rune(0x2243), true + return {'\u2243', 0}, 1, true case "simeq": // ASYMPTOTICALLY EQUAL TO - return rune(0x2243), true + return {'\u2243', 0}, 1, true case "simg": // SIMILAR OR GREATER-THAN - return rune(0x2a9e), true + return {'\u2a9e', 0}, 1, true case "simgE": // SIMILAR ABOVE GREATER-THAN ABOVE EQUALS SIGN - return rune(0x2aa0), true + return {'\u2aa0', 0}, 1, true case "siml": // SIMILAR OR LESS-THAN - return rune(0x2a9d), true + return {'\u2a9d', 0}, 1, true case "simlE": // SIMILAR ABOVE LESS-THAN ABOVE EQUALS SIGN - return rune(0x2a9f), true + return {'\u2a9f', 0}, 1, true case "simne": // APPROXIMATELY BUT NOT ACTUALLY EQUAL TO - return rune(0x2246), true + return {'\u2246', 0}, 1, true case "simplus": // PLUS SIGN WITH TILDE ABOVE - return rune(0x2a24), true + return {'\u2a24', 0}, 1, true case "simrarr": // TILDE OPERATOR ABOVE RIGHTWARDS ARROW - return rune(0x2972), true + return {'\u2972', 0}, 1, true case "slarr": // LEFTWARDS ARROW - return rune(0x2190), true + return {'\u2190', 0}, 1, true case "slint": // INTEGRAL AVERAGE WITH SLASH - return rune(0x2a0f), true + return {'\u2a0f', 0}, 1, true case "smallsetminus": // SET MINUS - return rune(0x2216), true + return {'\u2216', 0}, 1, true case "smashp": // SMASH PRODUCT - return rune(0x2a33), true + return {'\u2a33', 0}, 1, true case "smeparsl": // EQUALS SIGN AND SLANTED PARALLEL WITH TILDE ABOVE - return rune(0x29e4), true + return {'\u29e4', 0}, 1, true case "smid": // DIVIDES - return rune(0x2223), true + return {'\u2223', 0}, 1, true case "smile": // SMILE - return rune(0x2323), true + return {'\u2323', 0}, 1, true case "smt": // SMALLER THAN - return rune(0x2aaa), true + return {'\u2aaa', 0}, 1, true case "smte": // SMALLER THAN OR EQUAL TO - return rune(0x2aac), true + return {'\u2aac', 0}, 1, true case "smtes": // SMALLER THAN OR slanted EQUAL - return rune(0x2aac), true + return {'\u2aac', '\ufe00'}, 2, true case "softcy": // CYRILLIC SMALL LETTER SOFT SIGN - return rune(0x044c), true + return {'\u044c', 0}, 1, true case "sol": // SOLIDUS - return rune(0x2f), true + return {'/', 0}, 1, true case "solb": // SQUARED RISING DIAGONAL SLASH - return rune(0x29c4), true + return {'\u29c4', 0}, 1, true case "solbar": // APL FUNCTIONAL SYMBOL SLASH BAR - return rune(0x233f), true + return {'\u233f', 0}, 1, true case "sopf": // MATHEMATICAL DOUBLE-STRUCK SMALL S - return rune(0x01d564), true + return {'\U0001d564', 0}, 1, true case "spades": // BLACK SPADE SUIT - return rune(0x2660), true + return {'\u2660', 0}, 1, true case "spadesuit": // BLACK SPADE SUIT - return rune(0x2660), true + return {'\u2660', 0}, 1, true case "spar": // PARALLEL TO - return rune(0x2225), true + return {'\u2225', 0}, 1, true case "sqcap": // SQUARE CAP - return rune(0x2293), true + return {'\u2293', 0}, 1, true case "sqcaps": // SQUARE CAP with serifs - return rune(0x2293), true + return {'\u2293', '\ufe00'}, 2, true case "sqcup": // SQUARE CUP - return rune(0x2294), true + return {'\u2294', 0}, 1, true case "sqcups": // SQUARE CUP with serifs - return rune(0x2294), true + return {'\u2294', '\ufe00'}, 2, true case "sqsub": // SQUARE IMAGE OF - return rune(0x228f), true + return {'\u228f', 0}, 1, true case "sqsube": // SQUARE IMAGE OF OR EQUAL TO - return rune(0x2291), true + return {'\u2291', 0}, 1, true case "sqsubset": // SQUARE IMAGE OF - return rune(0x228f), true + return {'\u228f', 0}, 1, true case "sqsubseteq": // SQUARE IMAGE OF OR EQUAL TO - return rune(0x2291), true + return {'\u2291', 0}, 1, true case "sqsup": // SQUARE ORIGINAL OF - return rune(0x2290), true + return {'\u2290', 0}, 1, true case "sqsupe": // SQUARE ORIGINAL OF OR EQUAL TO - return rune(0x2292), true + return {'\u2292', 0}, 1, true case "sqsupset": // SQUARE ORIGINAL OF - return rune(0x2290), true + return {'\u2290', 0}, 1, true case "sqsupseteq": // SQUARE ORIGINAL OF OR EQUAL TO - return rune(0x2292), true + return {'\u2292', 0}, 1, true case "squ": // WHITE SQUARE - return rune(0x25a1), true + return {'\u25a1', 0}, 1, true case "square": // WHITE SQUARE - return rune(0x25a1), true + return {'\u25a1', 0}, 1, true case "squarf": // BLACK SMALL SQUARE - return rune(0x25aa), true + return {'\u25aa', 0}, 1, true case "squb": // SQUARED SQUARE - return rune(0x29c8), true + return {'\u29c8', 0}, 1, true case "squerr": // ERROR-BARRED WHITE SQUARE - return rune(0x29ee), true + return {'\u29ee', 0}, 1, true case "squf": // BLACK SMALL SQUARE - return rune(0x25aa), true + return {'\u25aa', 0}, 1, true case "squferr": // ERROR-BARRED BLACK SQUARE - return rune(0x29ef), true + return {'\u29ef', 0}, 1, true case "srarr": // RIGHTWARDS ARROW - return rune(0x2192), true + return {'\u2192', 0}, 1, true case "sscr": // MATHEMATICAL SCRIPT SMALL S - return rune(0x01d4c8), true + return {'\U0001d4c8', 0}, 1, true case "ssetmn": // SET MINUS - return rune(0x2216), true + return {'\u2216', 0}, 1, true case "ssmile": // SMILE - return rune(0x2323), true + return {'\u2323', 0}, 1, true case "sstarf": // STAR OPERATOR - return rune(0x22c6), true + return {'\u22c6', 0}, 1, true case "star": // WHITE STAR - return rune(0x2606), true + return {'\u2606', 0}, 1, true case "starf": // BLACK STAR - return rune(0x2605), true + return {'\u2605', 0}, 1, true case "stigma": // GREEK LETTER STIGMA - return rune(0x03da), true + return {'\u03da', 0}, 1, true case "straightepsilon": // GREEK LUNATE EPSILON SYMBOL - return rune(0x03f5), true + return {'\u03f5', 0}, 1, true case "straightphi": // GREEK PHI SYMBOL - return rune(0x03d5), true + return {'\u03d5', 0}, 1, true case "strns": // MACRON - return rune(0xaf), true + return {'¯', 0}, 1, true case "sub": // SUBSET OF - return rune(0x2282), true + return {'\u2282', 0}, 1, true case "subE": // SUBSET OF ABOVE EQUALS SIGN - return rune(0x2ac5), true + return {'\u2ac5', 0}, 1, true case "subdot": // SUBSET WITH DOT - return rune(0x2abd), true + return {'\u2abd', 0}, 1, true case "sube": // SUBSET OF OR EQUAL TO - return rune(0x2286), true + return {'\u2286', 0}, 1, true case "subedot": // SUBSET OF OR EQUAL TO WITH DOT ABOVE - return rune(0x2ac3), true + return {'\u2ac3', 0}, 1, true case "submult": // SUBSET WITH MULTIPLICATION SIGN BELOW - return rune(0x2ac1), true + return {'\u2ac1', 0}, 1, true case "subnE": // SUBSET OF ABOVE NOT EQUAL TO - return rune(0x2acb), true + return {'\u2acb', 0}, 1, true case "subne": // SUBSET OF WITH NOT EQUAL TO - return rune(0x228a), true + return {'\u228a', 0}, 1, true case "subplus": // SUBSET WITH PLUS SIGN BELOW - return rune(0x2abf), true + return {'\u2abf', 0}, 1, true case "subrarr": // SUBSET ABOVE RIGHTWARDS ARROW - return rune(0x2979), true + return {'\u2979', 0}, 1, true case "subset": // SUBSET OF - return rune(0x2282), true + return {'\u2282', 0}, 1, true case "subseteq": // SUBSET OF OR EQUAL TO - return rune(0x2286), true + return {'\u2286', 0}, 1, true case "subseteqq": // SUBSET OF ABOVE EQUALS SIGN - return rune(0x2ac5), true + return {'\u2ac5', 0}, 1, true case "subsetneq": // SUBSET OF WITH NOT EQUAL TO - return rune(0x228a), true + return {'\u228a', 0}, 1, true case "subsetneqq": // SUBSET OF ABOVE NOT EQUAL TO - return rune(0x2acb), true + return {'\u2acb', 0}, 1, true case "subsim": // SUBSET OF ABOVE TILDE OPERATOR - return rune(0x2ac7), true + return {'\u2ac7', 0}, 1, true case "subsub": // SUBSET ABOVE SUBSET - return rune(0x2ad5), true + return {'\u2ad5', 0}, 1, true case "subsup": // SUBSET ABOVE SUPERSET - return rune(0x2ad3), true + return {'\u2ad3', 0}, 1, true case "succ": // SUCCEEDS - return rune(0x227b), true + return {'\u227b', 0}, 1, true case "succapprox": // SUCCEEDS ABOVE ALMOST EQUAL TO - return rune(0x2ab8), true + return {'\u2ab8', 0}, 1, true case "succcurlyeq": // SUCCEEDS OR EQUAL TO - return rune(0x227d), true + return {'\u227d', 0}, 1, true case "succeq": // SUCCEEDS ABOVE SINGLE-LINE EQUALS SIGN - return rune(0x2ab0), true + return {'\u2ab0', 0}, 1, true case "succnapprox": // SUCCEEDS ABOVE NOT ALMOST EQUAL TO - return rune(0x2aba), true + return {'\u2aba', 0}, 1, true case "succneqq": // SUCCEEDS ABOVE NOT EQUAL TO - return rune(0x2ab6), true + return {'\u2ab6', 0}, 1, true case "succnsim": // SUCCEEDS BUT NOT EQUIVALENT TO - return rune(0x22e9), true + return {'\u22e9', 0}, 1, true case "succsim": // SUCCEEDS OR EQUIVALENT TO - return rune(0x227f), true + return {'\u227f', 0}, 1, true case "sum": // N-ARY SUMMATION - return rune(0x2211), true + return {'\u2211', 0}, 1, true case "sumint": // SUMMATION WITH INTEGRAL - return rune(0x2a0b), true + return {'\u2a0b', 0}, 1, true case "sung": // EIGHTH NOTE - return rune(0x266a), true + return {'\u266a', 0}, 1, true case "sup": // SUPERSET OF - return rune(0x2283), true + return {'\u2283', 0}, 1, true case "sup1": // SUPERSCRIPT ONE - return rune(0xb9), true + return {'¹', 0}, 1, true case "sup2": // SUPERSCRIPT TWO - return rune(0xb2), true + return {'²', 0}, 1, true case "sup3": // SUPERSCRIPT THREE - return rune(0xb3), true + return {'³', 0}, 1, true case "supE": // SUPERSET OF ABOVE EQUALS SIGN - return rune(0x2ac6), true + return {'\u2ac6', 0}, 1, true case "supdot": // SUPERSET WITH DOT - return rune(0x2abe), true + return {'\u2abe', 0}, 1, true case "supdsub": // SUPERSET BESIDE AND JOINED BY DASH WITH SUBSET - return rune(0x2ad8), true + return {'\u2ad8', 0}, 1, true case "supe": // SUPERSET OF OR EQUAL TO - return rune(0x2287), true + return {'\u2287', 0}, 1, true case "supedot": // SUPERSET OF OR EQUAL TO WITH DOT ABOVE - return rune(0x2ac4), true + return {'\u2ac4', 0}, 1, true case "suphsol": // SUPERSET PRECEDING SOLIDUS - return rune(0x27c9), true + return {'\u27c9', 0}, 1, true case "suphsub": // SUPERSET BESIDE SUBSET - return rune(0x2ad7), true + return {'\u2ad7', 0}, 1, true case "suplarr": // SUPERSET ABOVE LEFTWARDS ARROW - return rune(0x297b), true + return {'\u297b', 0}, 1, true case "supmult": // SUPERSET WITH MULTIPLICATION SIGN BELOW - return rune(0x2ac2), true + return {'\u2ac2', 0}, 1, true case "supnE": // SUPERSET OF ABOVE NOT EQUAL TO - return rune(0x2acc), true + return {'\u2acc', 0}, 1, true case "supne": // SUPERSET OF WITH NOT EQUAL TO - return rune(0x228b), true + return {'\u228b', 0}, 1, true case "supplus": // SUPERSET WITH PLUS SIGN BELOW - return rune(0x2ac0), true + return {'\u2ac0', 0}, 1, true case "supset": // SUPERSET OF - return rune(0x2283), true + return {'\u2283', 0}, 1, true case "supseteq": // SUPERSET OF OR EQUAL TO - return rune(0x2287), true + return {'\u2287', 0}, 1, true case "supseteqq": // SUPERSET OF ABOVE EQUALS SIGN - return rune(0x2ac6), true + return {'\u2ac6', 0}, 1, true case "supsetneq": // SUPERSET OF WITH NOT EQUAL TO - return rune(0x228b), true + return {'\u228b', 0}, 1, true case "supsetneqq": // SUPERSET OF ABOVE NOT EQUAL TO - return rune(0x2acc), true + return {'\u2acc', 0}, 1, true case "supsim": // SUPERSET OF ABOVE TILDE OPERATOR - return rune(0x2ac8), true + return {'\u2ac8', 0}, 1, true case "supsub": // SUPERSET ABOVE SUBSET - return rune(0x2ad4), true + return {'\u2ad4', 0}, 1, true case "supsup": // SUPERSET ABOVE SUPERSET - return rune(0x2ad6), true + return {'\u2ad6', 0}, 1, true case "swArr": // SOUTH WEST DOUBLE ARROW - return rune(0x21d9), true + return {'\u21d9', 0}, 1, true case "swarhk": // SOUTH WEST ARROW WITH HOOK - return rune(0x2926), true + return {'\u2926', 0}, 1, true case "swarr": // SOUTH WEST ARROW - return rune(0x2199), true + return {'\u2199', 0}, 1, true case "swarrow": // SOUTH WEST ARROW - return rune(0x2199), true + return {'\u2199', 0}, 1, true case "swnwar": // SOUTH WEST ARROW AND NORTH WEST ARROW - return rune(0x292a), true + return {'\u292a', 0}, 1, true case "szlig": // LATIN SMALL LETTER SHARP S - return rune(0xdf), true + return {'ß', 0}, 1, true } case 't': switch name { case "target": // POSITION INDICATOR - return rune(0x2316), true + return {'\u2316', 0}, 1, true case "tau": // GREEK SMALL LETTER TAU - return rune(0x03c4), true + return {'\u03c4', 0}, 1, true case "tbrk": // TOP SQUARE BRACKET - return rune(0x23b4), true + return {'\u23b4', 0}, 1, true case "tcaron": // LATIN SMALL LETTER T WITH CARON - return rune(0x0165), true + return {'\u0165', 0}, 1, true case "tcedil": // LATIN SMALL LETTER T WITH CEDILLA - return rune(0x0163), true + return {'\u0163', 0}, 1, true case "tcy": // CYRILLIC SMALL LETTER TE - return rune(0x0442), true + return {'\u0442', 0}, 1, true case "tdot": // COMBINING THREE DOTS ABOVE - return rune(0x20db), true + return {'\u20db', 0}, 1, true case "telrec": // TELEPHONE RECORDER - return rune(0x2315), true + return {'\u2315', 0}, 1, true case "tfr": // MATHEMATICAL FRAKTUR SMALL T - return rune(0x01d531), true + return {'\U0001d531', 0}, 1, true case "tgr": // GREEK SMALL LETTER TAU - return rune(0x03c4), true + return {'\u03c4', 0}, 1, true case "there4": // THEREFORE - return rune(0x2234), true + return {'\u2234', 0}, 1, true case "therefore": // THEREFORE - return rune(0x2234), true + return {'\u2234', 0}, 1, true case "thermod": // THERMODYNAMIC - return rune(0x29e7), true + return {'\u29e7', 0}, 1, true case "theta": // GREEK SMALL LETTER THETA - return rune(0x03b8), true + return {'\u03b8', 0}, 1, true case "thetas": // GREEK SMALL LETTER THETA - return rune(0x03b8), true + return {'\u03b8', 0}, 1, true case "thetasym": // GREEK THETA SYMBOL - return rune(0x03d1), true + return {'\u03d1', 0}, 1, true case "thetav": // GREEK THETA SYMBOL - return rune(0x03d1), true + return {'\u03d1', 0}, 1, true case "thgr": // GREEK SMALL LETTER THETA - return rune(0x03b8), true + return {'\u03b8', 0}, 1, true case "thickapprox": // ALMOST EQUAL TO - return rune(0x2248), true + return {'\u2248', 0}, 1, true case "thicksim": // TILDE OPERATOR - return rune(0x223c), true + return {'\u223c', 0}, 1, true case "thinsp": // THIN SPACE - return rune(0x2009), true + return {'\u2009', 0}, 1, true case "thkap": // ALMOST EQUAL TO - return rune(0x2248), true + return {'\u2248', 0}, 1, true case "thksim": // TILDE OPERATOR - return rune(0x223c), true + return {'\u223c', 0}, 1, true case "thorn": // LATIN SMALL LETTER THORN - return rune(0xfe), true + return {'þ', 0}, 1, true case "tilde": // SMALL TILDE - return rune(0x02dc), true + return {'\u02dc', 0}, 1, true case "timeint": // INTEGRAL WITH TIMES SIGN - return rune(0x2a18), true + return {'\u2a18', 0}, 1, true case "times": // MULTIPLICATION SIGN - return rune(0xd7), true + return {'×', 0}, 1, true case "timesb": // SQUARED TIMES - return rune(0x22a0), true + return {'\u22a0', 0}, 1, true case "timesbar": // MULTIPLICATION SIGN WITH UNDERBAR - return rune(0x2a31), true + return {'\u2a31', 0}, 1, true case "timesd": // MULTIPLICATION SIGN WITH DOT ABOVE - return rune(0x2a30), true + return {'\u2a30', 0}, 1, true case "tint": // TRIPLE INTEGRAL - return rune(0x222d), true + return {'\u222d', 0}, 1, true case "toea": // NORTH EAST ARROW AND SOUTH EAST ARROW - return rune(0x2928), true + return {'\u2928', 0}, 1, true case "top": // DOWN TACK - return rune(0x22a4), true + return {'\u22a4', 0}, 1, true case "topbot": // APL FUNCTIONAL SYMBOL I-BEAM - return rune(0x2336), true + return {'\u2336', 0}, 1, true case "topcir": // DOWN TACK WITH CIRCLE BELOW - return rune(0x2af1), true + return {'\u2af1', 0}, 1, true case "topf": // MATHEMATICAL DOUBLE-STRUCK SMALL T - return rune(0x01d565), true + return {'\U0001d565', 0}, 1, true case "topfork": // PITCHFORK WITH TEE TOP - return rune(0x2ada), true + return {'\u2ada', 0}, 1, true case "tosa": // SOUTH EAST ARROW AND SOUTH WEST ARROW - return rune(0x2929), true + return {'\u2929', 0}, 1, true case "tprime": // TRIPLE PRIME - return rune(0x2034), true + return {'\u2034', 0}, 1, true case "trade": // TRADE MARK SIGN - return rune(0x2122), true + return {'\u2122', 0}, 1, true case "triS": // S IN TRIANGLE - return rune(0x29cc), true + return {'\u29cc', 0}, 1, true case "triangle": // WHITE UP-POINTING SMALL TRIANGLE - return rune(0x25b5), true + return {'\u25b5', 0}, 1, true case "triangledown": // WHITE DOWN-POINTING SMALL TRIANGLE - return rune(0x25bf), true + return {'\u25bf', 0}, 1, true case "triangleleft": // WHITE LEFT-POINTING SMALL TRIANGLE - return rune(0x25c3), true + return {'\u25c3', 0}, 1, true case "trianglelefteq": // NORMAL SUBGROUP OF OR EQUAL TO - return rune(0x22b4), true + return {'\u22b4', 0}, 1, true case "triangleq": // DELTA EQUAL TO - return rune(0x225c), true + return {'\u225c', 0}, 1, true case "triangleright": // WHITE RIGHT-POINTING SMALL TRIANGLE - return rune(0x25b9), true + return {'\u25b9', 0}, 1, true case "trianglerighteq": // CONTAINS AS NORMAL SUBGROUP OR EQUAL TO - return rune(0x22b5), true + return {'\u22b5', 0}, 1, true case "tribar": // TRIANGLE WITH UNDERBAR - return rune(0x29cb), true + return {'\u29cb', 0}, 1, true case "tridot": // WHITE UP-POINTING TRIANGLE WITH DOT - return rune(0x25ec), true + return {'\u25ec', 0}, 1, true case "tridoto": // TRIANGLE WITH DOT ABOVE - return rune(0x29ca), true + return {'\u29ca', 0}, 1, true case "trie": // DELTA EQUAL TO - return rune(0x225c), true + return {'\u225c', 0}, 1, true case "triminus": // MINUS SIGN IN TRIANGLE - return rune(0x2a3a), true + return {'\u2a3a', 0}, 1, true case "triplus": // PLUS SIGN IN TRIANGLE - return rune(0x2a39), true + return {'\u2a39', 0}, 1, true case "trisb": // TRIANGLE WITH SERIFS AT BOTTOM - return rune(0x29cd), true + return {'\u29cd', 0}, 1, true case "tritime": // MULTIPLICATION SIGN IN TRIANGLE - return rune(0x2a3b), true + return {'\u2a3b', 0}, 1, true case "trpezium": // WHITE TRAPEZIUM - return rune(0x23e2), true + return {'\u23e2', 0}, 1, true case "tscr": // MATHEMATICAL SCRIPT SMALL T - return rune(0x01d4c9), true + return {'\U0001d4c9', 0}, 1, true case "tscy": // CYRILLIC SMALL LETTER TSE - return rune(0x0446), true + return {'\u0446', 0}, 1, true case "tshcy": // CYRILLIC SMALL LETTER TSHE - return rune(0x045b), true + return {'\u045b', 0}, 1, true case "tstrok": // LATIN SMALL LETTER T WITH STROKE - return rune(0x0167), true + return {'\u0167', 0}, 1, true case "tverbar": // TRIPLE VERTICAL BAR DELIMITER - return rune(0x2980), true + return {'\u2980', 0}, 1, true case "twixt": // BETWEEN - return rune(0x226c), true + return {'\u226c', 0}, 1, true case "twoheadleftarrow": // LEFTWARDS TWO HEADED ARROW - return rune(0x219e), true + return {'\u219e', 0}, 1, true case "twoheadrightarrow": // RIGHTWARDS TWO HEADED ARROW - return rune(0x21a0), true + return {'\u21a0', 0}, 1, true } case 'u': switch name { case "uAarr": // UPWARDS TRIPLE ARROW - return rune(0x290a), true + return {'\u290a', 0}, 1, true case "uArr": // UPWARDS DOUBLE ARROW - return rune(0x21d1), true + return {'\u21d1', 0}, 1, true case "uHar": // UPWARDS HARPOON WITH BARB LEFT BESIDE UPWARDS HARPOON WITH BARB RIGHT - return rune(0x2963), true + return {'\u2963', 0}, 1, true case "uacgr": // GREEK SMALL LETTER UPSILON WITH TONOS - return rune(0x03cd), true + return {'\u03cd', 0}, 1, true case "uacute": // LATIN SMALL LETTER U WITH ACUTE - return rune(0xfa), true + return {'ú', 0}, 1, true case "uarr": // UPWARDS ARROW - return rune(0x2191), true + return {'\u2191', 0}, 1, true case "uarr2": // UPWARDS PAIRED ARROWS - return rune(0x21c8), true + return {'\u21c8', 0}, 1, true case "uarrb": // UPWARDS ARROW TO BAR - return rune(0x2912), true + return {'\u2912', 0}, 1, true case "uarrln": // UPWARDS ARROW WITH HORIZONTAL STROKE - return rune(0x2909), true + return {'\u2909', 0}, 1, true case "ubrcy": // CYRILLIC SMALL LETTER SHORT U - return rune(0x045e), true + return {'\u045e', 0}, 1, true case "ubreve": // LATIN SMALL LETTER U WITH BREVE - return rune(0x016d), true + return {'\u016d', 0}, 1, true case "ucirc": // LATIN SMALL LETTER U WITH CIRCUMFLEX - return rune(0xfb), true + return {'û', 0}, 1, true case "ucy": // CYRILLIC SMALL LETTER U - return rune(0x0443), true + return {'\u0443', 0}, 1, true case "udarr": // UPWARDS ARROW LEFTWARDS OF DOWNWARDS ARROW - return rune(0x21c5), true + return {'\u21c5', 0}, 1, true case "udblac": // LATIN SMALL LETTER U WITH DOUBLE ACUTE - return rune(0x0171), true + return {'\u0171', 0}, 1, true case "udhar": // UPWARDS HARPOON WITH BARB LEFT BESIDE DOWNWARDS HARPOON WITH BARB RIGHT - return rune(0x296e), true + return {'\u296e', 0}, 1, true case "udiagr": // GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS - return rune(0x03b0), true + return {'\u03b0', 0}, 1, true case "udigr": // GREEK SMALL LETTER UPSILON WITH DIALYTIKA - return rune(0x03cb), true + return {'\u03cb', 0}, 1, true case "udrbrk": // BOTTOM SQUARE BRACKET - return rune(0x23b5), true + return {'\u23b5', 0}, 1, true case "udrcub": // BOTTOM CURLY BRACKET - return rune(0x23df), true + return {'\u23df', 0}, 1, true case "udrpar": // BOTTOM PARENTHESIS - return rune(0x23dd), true + return {'\u23dd', 0}, 1, true case "ufisht": // UP FISH TAIL - return rune(0x297e), true + return {'\u297e', 0}, 1, true case "ufr": // MATHEMATICAL FRAKTUR SMALL U - return rune(0x01d532), true + return {'\U0001d532', 0}, 1, true case "ugr": // GREEK SMALL LETTER UPSILON - return rune(0x03c5), true + return {'\u03c5', 0}, 1, true case "ugrave": // LATIN SMALL LETTER U WITH GRAVE - return rune(0xf9), true + return {'ù', 0}, 1, true case "uharl": // UPWARDS HARPOON WITH BARB LEFTWARDS - return rune(0x21bf), true + return {'\u21bf', 0}, 1, true case "uharr": // UPWARDS HARPOON WITH BARB RIGHTWARDS - return rune(0x21be), true + return {'\u21be', 0}, 1, true case "uhblk": // UPPER HALF BLOCK - return rune(0x2580), true + return {'\u2580', 0}, 1, true case "ulcorn": // TOP LEFT CORNER - return rune(0x231c), true + return {'\u231c', 0}, 1, true case "ulcorner": // TOP LEFT CORNER - return rune(0x231c), true + return {'\u231c', 0}, 1, true case "ulcrop": // TOP LEFT CROP - return rune(0x230f), true + return {'\u230f', 0}, 1, true case "uldlshar": // UP BARB LEFT DOWN BARB LEFT HARPOON - return rune(0x2951), true + return {'\u2951', 0}, 1, true case "ulharb": // UPWARDS HARPOON WITH BARB LEFT TO BAR - return rune(0x2958), true + return {'\u2958', 0}, 1, true case "ultri": // UPPER LEFT TRIANGLE - return rune(0x25f8), true + return {'\u25f8', 0}, 1, true case "umacr": // LATIN SMALL LETTER U WITH MACRON - return rune(0x016b), true + return {'\u016b', 0}, 1, true case "uml": // DIAERESIS - return rune(0xa8), true + return {'¨', 0}, 1, true case "uogon": // LATIN SMALL LETTER U WITH OGONEK - return rune(0x0173), true + return {'\u0173', 0}, 1, true case "uopf": // MATHEMATICAL DOUBLE-STRUCK SMALL U - return rune(0x01d566), true + return {'\U0001d566', 0}, 1, true case "uparrow": // UPWARDS ARROW - return rune(0x2191), true + return {'\u2191', 0}, 1, true case "updownarrow": // UP DOWN ARROW - return rune(0x2195), true + return {'\u2195', 0}, 1, true case "upharpoonleft": // UPWARDS HARPOON WITH BARB LEFTWARDS - return rune(0x21bf), true + return {'\u21bf', 0}, 1, true case "upharpoonright": // UPWARDS HARPOON WITH BARB RIGHTWARDS - return rune(0x21be), true + return {'\u21be', 0}, 1, true case "upint": // INTEGRAL WITH OVERBAR - return rune(0x2a1b), true + return {'\u2a1b', 0}, 1, true case "uplus": // MULTISET UNION - return rune(0x228e), true + return {'\u228e', 0}, 1, true case "upsi": // GREEK SMALL LETTER UPSILON - return rune(0x03c5), true + return {'\u03c5', 0}, 1, true case "upsih": // GREEK UPSILON WITH HOOK SYMBOL - return rune(0x03d2), true + return {'\u03d2', 0}, 1, true case "upsilon": // GREEK SMALL LETTER UPSILON - return rune(0x03c5), true + return {'\u03c5', 0}, 1, true case "upuparrows": // UPWARDS PAIRED ARROWS - return rune(0x21c8), true + return {'\u21c8', 0}, 1, true case "urcorn": // TOP RIGHT CORNER - return rune(0x231d), true + return {'\u231d', 0}, 1, true case "urcorner": // TOP RIGHT CORNER - return rune(0x231d), true + return {'\u231d', 0}, 1, true case "urcrop": // TOP RIGHT CROP - return rune(0x230e), true + return {'\u230e', 0}, 1, true case "urdrshar": // UP BARB RIGHT DOWN BARB RIGHT HARPOON - return rune(0x294f), true + return {'\u294f', 0}, 1, true case "urharb": // UPWARDS HARPOON WITH BARB RIGHT TO BAR - return rune(0x2954), true + return {'\u2954', 0}, 1, true case "uring": // LATIN SMALL LETTER U WITH RING ABOVE - return rune(0x016f), true + return {'\u016f', 0}, 1, true case "urtri": // UPPER RIGHT TRIANGLE - return rune(0x25f9), true + return {'\u25f9', 0}, 1, true case "urtrif": // BLACK UPPER RIGHT TRIANGLE - return rune(0x25e5), true + return {'\u25e5', 0}, 1, true case "uscr": // MATHEMATICAL SCRIPT SMALL U - return rune(0x01d4ca), true + return {'\U0001d4ca', 0}, 1, true case "utdot": // UP RIGHT DIAGONAL ELLIPSIS - return rune(0x22f0), true + return {'\u22f0', 0}, 1, true case "utilde": // LATIN SMALL LETTER U WITH TILDE - return rune(0x0169), true + return {'\u0169', 0}, 1, true case "utri": // WHITE UP-POINTING SMALL TRIANGLE - return rune(0x25b5), true + return {'\u25b5', 0}, 1, true case "utrif": // BLACK UP-POINTING SMALL TRIANGLE - return rune(0x25b4), true + return {'\u25b4', 0}, 1, true case "uuarr": // UPWARDS PAIRED ARROWS - return rune(0x21c8), true + return {'\u21c8', 0}, 1, true case "uuml": // LATIN SMALL LETTER U WITH DIAERESIS - return rune(0xfc), true + return {'ü', 0}, 1, true case "uwangle": // OBLIQUE ANGLE OPENING DOWN - return rune(0x29a7), true + return {'\u29a7', 0}, 1, true } case 'v': switch name { case "vArr": // UP DOWN DOUBLE ARROW - return rune(0x21d5), true + return {'\u21d5', 0}, 1, true case "vBar": // SHORT UP TACK WITH UNDERBAR - return rune(0x2ae8), true + return {'\u2ae8', 0}, 1, true case "vBarv": // SHORT UP TACK ABOVE SHORT DOWN TACK - return rune(0x2ae9), true + return {'\u2ae9', 0}, 1, true case "vDash": // TRUE - return rune(0x22a8), true + return {'\u22a8', 0}, 1, true case "vDdash": // VERTICAL BAR TRIPLE RIGHT TURNSTILE - return rune(0x2ae2), true + return {'\u2ae2', 0}, 1, true case "vangrt": // RIGHT ANGLE VARIANT WITH SQUARE - return rune(0x299c), true + return {'\u299c', 0}, 1, true case "varepsilon": // GREEK LUNATE EPSILON SYMBOL - return rune(0x03f5), true + return {'\u03f5', 0}, 1, true case "varkappa": // GREEK KAPPA SYMBOL - return rune(0x03f0), true + return {'\u03f0', 0}, 1, true case "varnothing": // EMPTY SET - return rune(0x2205), true + return {'\u2205', 0}, 1, true case "varphi": // GREEK PHI SYMBOL - return rune(0x03d5), true + return {'\u03d5', 0}, 1, true case "varpi": // GREEK PI SYMBOL - return rune(0x03d6), true + return {'\u03d6', 0}, 1, true case "varpropto": // PROPORTIONAL TO - return rune(0x221d), true + return {'\u221d', 0}, 1, true case "varr": // UP DOWN ARROW - return rune(0x2195), true + return {'\u2195', 0}, 1, true case "varrho": // GREEK RHO SYMBOL - return rune(0x03f1), true + return {'\u03f1', 0}, 1, true case "varsigma": // GREEK SMALL LETTER FINAL SIGMA - return rune(0x03c2), true + return {'\u03c2', 0}, 1, true case "varsubsetneq": // SUBSET OF WITH NOT EQUAL TO - variant with stroke through bottom members - return rune(0x228a), true + return {'\u228a', '\ufe00'}, 2, true case "varsubsetneqq": // SUBSET OF ABOVE NOT EQUAL TO - variant with stroke through bottom members - return rune(0x2acb), true + return {'\u2acb', '\ufe00'}, 2, true case "varsupsetneq": // SUPERSET OF WITH NOT EQUAL TO - variant with stroke through bottom members - return rune(0x228b), true + return {'\u228b', '\ufe00'}, 2, true case "varsupsetneqq": // SUPERSET OF ABOVE NOT EQUAL TO - variant with stroke through bottom members - return rune(0x2acc), true + return {'\u2acc', '\ufe00'}, 2, true case "vartheta": // GREEK THETA SYMBOL - return rune(0x03d1), true + return {'\u03d1', 0}, 1, true case "vartriangleleft": // NORMAL SUBGROUP OF - return rune(0x22b2), true + return {'\u22b2', 0}, 1, true case "vartriangleright": // CONTAINS AS NORMAL SUBGROUP - return rune(0x22b3), true + return {'\u22b3', 0}, 1, true case "vbrtri": // VERTICAL BAR BESIDE RIGHT TRIANGLE - return rune(0x29d0), true + return {'\u29d0', 0}, 1, true case "vcy": // CYRILLIC SMALL LETTER VE - return rune(0x0432), true + return {'\u0432', 0}, 1, true case "vdash": // RIGHT TACK - return rune(0x22a2), true + return {'\u22a2', 0}, 1, true case "vee": // LOGICAL OR - return rune(0x2228), true + return {'\u2228', 0}, 1, true case "veeBar": // LOGICAL OR WITH DOUBLE UNDERBAR - return rune(0x2a63), true + return {'\u2a63', 0}, 1, true case "veebar": // XOR - return rune(0x22bb), true + return {'\u22bb', 0}, 1, true case "veeeq": // EQUIANGULAR TO - return rune(0x225a), true + return {'\u225a', 0}, 1, true case "vellip": // VERTICAL ELLIPSIS - return rune(0x22ee), true + return {'\u22ee', 0}, 1, true case "vellip4": // DOTTED FENCE - return rune(0x2999), true + return {'\u2999', 0}, 1, true case "vellipv": // TRIPLE COLON OPERATOR - return rune(0x2af6), true + return {'\u2af6', 0}, 1, true case "verbar": // VERTICAL LINE - return rune(0x7c), true + return {'|', 0}, 1, true case "vert": // VERTICAL LINE - return rune(0x7c), true + return {'|', 0}, 1, true case "vert3": // TRIPLE VERTICAL BAR BINARY RELATION - return rune(0x2af4), true + return {'\u2af4', 0}, 1, true case "vfr": // MATHEMATICAL FRAKTUR SMALL V - return rune(0x01d533), true + return {'\U0001d533', 0}, 1, true case "vldash": // LEFT SQUARE BRACKET LOWER CORNER - return rune(0x23a3), true + return {'\u23a3', 0}, 1, true case "vltri": // NORMAL SUBGROUP OF - return rune(0x22b2), true + return {'\u22b2', 0}, 1, true case "vnsub": // SUBSET OF with vertical line - return rune(0x2282), true + return {'\u2282', '\u20d2'}, 2, true case "vnsup": // SUPERSET OF with vertical line - return rune(0x2283), true + return {'\u2283', '\u20d2'}, 2, true case "vopf": // MATHEMATICAL DOUBLE-STRUCK SMALL V - return rune(0x01d567), true + return {'\U0001d567', 0}, 1, true case "vprime": // PRIME - return rune(0x2032), true + return {'\u2032', 0}, 1, true case "vprop": // PROPORTIONAL TO - return rune(0x221d), true + return {'\u221d', 0}, 1, true case "vrtri": // CONTAINS AS NORMAL SUBGROUP - return rune(0x22b3), true + return {'\u22b3', 0}, 1, true case "vscr": // MATHEMATICAL SCRIPT SMALL V - return rune(0x01d4cb), true + return {'\U0001d4cb', 0}, 1, true case "vsubnE": // SUBSET OF ABOVE NOT EQUAL TO - variant with stroke through bottom members - return rune(0x2acb), true + return {'\u2acb', '\ufe00'}, 2, true case "vsubne": // SUBSET OF WITH NOT EQUAL TO - variant with stroke through bottom members - return rune(0x228a), true + return {'\u228a', '\ufe00'}, 2, true case "vsupnE": // SUPERSET OF ABOVE NOT EQUAL TO - variant with stroke through bottom members - return rune(0x2acc), true + return {'\u2acc', '\ufe00'}, 2, true case "vsupne": // SUPERSET OF WITH NOT EQUAL TO - variant with stroke through bottom members - return rune(0x228b), true + return {'\u228b', '\ufe00'}, 2, true case "vzigzag": // VERTICAL ZIGZAG LINE - return rune(0x299a), true + return {'\u299a', 0}, 1, true } case 'w': switch name { case "wcirc": // LATIN SMALL LETTER W WITH CIRCUMFLEX - return rune(0x0175), true + return {'\u0175', 0}, 1, true case "wedbar": // LOGICAL AND WITH UNDERBAR - return rune(0x2a5f), true + return {'\u2a5f', 0}, 1, true case "wedge": // LOGICAL AND - return rune(0x2227), true + return {'\u2227', 0}, 1, true case "wedgeq": // ESTIMATES - return rune(0x2259), true + return {'\u2259', 0}, 1, true case "weierp": // SCRIPT CAPITAL P - return rune(0x2118), true + return {'\u2118', 0}, 1, true case "wfr": // MATHEMATICAL FRAKTUR SMALL W - return rune(0x01d534), true + return {'\U0001d534', 0}, 1, true case "wopf": // MATHEMATICAL DOUBLE-STRUCK SMALL W - return rune(0x01d568), true + return {'\U0001d568', 0}, 1, true case "wp": // SCRIPT CAPITAL P - return rune(0x2118), true + return {'\u2118', 0}, 1, true case "wr": // WREATH PRODUCT - return rune(0x2240), true + return {'\u2240', 0}, 1, true case "wreath": // WREATH PRODUCT - return rune(0x2240), true + return {'\u2240', 0}, 1, true case "wscr": // MATHEMATICAL SCRIPT SMALL W - return rune(0x01d4cc), true + return {'\U0001d4cc', 0}, 1, true } case 'x': switch name { case "xandand": // TWO LOGICAL AND OPERATOR - return rune(0x2a07), true + return {'\u2a07', 0}, 1, true case "xbsol": // BOX DRAWINGS LIGHT DIAGONAL UPPER RIGHT TO LOWER LEFT - return rune(0x2571), true + return {'\u2571', 0}, 1, true case "xcap": // N-ARY INTERSECTION - return rune(0x22c2), true + return {'\u22c2', 0}, 1, true case "xcirc": // LARGE CIRCLE - return rune(0x25ef), true + return {'\u25ef', 0}, 1, true case "xcup": // N-ARY UNION - return rune(0x22c3), true + return {'\u22c3', 0}, 1, true case "xcupdot": // N-ARY UNION OPERATOR WITH DOT - return rune(0x2a03), true + return {'\u2a03', 0}, 1, true case "xdtri": // WHITE DOWN-POINTING TRIANGLE - return rune(0x25bd), true + return {'\u25bd', 0}, 1, true case "xfr": // MATHEMATICAL FRAKTUR SMALL X - return rune(0x01d535), true + return {'\U0001d535', 0}, 1, true case "xgr": // GREEK SMALL LETTER XI - return rune(0x03be), true + return {'\u03be', 0}, 1, true case "xhArr": // LONG LEFT RIGHT DOUBLE ARROW - return rune(0x27fa), true + return {'\u27fa', 0}, 1, true case "xharr": // LONG LEFT RIGHT ARROW - return rune(0x27f7), true + return {'\u27f7', 0}, 1, true case "xi": // GREEK SMALL LETTER XI - return rune(0x03be), true + return {'\u03be', 0}, 1, true case "xlArr": // LONG LEFTWARDS DOUBLE ARROW - return rune(0x27f8), true + return {'\u27f8', 0}, 1, true case "xlarr": // LONG LEFTWARDS ARROW - return rune(0x27f5), true + return {'\u27f5', 0}, 1, true case "xmap": // LONG RIGHTWARDS ARROW FROM BAR - return rune(0x27fc), true + return {'\u27fc', 0}, 1, true case "xnis": // CONTAINS WITH VERTICAL BAR AT END OF HORIZONTAL STROKE - return rune(0x22fb), true + return {'\u22fb', 0}, 1, true case "xodot": // N-ARY CIRCLED DOT OPERATOR - return rune(0x2a00), true + return {'\u2a00', 0}, 1, true case "xopf": // MATHEMATICAL DOUBLE-STRUCK SMALL X - return rune(0x01d569), true + return {'\U0001d569', 0}, 1, true case "xoplus": // N-ARY CIRCLED PLUS OPERATOR - return rune(0x2a01), true + return {'\u2a01', 0}, 1, true case "xoror": // TWO LOGICAL OR OPERATOR - return rune(0x2a08), true + return {'\u2a08', 0}, 1, true case "xotime": // N-ARY CIRCLED TIMES OPERATOR - return rune(0x2a02), true + return {'\u2a02', 0}, 1, true case "xrArr": // LONG RIGHTWARDS DOUBLE ARROW - return rune(0x27f9), true + return {'\u27f9', 0}, 1, true case "xrarr": // LONG RIGHTWARDS ARROW - return rune(0x27f6), true + return {'\u27f6', 0}, 1, true case "xscr": // MATHEMATICAL SCRIPT SMALL X - return rune(0x01d4cd), true + return {'\U0001d4cd', 0}, 1, true case "xsol": // BOX DRAWINGS LIGHT DIAGONAL UPPER LEFT TO LOWER RIGHT - return rune(0x2572), true + return {'\u2572', 0}, 1, true case "xsqcap": // N-ARY SQUARE INTERSECTION OPERATOR - return rune(0x2a05), true + return {'\u2a05', 0}, 1, true case "xsqcup": // N-ARY SQUARE UNION OPERATOR - return rune(0x2a06), true + return {'\u2a06', 0}, 1, true case "xsqu": // WHITE MEDIUM SQUARE - return rune(0x25fb), true + return {'\u25fb', 0}, 1, true case "xsquf": // BLACK MEDIUM SQUARE - return rune(0x25fc), true + return {'\u25fc', 0}, 1, true case "xtimes": // N-ARY TIMES OPERATOR - return rune(0x2a09), true + return {'\u2a09', 0}, 1, true case "xuplus": // N-ARY UNION OPERATOR WITH PLUS - return rune(0x2a04), true + return {'\u2a04', 0}, 1, true case "xutri": // WHITE UP-POINTING TRIANGLE - return rune(0x25b3), true + return {'\u25b3', 0}, 1, true case "xvee": // N-ARY LOGICAL OR - return rune(0x22c1), true + return {'\u22c1', 0}, 1, true case "xwedge": // N-ARY LOGICAL AND - return rune(0x22c0), true + return {'\u22c0', 0}, 1, true } case 'y': switch name { case "yacute": // LATIN SMALL LETTER Y WITH ACUTE - return rune(0xfd), true + return {'ý', 0}, 1, true case "yacy": // CYRILLIC SMALL LETTER YA - return rune(0x044f), true + return {'\u044f', 0}, 1, true case "ycirc": // LATIN SMALL LETTER Y WITH CIRCUMFLEX - return rune(0x0177), true + return {'\u0177', 0}, 1, true case "ycy": // CYRILLIC SMALL LETTER YERU - return rune(0x044b), true + return {'\u044b', 0}, 1, true case "yen": // YEN SIGN - return rune(0xa5), true + return {'¥', 0}, 1, true case "yfr": // MATHEMATICAL FRAKTUR SMALL Y - return rune(0x01d536), true + return {'\U0001d536', 0}, 1, true case "yicy": // CYRILLIC SMALL LETTER YI - return rune(0x0457), true + return {'\u0457', 0}, 1, true case "yopf": // MATHEMATICAL DOUBLE-STRUCK SMALL Y - return rune(0x01d56a), true + return {'\U0001d56a', 0}, 1, true case "yscr": // MATHEMATICAL SCRIPT SMALL Y - return rune(0x01d4ce), true + return {'\U0001d4ce', 0}, 1, true case "yucy": // CYRILLIC SMALL LETTER YU - return rune(0x044e), true + return {'\u044e', 0}, 1, true case "yuml": // LATIN SMALL LETTER Y WITH DIAERESIS - return rune(0xff), true + return {'ÿ', 0}, 1, true } case 'z': switch name { case "zacute": // LATIN SMALL LETTER Z WITH ACUTE - return rune(0x017a), true + return {'\u017a', 0}, 1, true case "zcaron": // LATIN SMALL LETTER Z WITH CARON - return rune(0x017e), true + return {'\u017e', 0}, 1, true case "zcy": // CYRILLIC SMALL LETTER ZE - return rune(0x0437), true + return {'\u0437', 0}, 1, true case "zdot": // LATIN SMALL LETTER Z WITH DOT ABOVE - return rune(0x017c), true + return {'\u017c', 0}, 1, true case "zeetrf": // BLACK-LETTER CAPITAL Z - return rune(0x2128), true + return {'\u2128', 0}, 1, true case "zeta": // GREEK SMALL LETTER ZETA - return rune(0x03b6), true + return {'\u03b6', 0}, 1, true case "zfr": // MATHEMATICAL FRAKTUR SMALL Z - return rune(0x01d537), true + return {'\U0001d537', 0}, 1, true case "zgr": // GREEK SMALL LETTER ZETA - return rune(0x03b6), true + return {'\u03b6', 0}, 1, true case "zhcy": // CYRILLIC SMALL LETTER ZHE - return rune(0x0436), true + return {'\u0436', 0}, 1, true case "zigrarr": // RIGHTWARDS SQUIGGLE ARROW - return rune(0x21dd), true + return {'\u21dd', 0}, 1, true case "zopf": // MATHEMATICAL DOUBLE-STRUCK SMALL Z - return rune(0x01d56b), true + return {'\U0001d56b', 0}, 1, true case "zscr": // MATHEMATICAL SCRIPT SMALL Z - return rune(0x01d4cf), true + return {'\U0001d4cf', 0}, 1, true case "zwj": // ZERO WIDTH JOINER - return rune(0x200d), true + return {'\u200d', 0}, 1, true case "zwnj": // ZERO WIDTH NON-JOINER - return rune(0x200c), true + return {'\u200c', 0}, 1, true } } - return -1, false + return } /* diff --git a/core/encoding/json/marshal.odin b/core/encoding/json/marshal.odin index e563c326a..011fc6f91 100644 --- a/core/encoding/json/marshal.odin +++ b/core/encoding/json/marshal.odin @@ -62,6 +62,78 @@ Marshal_Options :: struct { mjson_skipped_first_braces_end: bool, } +User_Marshaler :: #type proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> Marshal_Error + +Register_User_Marshaler_Error :: enum { + None, + No_User_Marshaler, + Marshaler_Previously_Found, +} + +// Example User Marshaler: +// Custom Marshaler for `int` +// Some_Marshaler :: proc(w: io.Writer, v: any, opt: ^json.Marshal_Options) -> json.Marshal_Error { +// io.write_string(w, fmt.tprintf("%b", v)) +// return json.Marshal_Data_Error.None +// } +// +// main :: proc() { +// // Ensure the json._user_marshaler map is initialized +// json.set_user_marshalers(new(map[typeid]json.User_Marshaler)) +// reg_err := json.register_user_marshaler(type_info_of(int).id, Some_Marshaler) +// assert(reg_err == .None) +// +// +// // Use the custom marshaler +// SomeType :: struct { +// value: int, +// } +// +// x := SomeType{42} +// data, marshal_err := json.marshal(x) +// assert(marshal_err == nil) +// defer delete(data) +// +// fmt.println("Custom output:", string(data)) // Custom output: {"value":101010} +// } + +// NOTE(Jeroen): This is a pointer to prevent accidental additions +// it is prefixed with `_` rather than marked with a private attribute so that users can access it if necessary +_user_marshalers: ^map[typeid]User_Marshaler + +// Sets user-defined marshalers for custom json marshaling of specific types +// +// Inputs: +// - m: A pointer to a map of typeids to User_Marshaler procs. +// +// NOTE: Must be called before using register_user_marshaler. +// +set_user_marshalers :: proc(m: ^map[typeid]User_Marshaler) { + assert(_user_marshalers == nil, "set_user_marshalers must not be called more than once.") + _user_marshalers = m +} + +// Registers a user-defined marshaler for a specific typeid +// +// Inputs: +// - id: The typeid of the custom type. +// - formatter: The User_Marshaler function for the custom type. +// +// Returns: A Register_User_Marshaler_Error value indicating the success or failure of the operation. +// +// WARNING: set_user_marshalers must be called before using this procedure. +// +register_user_marshaler :: proc(id: typeid, marshaler: User_Marshaler) -> Register_User_Marshaler_Error { + if _user_marshalers == nil { + return .No_User_Marshaler + } + if prev, found := _user_marshalers[id]; found && prev != nil { + return .Marshaler_Previously_Found + } + _user_marshalers[id] = marshaler + return .None +} + marshal :: proc(v: any, opt: Marshal_Options = {}, allocator := context.allocator, loc := #caller_location) -> (data: []byte, err: Marshal_Error) { b := strings.builder_make(allocator, loc) defer if err != nil { @@ -91,6 +163,13 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err: return } + if _user_marshalers != nil { + marshaler := _user_marshalers[v.id] + if marshaler != nil { + return marshaler(w, v, opt) + } + } + ti := runtime.type_info_base(type_info_of(v.id)) a := any{v.data, ti.id} @@ -122,9 +201,9 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err: case runtime.Type_Info_Rune: r := a.(rune) - io.write_byte(w, '"') or_return - io.write_escaped_rune(w, r, '"', true) or_return - io.write_byte(w, '"') or_return + io.write_byte(w, '"') or_return + io.write_escaped_rune(w, r, '"', for_json = true) or_return + io.write_byte(w, '"') or_return case runtime.Type_Info_Float: switch f in a { @@ -414,6 +493,12 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err: opt_write_iteration(w, opt, first_iteration) or_return first_iteration = false + + if opt.pretty { + comment := reflect.struct_tag_get(reflect.Struct_Tag(info.tags[i]), "jsoncomment") + opt_write_comment(w, opt, &comment) or_return + } + if json_name != "" { opt_write_key(w, opt, json_name) or_return } else { @@ -533,6 +618,26 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err: return } +// Newlines are split into multiple comment lines +opt_write_comment :: proc(w: io.Writer, opt: ^Marshal_Options, comment: ^string) -> (err: io.Error) { + if comment^ == "" { + return nil + } + + switch opt.spec { + case .JSON5, .MJSON: + for line in strings.split_iterator(comment, "\n") { + io.write_string(w, "// ") or_return + io.write_string(w, line) or_return + io.write_rune(w, '\n') or_return + opt_write_indentation(w, opt) or_return + } + case .JSON: return nil + } + + return nil +} + // write key as quoted string or with optional quotes in mjson opt_write_key :: proc(w: io.Writer, opt: ^Marshal_Options, name: string) -> (err: io.Error) { switch opt.spec { diff --git a/core/encoding/json/parser.odin b/core/encoding/json/parser.odin index d6c3df7c6..cd6518955 100644 --- a/core/encoding/json/parser.odin +++ b/core/encoding/json/parser.odin @@ -38,7 +38,7 @@ parse_string :: proc(data: string, spec := DEFAULT_SPECIFICATION, parse_integers switch p.spec { case .JSON: - return parse_object(&p, loc) + return parse_value(&p, loc) case .JSON5: return parse_value(&p, loc) case .SJSON: @@ -84,7 +84,7 @@ expect_token :: proc(p: ^Parser, kind: Token_Kind) -> Error { parse_colon :: proc(p: ^Parser) -> (err: Error) { - colon_err := expect_token(p, .Colon) + colon_err := expect_token(p, .Colon) if colon_err == nil { return nil } @@ -133,13 +133,13 @@ parse_value :: proc(p: ^Parser, loc := #caller_location) -> (value: Value, err: f, _ := strconv.parse_f64(token.text) value = Float(f) return - + case .Ident: if p.spec == .MJSON { advance_token(p) return clone_string(token.text, p.allocator, loc) } - + case .String: advance_token(p) return unquote_string(token, p.spec, p.allocator, loc) @@ -192,7 +192,7 @@ parse_array :: proc(p: ^Parser, loc := #caller_location) -> (value: Value, err: for p.curr_token.kind != .Close_Bracket { elem := parse_value(p, loc) or_return append(&array, elem, loc) - + if parse_comma(p) { break } @@ -278,7 +278,7 @@ parse_object_body :: proc(p: ^Parser, end_token: Token_Kind, loc := #caller_loca if parse_comma(p) { break } - } + } return obj, .None } @@ -481,4 +481,4 @@ unquote_string :: proc(token: Token, spec: Specification, allocator := context.a } return string(b[:w]), nil -} \ No newline at end of file +} diff --git a/core/encoding/json/types.odin b/core/encoding/json/types.odin index 1da17a0db..77cc7db85 100644 --- a/core/encoding/json/types.odin +++ b/core/encoding/json/types.odin @@ -76,6 +76,7 @@ Error :: enum { Invalid_Number, String_Not_Terminated, Invalid_String, + Invalid_Rune, // Parsing Errors diff --git a/core/encoding/json/unmarshal.odin b/core/encoding/json/unmarshal.odin index 3cdc6429d..2aa3c0913 100644 --- a/core/encoding/json/unmarshal.odin +++ b/core/encoding/json/unmarshal.odin @@ -26,6 +26,80 @@ Unmarshal_Error :: union { Unsupported_Type_Error, } +User_Unmarshaler :: #type proc(p: ^Parser, v: any) -> Unmarshal_Error + +Register_User_Unmarshaler_Error :: enum { + None, + No_User_Unmarshaler, + Unmarshaler_Previously_Found, +} + +// Example User Unmarshaler: +// Custom Unmarshaler for `int` +// Some_Unmarshaler :: proc(p: ^json.Parser, v: any) -> json.Unmarshal_Error { +// token := p.curr_token.text +// i, ok := strconv.parse_i64_of_base(token, 2) +// if !ok { +// return .Invalid_Data +// +// } +// (^int)(v.data)^ = int(i) +// return .None +// } +// +// _main :: proc() { +// // Ensure the json._user_unmarshaler map is initialized +// json.set_user_unmarshalers(new(map[typeid]json.User_Unmarshaler)) +// reg_err := json.register_user_unmarshaler(type_info_of(int).id, Some_Unmarshaler) +// assert(reg_err == .None) +// +// data := `{"value":101010}` +// SomeType :: struct { +// value: int, +// } +// y: SomeType +// +// unmarshal_err := json.unmarshal(transmute([]byte)data, &y) +// fmt.println(y, unmarshal_err) +// } + +// NOTE(Jeroen): This is a pointer to prevent accidental additions +// it is prefixed with `_` rather than marked with a private attribute so that users can access it if necessary +_user_unmarshalers: ^map[typeid]User_Unmarshaler + +// Sets user-defined unmarshalers for custom json unmarshaling of specific types +// +// Inputs: +// - m: A pointer to a map of typeids to User_Unmarshaler procs. +// +// NOTE: Must be called before using register_user_unmarshaler. +// +set_user_unmarshalers :: proc(m: ^map[typeid]User_Unmarshaler) { + assert(_user_unmarshalers == nil, "set_user_unmarshalers must not be called more than once.") + _user_unmarshalers = m +} + +// Registers a user-defined unmarshaler for a specific typeid +// +// Inputs: +// - id: The typeid of the custom type. +// - unmarshaler: The User_Unmarshaler function for the custom type. +// +// Returns: A Register_User_Unmarshaler_Error value indicating the success or failure of the operation. +// +// WARNING: set_user_unmarshalers must be called before using this procedure. +// +register_user_unmarshaler :: proc(id: typeid, unmarshaler: User_Unmarshaler) -> Register_User_Unmarshaler_Error { + if _user_unmarshalers == nil { + return .No_User_Unmarshaler + } + if prev, found := _user_unmarshalers[id]; found && prev != nil { + return .Unmarshaler_Previously_Found + } + _user_unmarshalers[id] = unmarshaler + return .None +} + unmarshal_any :: proc(data: []byte, v: any, spec := DEFAULT_SPECIFICATION, allocator := context.allocator) -> Unmarshal_Error { v := v if v == nil || v.id == nil { @@ -37,8 +111,10 @@ unmarshal_any :: proc(data: []byte, v: any, spec := DEFAULT_SPECIFICATION, alloc return .Non_Pointer_Parameter } PARSE_INTEGERS :: true - - if !is_valid(data, spec, PARSE_INTEGERS) { + + // If we have custom unmarshalers, we skip validation in case the custom data is not quite up to spec. + have_custom := _user_unmarshalers != nil && len(_user_unmarshalers) > 0 + if !have_custom && !is_valid(data, spec, PARSE_INTEGERS) { return .Invalid_Data } p := make_parser(data, spec, PARSE_INTEGERS, allocator) @@ -225,6 +301,15 @@ unmarshal_string_token :: proc(p: ^Parser, val: any, token: Token, ti: ^reflect. } ok = true return + case rune: + for rne, i in str { + if i > 0 { + dst = {} + return false, .Invalid_Rune + } + dst = rne + } + return true, nil } #partial switch variant in ti.variant { @@ -265,12 +350,18 @@ unmarshal_string_token :: proc(p: ^Parser, val: any, token: Token, ti: ^reflect. return false, nil } - @(private) unmarshal_value :: proc(p: ^Parser, v: any) -> (err: Unmarshal_Error) { UNSUPPORTED_TYPE := Unsupported_Type_Error{v.id, p.curr_token} token := p.curr_token + if _user_unmarshalers != nil { + unmarshaler := _user_unmarshalers[v.id] + if unmarshaler != nil { + return unmarshaler(p, v) + } + } + v := v ti := reflect.type_info_base(type_info_of(v.id)) if u, ok := ti.variant.(reflect.Type_Info_Union); ok && token.kind != .Null { diff --git a/core/encoding/json/validator.odin b/core/encoding/json/validator.odin index a6873319d..e90270335 100644 --- a/core/encoding/json/validator.odin +++ b/core/encoding/json/validator.odin @@ -5,10 +5,10 @@ import "core:mem" // NOTE(bill): is_valid will not check for duplicate keys is_valid :: proc(data: []byte, spec := DEFAULT_SPECIFICATION, parse_integers := false) -> bool { p := make_parser(data, spec, parse_integers, mem.nil_allocator()) - + switch p.spec { case .JSON: - return validate_object(&p) + return validate_value(&p) case .JSON5: return validate_value(&p) case .MJSON: @@ -52,7 +52,7 @@ validate_object :: proc(p: ^Parser) -> bool { if err := expect_token(p, .Open_Brace); err != .None { return false } - + validate_object_body(p, .Close_Brace) or_return if err := expect_token(p, .Close_Brace); err != .None { @@ -102,7 +102,7 @@ validate_value :: proc(p: ^Parser) -> bool { case .Open_Bracket: return validate_array(p) - + case .Ident: if p.spec == .MJSON { advance_token(p) diff --git a/core/encoding/xml/tokenizer.odin b/core/encoding/xml/tokenizer.odin index 71fa0bdf5..d07f41580 100644 --- a/core/encoding/xml/tokenizer.odin +++ b/core/encoding/xml/tokenizer.odin @@ -264,7 +264,7 @@ scan_comment :: proc(t: ^Tokenizer) -> (comment: string, err: Error) { expect(t, .Dash) expect(t, .Gt) - return string(t.src[offset : t.offset - 1]), .None + return string(t.src[offset : t.offset - 3]), .None } // Skip CDATA diff --git a/core/encoding/xml/xml_reader.odin b/core/encoding/xml/xml_reader.odin index 0e773fd8a..8f8fffe14 100644 --- a/core/encoding/xml/xml_reader.odin +++ b/core/encoding/xml/xml_reader.odin @@ -294,7 +294,7 @@ parse_bytes :: proc(data: []u8, options := DEFAULT_OPTIONS, path := "", error_ha comment := scan_comment(t) or_return if .Intern_Comments in opts.flags { - if len(doc.elements) == 0 { + if doc.element_count == 0 { append(&doc.comments, comment) } else { el := new_element(doc) @@ -308,6 +308,7 @@ parse_bytes :: proc(data: []u8, options := DEFAULT_OPTIONS, path := "", error_ha case .Open_Bracket: // This could be a CDATA tag part of a tag's body. Unread the ` (id: Element_ID) { cur := doc.element_count doc.element_count += 1 return cur -} \ No newline at end of file +} diff --git a/core/flags/constants.odin b/core/flags/constants.odin index dc2663e2a..154ed3cec 100644 --- a/core/flags/constants.odin +++ b/core/flags/constants.odin @@ -11,8 +11,7 @@ NO_CORE_NAMED_TYPES :: #config(ODIN_CORE_FLAGS_NO_CORE_NAMED_TYPES, false) IMPORTING_TIME :: #config(ODIN_CORE_FLAGS_USE_TIME, time.IS_SUPPORTED) // Override support for parsing `net` types. -// TODO: Update this when the BSDs are supported. -IMPORTING_NET :: #config(ODIN_CORE_FLAGS_USE_NET, ODIN_OS == .Windows || ODIN_OS == .Linux || ODIN_OS == .Darwin || ODIN_OS == .FreeBSD) +IMPORTING_NET :: #config(ODIN_CORE_FLAGS_USE_NET, ODIN_OS == .Windows || ODIN_OS == .Linux || ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD) TAG_ARGS :: "args" SUBTAG_NAME :: "name" diff --git a/core/flags/errors.odin b/core/flags/errors.odin index 3d34a95d3..e9b2e18c8 100644 --- a/core/flags/errors.odin +++ b/core/flags/errors.odin @@ -1,5 +1,7 @@ package flags +import "base:runtime" +import "core:net" import "core:os" Parse_Error_Reason :: enum { @@ -24,6 +26,12 @@ Parse_Error :: struct { message: string, } +Unified_Parse_Error_Reason :: union #shared_nil { + Parse_Error_Reason, + runtime.Allocator_Error, + net.Parse_Endpoint_Error, +} + // Raised during parsing. // Provides more granular information than what just a string could hold. Open_File_Error :: struct { diff --git a/core/flags/errors_bsd.odin b/core/flags/errors_bsd.odin deleted file mode 100644 index 4d98d2ee4..000000000 --- a/core/flags/errors_bsd.odin +++ /dev/null @@ -1,9 +0,0 @@ -#+build netbsd, openbsd -package flags - -import "base:runtime" - -Unified_Parse_Error_Reason :: union #shared_nil { - Parse_Error_Reason, - runtime.Allocator_Error, -} diff --git a/core/flags/errors_nonbsd.odin b/core/flags/errors_nonbsd.odin deleted file mode 100644 index 28912b57f..000000000 --- a/core/flags/errors_nonbsd.odin +++ /dev/null @@ -1,12 +0,0 @@ -#+build !netbsd -#+build !openbsd -package flags - -import "base:runtime" -import "core:net" - -Unified_Parse_Error_Reason :: union #shared_nil { - Parse_Error_Reason, - runtime.Allocator_Error, - net.Parse_Endpoint_Error, -} diff --git a/core/flags/internal_rtti.odin b/core/flags/internal_rtti.odin index a1b050597..b3880afa0 100644 --- a/core/flags/internal_rtti.odin +++ b/core/flags/internal_rtti.odin @@ -5,6 +5,7 @@ import "base:intrinsics" import "base:runtime" import "core:fmt" import "core:mem" +import "core:net" import "core:os" import "core:reflect" import "core:strconv" @@ -310,7 +311,18 @@ parse_and_set_pointer_by_named_type :: proc(ptr: rawptr, str: string, data_type: } when IMPORTING_NET { - if try_net_parse_workaround(data_type, str, ptr, out_error) { + if data_type == net.Host_Or_Endpoint { + addr, net_error := net.parse_hostname_or_endpoint(str) + if net_error != nil { + // We pass along `net.Error` here. + out_error^ = Parse_Error { + net_error, + "Invalid Host/Endpoint.", + } + return + } + + (cast(^net.Host_Or_Endpoint)ptr)^ = addr return } } diff --git a/core/flags/internal_rtti_nonbsd.odin b/core/flags/internal_rtti_nonbsd.odin deleted file mode 100644 index e1286186b..000000000 --- a/core/flags/internal_rtti_nonbsd.odin +++ /dev/null @@ -1,32 +0,0 @@ -#+private -#+build !netbsd -#+build !openbsd -package flags - -import "core:net" - -// This proc exists purely as a workaround for import restrictions. -// Returns true if caller should return early. -try_net_parse_workaround :: #force_inline proc ( - data_type: typeid, - str: string, - ptr: rawptr, - out_error: ^Error, -) -> bool { - if data_type == net.Host_Or_Endpoint { - addr, net_error := net.parse_hostname_or_endpoint(str) - if net_error != nil { - // We pass along `net.Error` here. - out_error^ = Parse_Error { - net_error, - "Invalid Host/Endpoint.", - } - return true - } - - (cast(^net.Host_Or_Endpoint)ptr)^ = addr - return true - } - - return false -} diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index c958c2d2e..04211b8a9 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -1086,7 +1086,7 @@ _fmt_int :: proc(fi: ^Info, u: u64, base: int, is_signed: bool, bit_size: int, d case 12: io.write_byte(fi.writer, '0', &fi.n) - io.write_byte(fi.writer, 'o', &fi.n) + io.write_byte(fi.writer, 'z', &fi.n) start = 2 case 16: @@ -1100,10 +1100,7 @@ _fmt_int :: proc(fi: ^Info, u: u64, base: int, is_signed: bool, bit_size: int, d if fi.prec_set { prec = fi.prec if prec == 0 && u == 0 { - prev_zero := fi.zero - fi.zero = false fmt_write_padding(fi, fi.width) - fi.zero = prev_zero return } } else if fi.zero && fi.width_set { @@ -1171,7 +1168,7 @@ _fmt_int_128 :: proc(fi: ^Info, u: u128, base: int, is_signed: bool, bit_size: i case 12: io.write_byte(fi.writer, '0', &fi.n) - io.write_byte(fi.writer, 'o', &fi.n) + io.write_byte(fi.writer, 'z', &fi.n) start = 2 case 16: @@ -1185,10 +1182,7 @@ _fmt_int_128 :: proc(fi: ^Info, u: u128, base: int, is_signed: bool, bit_size: i if fi.prec_set { prec = fi.prec if prec == 0 && u == 0 { - prev_zero := fi.zero - fi.zero = false fmt_write_padding(fi, fi.width) - fi.zero = prev_zero return } } else if fi.zero && fi.width_set { @@ -1231,8 +1225,8 @@ _fmt_int_128 :: proc(fi: ^Info, u: u128, base: int, is_signed: bool, bit_size: i _pad(fi, s) } // Units of measurements: -__MEMORY_LOWER := " b kib mib gib tib pib eib" -__MEMORY_UPPER := " B KiB MiB GiB TiB PiB EiB" +@(rodata) __MEMORY_LOWER := " b kib mib gib tib pib eib" +@(rodata) __MEMORY_UPPER := " B KiB MiB GiB TiB PiB EiB" // Formats an integer value as bytes with the best representation. // // Inputs: @@ -1290,8 +1284,8 @@ _fmt_memory :: proc(fi: ^Info, u: u64, is_signed: bool, bit_size: int, units: st _pad(fi, str) } // Hex Values: -__DIGITS_LOWER := "0123456789abcdefx" -__DIGITS_UPPER := "0123456789ABCDEFX" +@(rodata) __DIGITS_LOWER := "0123456789abcdefx" +@(rodata) __DIGITS_UPPER := "0123456789ABCDEFX" // Formats a rune value according to the specified formatting verb. // // Inputs: @@ -2137,11 +2131,170 @@ __handle_raw_union_tag :: proc(fi: ^Info, v: any, the_verb: rune, info: runtime. } } } + case reflect.Type_Info_Integer: + tag_value := reflect.as_i64(tag) or_break + + for tag, index in info.tags[:info.field_count] { + rut_list := reflect.struct_tag_lookup(reflect.Struct_Tag(tag), "raw_union_tag") or_continue + + for rut in strings.split_iterator(&rut_list, ",") { + head_tag, match, tail_name := strings.partition(string(rut), "=") + if head_tag != tag_name || match != "=" { + continue + } + + // just ignore the `A.` prefix for `A.B` stuff entirely + if _, _, try_tail_name := strings.partition(string(rut), "."); try_tail_name != "" { + tail_name = try_tail_name + } + + tail_value := strconv.parse_i64(tail_name) or_continue + + if tail_value == tag_value { + io.write_string(fi.writer, "#raw_union(.", &fi.n) + io.write_i64(fi.writer, tag_value, 10, &fi.n) + io.write_string(fi.writer, ") ", &fi.n) + fmt_arg(fi, any{v.data, info.types[index].id}, the_verb) + return true + } + } + } + + case reflect.Type_Info_Boolean: + tag_value := reflect.as_bool(tag) or_break + + for tag, index in info.tags[:info.field_count] { + rut_list := reflect.struct_tag_lookup(reflect.Struct_Tag(tag), "raw_union_tag") or_continue + + for rut in strings.split_iterator(&rut_list, ",") { + head_tag, match, tail_name := strings.partition(string(rut), "=") + if head_tag != tag_name || match != "=" { + continue + } + + // just ignore the `A.` prefix for `A.B` stuff entirely + if _, _, try_tail_name := strings.partition(string(rut), "."); try_tail_name != "" { + tail_name = try_tail_name + } + + tail_value := strconv.parse_bool(tail_name) or_continue + + if tail_value == tag_value { + io.write_string(fi.writer, "#raw_union(.", &fi.n) + io.write_string(fi.writer, "true" if tag_value else "false", &fi.n) + io.write_string(fi.writer, ") ", &fi.n) + fmt_arg(fi, any{v.data, info.types[index].id}, the_verb) + return true + } + } + } } return false } +@(private) +fmt_soa_struct_internal :: proc(fi: ^Info, v: any, the_verb: rune, info: runtime.Type_Info_Struct, type_name: string, hash: bool, indent: int) { + is_empty := info.field_count == 0 + + fi.indent += 1 + defer fi.indent -= 1 + + base_type_name: string + if v, ok := info.soa_base_type.variant.(runtime.Type_Info_Named); ok { + base_type_name = v.name + } + + actual_field_count := info.field_count + + n := uintptr(info.soa_len) + + if info.soa_kind == .Slice { + actual_field_count = info.field_count-1 // len + + n = uintptr((^int)(uintptr(v.data) + info.offsets[actual_field_count])^) + + } else if info.soa_kind == .Dynamic { + actual_field_count = info.field_count-3 // len, cap, allocator + + n = uintptr((^int)(uintptr(v.data) + info.offsets[actual_field_count])^) + } + + if hash && n > 0 { + io.write_byte(fi.writer, '\n', &fi.n) + } + + for index in 0.. 0 { io.write_string(fi.writer, ", ", &fi.n) } + + field_count := -1 + + if !hash && field_count > 0 { io.write_string(fi.writer, ", ", &fi.n) } + + if hash { + fi.indent -= 1 + fmt_write_indent(fi) + fi.indent += 1 + } + io.write_string(fi.writer, base_type_name, &fi.n) + io.write_byte(fi.writer, '{', &fi.n) + if hash && !is_empty { io.write_byte(fi.writer, '\n', &fi.n) } + defer { + if hash && !is_empty { + fi.indent -= 1 + fmt_write_indent(fi) + fi.indent += 1 + } + io.write_byte(fi.writer, '}', &fi.n) + if hash { io.write_string(fi.writer, ",\n", &fi.n) } + } + fi.record_level += 1 + defer fi.record_level -= 1 + + for i in 0.. 0 { io.write_string(fi.writer, ", ", &fi.n) } + if hash { + fmt_write_indent(fi) + } + + io.write_string(fi.writer, name, &fi.n) + io.write_string(fi.writer, " = ", &fi.n) + + if info.soa_kind == .Fixed { + t := info.types[i].variant.(runtime.Type_Info_Array).elem + t_size := uintptr(t.size) + if reflect.is_any(t) { + io.write_string(fi.writer, "any{}", &fi.n) + } else { + data := rawptr(uintptr(v.data) + info.offsets[i] + index*t_size) + fmt_arg(fi, any{data, t.id}, verb) + } + } else { + t := info.types[i].variant.(runtime.Type_Info_Multi_Pointer).elem + t_size := uintptr(t.size) + if reflect.is_any(t) { + io.write_string(fi.writer, "any{}", &fi.n) + } else { + field_ptr := (^^byte)(uintptr(v.data) + info.offsets[i])^ + data := rawptr(uintptr(field_ptr) + index*t_size) + fmt_arg(fi, any{data, t.id}, verb) + } + } + + if hash { io.write_string(fi.writer, ",\n", &fi.n) } + } + } + + if hash && n > 0 { + for _ in 0.. 0 { - io.write_byte(fi.writer, '\n', &fi.n) - } - - for index in 0.. 0 { io.write_string(fi.writer, ", ", &fi.n) } - - field_count := -1 - - if !hash && field_count > 0 { io.write_string(fi.writer, ", ", &fi.n) } - - if hash { - fi.indent -= 1 - fmt_write_indent(fi) - fi.indent += 1 - } - io.write_string(fi.writer, base_type_name, &fi.n) - io.write_byte(fi.writer, '{', &fi.n) - if hash && !is_empty { io.write_byte(fi.writer, '\n', &fi.n) } - defer { - if hash && !is_empty { - fi.indent -= 1 - fmt_write_indent(fi) - fi.indent += 1 - } - io.write_byte(fi.writer, '}', &fi.n) - if hash { io.write_string(fi.writer, ",\n", &fi.n) } - } - fi.record_level += 1 - defer fi.record_level -= 1 - - for i in 0.. 0 { io.write_string(fi.writer, ", ", &fi.n) } - if hash { - fmt_write_indent(fi) - } - - io.write_string(fi.writer, name, &fi.n) - io.write_string(fi.writer, " = ", &fi.n) - - if info.soa_kind == .Fixed { - t := info.types[i].variant.(runtime.Type_Info_Array).elem - t_size := uintptr(t.size) - if reflect.is_any(t) { - io.write_string(fi.writer, "any{}", &fi.n) - } else { - data := rawptr(uintptr(v.data) + info.offsets[i] + index*t_size) - fmt_arg(fi, any{data, t.id}, verb) - } - } else { - t := info.types[i].variant.(runtime.Type_Info_Multi_Pointer).elem - t_size := uintptr(t.size) - if reflect.is_any(t) { - io.write_string(fi.writer, "any{}", &fi.n) - } else { - field_ptr := (^^byte)(uintptr(v.data) + info.offsets[i])^ - data := rawptr(uintptr(field_ptr) + index*t_size) - fmt_arg(fi, any{data, t.id}, verb) - } - } - - if hash { io.write_string(fi.writer, ",\n", &fi.n) } - } - } - - if hash && n > 0 { - for _ in 0.. bool { + switch a in v { + case runtime.Source_Code_Location: + io.write_string(fi.writer, a.file_path, &fi.n) + + when ODIN_ERROR_POS_STYLE == .Default { + io.write_byte(fi.writer, '(', &fi.n) + io.write_int(fi.writer, int(a.line), 10, &fi.n) + if a.column != 0 { + io.write_byte(fi.writer, ':', &fi.n) + io.write_int(fi.writer, int(a.column), 10, &fi.n) + } + io.write_byte(fi.writer, ')', &fi.n) + } else when ODIN_ERROR_POS_STYLE == .Unix { + io.write_byte(fi.writer, ':', &fi.n) + io.write_int(fi.writer, int(a.line), 10, &fi.n) + if a.column != 0 { + io.write_byte(fi.writer, ':', &fi.n) + io.write_int(fi.writer, int(a.column), 10, &fi.n) + } + io.write_byte(fi.writer, ':', &fi.n) + } else { + #panic("Unhandled ODIN_ERROR_POS_STYLE") + } + return true + + case time.Duration: + ffrac :: proc(buf: []byte, v: u64, prec: int) -> (nw: int, nv: u64) { + v := v + w := len(buf) + print := false + for _ in 0.. int { + v := v + w := len(buf) + if v == 0 { + w -= 1 + buf[w] = '0' + } else { + for v > 0 { + w -= 1 + buf[w] = byte(v%10) + '0' + v /= 10 + } + } + return w + } + + buf: [32]byte + w := len(buf) + u := u64(a) + neg := a < 0 + if neg { + u = -u + } + + if u < u64(time.Second) { + prec: int + w -= 1 + buf[w] = 's' + w -= 1 + switch { + case u == 0: + io.write_string(fi.writer, "0s", &fi.n) + return true + case u < u64(time.Microsecond): + prec = 0 + buf[w] = 'n' + case u < u64(time.Millisecond): + prec = 3 + // U+00B5 'µ' micro sign == 0xC2 0xB5 + w -= 1 // Need room for two bytes + copy(buf[w:], "µ") + case: + prec = 6 + buf[w] = 'm' + } + w, u = ffrac(buf[:w], u, prec) + w = fint(buf[:w], u) + } else { + w -= 1 + buf[w] = 's' + w, u = ffrac(buf[:w], u, 9) + w = fint(buf[:w], u%60) + u /= 60 + if u > 0 { + w -= 1 + buf[w] = 'm' + w = fint(buf[:w], u%60) + u /= 60 + if u > 0 { + w -= 1 + buf[w] = 'h' + w = fint(buf[:w], u) + } + } + } + + if neg { + w -= 1 + buf[w] = '-' + } + io.write_string(fi.writer, string(buf[w:]), &fi.n) + return true + + case time.Time: + write_padded_number :: proc(fi: ^Info, i: i64, width: int) { + n := width-1 + for x := i; x >= 10; x /= 10 { + n -= 1 + } + for _ in 0..= 10; x /= 10 { - n -= 1 - } - for _ in 0.. (nw: int, nv: u64) { - v := v - w := len(buf) - print := false - for _ in 0.. int { - v := v - w := len(buf) - if v == 0 { - w -= 1 - buf[w] = '0' - } else { - for v > 0 { - w -= 1 - buf[w] = byte(v%10) + '0' - v /= 10 - } - } - return w - } - - buf: [32]byte - w := len(buf) - u := u64(a) - neg := a < 0 - if neg { - u = -u - } - - if u < u64(time.Second) { - prec: int - w -= 1 - buf[w] = 's' - w -= 1 - switch { - case u == 0: - io.write_string(fi.writer, "0s", &fi.n) - return - case u < u64(time.Microsecond): - prec = 0 - buf[w] = 'n' - case u < u64(time.Millisecond): - prec = 3 - // U+00B5 'µ' micro sign == 0xC2 0xB5 - w -= 1 // Need room for two bytes - copy(buf[w:], "µ") - case: - prec = 6 - buf[w] = 'm' - } - w, u = ffrac(buf[:w], u, prec) - w = fint(buf[:w], u) - } else { - w -= 1 - buf[w] = 's' - w, u = ffrac(buf[:w], u, 9) - w = fint(buf[:w], u%60) - u /= 60 - if u > 0 { - w -= 1 - buf[w] = 'm' - w = fint(buf[:w], u%60) - u /= 60 - if u > 0 { - w -= 1 - buf[w] = 'h' - w = fint(buf[:w], u) - } - } - } - - if neg { - w -= 1 - buf[w] = '-' - } - io.write_string(fi.writer, string(buf[w:]), &fi.n) - return - - case time.Time: - t := a - y, mon, d := time.date(t) - h, min, s := time.clock(t) - ns := (t._nsec - (t._nsec/1e9 + time.UNIX_TO_ABSOLUTE)*1e9) % 1e9 - write_padded_number(fi, i64(y), 4) - io.write_byte(fi.writer, '-', &fi.n) - write_padded_number(fi, i64(mon), 2) - io.write_byte(fi.writer, '-', &fi.n) - write_padded_number(fi, i64(d), 2) - io.write_byte(fi.writer, ' ', &fi.n) - - write_padded_number(fi, i64(h), 2) - io.write_byte(fi.writer, ':', &fi.n) - write_padded_number(fi, i64(min), 2) - io.write_byte(fi.writer, ':', &fi.n) - write_padded_number(fi, i64(s), 2) - io.write_byte(fi.writer, '.', &fi.n) - write_padded_number(fi, (ns), 9) - io.write_string(fi.writer, " +0000 UTC", &fi.n) - return - } + if verb != 'w' && fmt_named_buitlin_custom_formatters(fi, v, verb, info) { + return } #partial switch &b in info.base.variant { @@ -2842,6 +2911,232 @@ fmt_bit_field :: proc(fi: ^Info, v: any, verb: rune, info: runtime.Type_Info_Bit } +@(private) +fmt_pointer_from_value :: proc(fi: ^Info, v: any, info: runtime.Type_Info_Pointer, verb: rune) { + if v.id == typeid_of(^runtime.Type_Info) { + reflect.write_type(fi.writer, (^^runtime.Type_Info)(v.data)^, &fi.n) + } else { + ptr := (^rawptr)(v.data)^ + if verb != 'p' && info.elem != nil { + a := any{ptr, info.elem.id} + + elem := runtime.type_info_base(info.elem) + if elem != nil { + #partial switch &e in elem.variant { + case runtime.Type_Info_Array, + runtime.Type_Info_Slice, + runtime.Type_Info_Dynamic_Array, + runtime.Type_Info_Map: + if ptr == nil { + io.write_string(fi.writer, "", &fi.n) + return + } + if fi.indirection_level < 1 { + fi.indirection_level += 1 + defer fi.indirection_level -= 1 + io.write_byte(fi.writer, '&') + fmt_value(fi, a, verb) + return + } + + case runtime.Type_Info_Struct, + runtime.Type_Info_Union, + runtime.Type_Info_Bit_Field: + if ptr == nil { + io.write_string(fi.writer, "", &fi.n) + return + } + if fi.indirection_level < 1 { + fi.indirection_level += 1 + defer fi.indirection_level -= 1 + io.write_byte(fi.writer, '&', &fi.n) + fmt_value(fi, a, verb) + return + } + } + } + } + fmt_pointer(fi, ptr, verb) + } +} + +@(private) +fmt_multi_pointer :: proc(fi: ^Info, v: any, info: runtime.Type_Info_Multi_Pointer, verb: rune) { + ptr := (^rawptr)(v.data)^ + if ptr == nil { + io.write_string(fi.writer, "", &fi.n) + return + } + if verb != 'p' && info.elem != nil { + a := any{ptr, info.elem.id} + + elem := runtime.type_info_base(info.elem) + if elem != nil { + if n, ok := fi.optional_len.?; ok { + fi.optional_len = nil + fmt_array(fi, ptr, n, elem.size, elem, verb) + return + } else if fi.use_nul_termination { + fi.use_nul_termination = false + fmt_array_nul_terminated(fi, ptr, -1, elem.size, elem, verb) + return + } + + #partial switch &e in elem.variant { + case runtime.Type_Info_Integer: + switch verb { + case 's', 'q': + switch elem.id { + case u8: + fmt_cstring(fi, cstring(ptr), verb) + return + case u16, u32, rune: + n := search_nul_termination(ptr, elem.size, -1) + fmt_array(fi, ptr, n, elem.size, elem, verb) + return + } + } + + case runtime.Type_Info_Array, + runtime.Type_Info_Slice, + runtime.Type_Info_Dynamic_Array, + runtime.Type_Info_Map: + if fi.indirection_level < 1 { + fi.indirection_level += 1 + defer fi.indirection_level -= 1 + io.write_byte(fi.writer, '&', &fi.n) + fmt_value(fi, a, verb) + return + } + + case runtime.Type_Info_Struct, + runtime.Type_Info_Union: + if fi.indirection_level < 1 { + fi.indirection_level += 1 + defer fi.indirection_level -= 1 + io.write_byte(fi.writer, '&', &fi.n) + fmt_value(fi, a, verb) + return + } + } + } + } + fmt_pointer(fi, ptr, verb) +} + +fmt_enumerated_array :: proc(fi: ^Info, v: any, info: runtime.Type_Info_Enumerated_Array, verb: rune) { + fi.record_level += 1 + defer fi.record_level -= 1 + + if fi.hash { + io.write_byte(fi.writer, '[' if verb != 'w' else '{', &fi.n) + io.write_byte(fi.writer, '\n', &fi.n) + defer { + fmt_write_indent(fi) + io.write_byte(fi.writer, ']' if verb != 'w' else '}', &fi.n) + } + indent := fi.indent + fi.indent += 1 + defer fi.indent = indent + + for i in 0.. 0 { io.write_string(fi.writer, ", ", &fi.n) } + + idx, ok := stored_enum_value_to_string(info.index, info.min_value, i) + if ok { + io.write_byte(fi.writer, '.', &fi.n) + io.write_string(fi.writer, idx, &fi.n) + } else { + io.write_i64(fi.writer, i64(info.min_value)+i64(i), 10, &fi.n) + } + io.write_string(fi.writer, " = ", &fi.n) + + data := uintptr(v.data) + uintptr(i*info.elem_size) + fmt_arg(fi, any{rawptr(data), info.elem.id}, verb) + } + } +} + +fmt_map :: proc(fi: ^Info, v: any, info: runtime.Type_Info_Map, verb: rune) { + switch verb { + case: + fmt_bad_verb(fi, verb) + case 'v', 'w': + if verb == 'v' { + io.write_string(fi.writer, "map", &fi.n) + } + io.write_byte(fi.writer, '[' if verb != 'w' else '{', &fi.n) + defer io.write_byte(fi.writer, ']' if verb != 'w' else '}', &fi.n) + + + hash := fi.hash; defer fi.hash = hash + indent := fi.indent; defer fi.indent -= 1 + do_trailing_comma := hash + + fi.indent += 1 + if hash { + io.write_byte(fi.writer, '\n', &fi.n) + } + defer { + if hash { + for _ in 0.. 0 { io.write_string(fi.writer, ", ") } + if hash { + fmt_write_indent(fi) + } + j += 1 + + key := runtime.map_cell_index_dynamic(ks, info.map_info.ks, bucket_index) + value := runtime.map_cell_index_dynamic(vs, info.map_info.vs, bucket_index) + + fmt_arg(&Info{writer = fi.writer}, any{rawptr(key), info.key.id}, verb) + if hash { + io.write_string(fi.writer, " = ", &fi.n) + } else { + io.write_string(fi.writer, "=", &fi.n) + } + fmt_arg(fi, any{rawptr(value), info.value.id}, verb) + + if do_trailing_comma { io.write_string(fi.writer, ",\n", &fi.n) } + } + } + } + +} // Formats a value based on its type and formatting verb // @@ -2872,184 +3167,35 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) { type_info := type_info_of(v.id) switch &info in type_info.variant { - case runtime.Type_Info_Any: // Ignore - case runtime.Type_Info_Parameters: // Ignore + case runtime.Type_Info_Any: + // Ignore + case runtime.Type_Info_Parameters: + // Ignore case runtime.Type_Info_Named: fmt_named(fi, v, verb, info) - case runtime.Type_Info_Boolean: fmt_arg(fi, v, verb) - case runtime.Type_Info_Integer: fmt_arg(fi, v, verb) - case runtime.Type_Info_Rune: fmt_arg(fi, v, verb) - case runtime.Type_Info_Float: fmt_arg(fi, v, verb) - case runtime.Type_Info_Complex: fmt_arg(fi, v, verb) - case runtime.Type_Info_Quaternion: fmt_arg(fi, v, verb) - case runtime.Type_Info_String: fmt_arg(fi, v, verb) + case runtime.Type_Info_Boolean, + runtime.Type_Info_Integer, + runtime.Type_Info_Rune, + runtime.Type_Info_Float, + runtime.Type_Info_Complex, + runtime.Type_Info_Quaternion, + runtime.Type_Info_String: + fmt_arg(fi, v, verb) case runtime.Type_Info_Pointer: - if v.id == typeid_of(^runtime.Type_Info) { - reflect.write_type(fi.writer, (^^runtime.Type_Info)(v.data)^, &fi.n) - } else { - ptr := (^rawptr)(v.data)^ - if verb != 'p' && info.elem != nil { - a := any{ptr, info.elem.id} - - elem := runtime.type_info_base(info.elem) - if elem != nil { - #partial switch &e in elem.variant { - case runtime.Type_Info_Array, - runtime.Type_Info_Slice, - runtime.Type_Info_Dynamic_Array, - runtime.Type_Info_Map: - if ptr == nil { - io.write_string(fi.writer, "", &fi.n) - return - } - if fi.indirection_level < 1 { - fi.indirection_level += 1 - defer fi.indirection_level -= 1 - io.write_byte(fi.writer, '&') - fmt_value(fi, a, verb) - return - } - - case runtime.Type_Info_Struct, - runtime.Type_Info_Union, - runtime.Type_Info_Bit_Field: - if ptr == nil { - io.write_string(fi.writer, "", &fi.n) - return - } - if fi.indirection_level < 1 { - fi.indirection_level += 1 - defer fi.indirection_level -= 1 - io.write_byte(fi.writer, '&', &fi.n) - fmt_value(fi, a, verb) - return - } - } - } - } - fmt_pointer(fi, ptr, verb) - } + fmt_pointer_from_value(fi, v, info, verb) case runtime.Type_Info_Soa_Pointer: ptr := (^runtime.Raw_Soa_Pointer)(v.data)^ fmt_soa_pointer(fi, ptr, verb) case runtime.Type_Info_Multi_Pointer: - ptr := (^rawptr)(v.data)^ - if ptr == nil { - io.write_string(fi.writer, "", &fi.n) - return - } - if verb != 'p' && info.elem != nil { - a := any{ptr, info.elem.id} - - elem := runtime.type_info_base(info.elem) - if elem != nil { - if n, ok := fi.optional_len.?; ok { - fi.optional_len = nil - fmt_array(fi, ptr, n, elem.size, elem, verb) - return - } else if fi.use_nul_termination { - fi.use_nul_termination = false - fmt_array_nul_terminated(fi, ptr, -1, elem.size, elem, verb) - return - } - - #partial switch &e in elem.variant { - case runtime.Type_Info_Integer: - switch verb { - case 's', 'q': - switch elem.id { - case u8: - fmt_cstring(fi, cstring(ptr), verb) - return - case u16, u32, rune: - n := search_nul_termination(ptr, elem.size, -1) - fmt_array(fi, ptr, n, elem.size, elem, verb) - return - } - } - - case runtime.Type_Info_Array, - runtime.Type_Info_Slice, - runtime.Type_Info_Dynamic_Array, - runtime.Type_Info_Map: - if fi.indirection_level < 1 { - fi.indirection_level += 1 - defer fi.indirection_level -= 1 - io.write_byte(fi.writer, '&', &fi.n) - fmt_value(fi, a, verb) - return - } - - case runtime.Type_Info_Struct, - runtime.Type_Info_Union: - if fi.indirection_level < 1 { - fi.indirection_level += 1 - defer fi.indirection_level -= 1 - io.write_byte(fi.writer, '&', &fi.n) - fmt_value(fi, a, verb) - return - } - } - } - } - fmt_pointer(fi, ptr, verb) + fmt_multi_pointer(fi, v, info, verb) case runtime.Type_Info_Enumerated_Array: - fi.record_level += 1 - defer fi.record_level -= 1 - - if fi.hash { - io.write_byte(fi.writer, '[' if verb != 'w' else '{', &fi.n) - io.write_byte(fi.writer, '\n', &fi.n) - defer { - fmt_write_indent(fi) - io.write_byte(fi.writer, ']' if verb != 'w' else '}', &fi.n) - } - indent := fi.indent - fi.indent += 1 - defer fi.indent = indent - - for i in 0.. 0 { io.write_string(fi.writer, ", ", &fi.n) } - - idx, ok := stored_enum_value_to_string(info.index, info.min_value, i) - if ok { - io.write_byte(fi.writer, '.', &fi.n) - io.write_string(fi.writer, idx, &fi.n) - } else { - io.write_i64(fi.writer, i64(info.min_value)+i64(i), 10, &fi.n) - } - io.write_string(fi.writer, " = ", &fi.n) - - data := uintptr(v.data) + uintptr(i*info.elem_size) - fmt_arg(fi, any{rawptr(data), info.elem.id}, verb) - } - } + fmt_enumerated_array(fi, v, info, verb) case runtime.Type_Info_Array: n := info.count @@ -3104,63 +3250,7 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) { case runtime.Type_Info_Map: - switch verb { - case: - fmt_bad_verb(fi, verb) - case 'v', 'w': - if verb == 'v' { - io.write_string(fi.writer, "map", &fi.n) - } - io.write_byte(fi.writer, '[' if verb != 'w' else '{', &fi.n) - defer io.write_byte(fi.writer, ']' if verb != 'w' else '}', &fi.n) - - - hash := fi.hash; defer fi.hash = hash - indent := fi.indent; defer fi.indent -= 1 - do_trailing_comma := hash - - fi.indent += 1 - if hash { - io.write_byte(fi.writer, '\n', &fi.n) - } - defer { - if hash { - for _ in 0.. 0 { io.write_string(fi.writer, ", ") } - if hash { - fmt_write_indent(fi) - } - j += 1 - - key := runtime.map_cell_index_dynamic(ks, info.map_info.ks, bucket_index) - value := runtime.map_cell_index_dynamic(vs, info.map_info.vs, bucket_index) - - fmt_arg(&Info{writer = fi.writer}, any{rawptr(key), info.key.id}, verb) - if hash { - io.write_string(fi.writer, " = ", &fi.n) - } else { - io.write_string(fi.writer, "=", &fi.n) - } - fmt_arg(fi, any{rawptr(value), info.value.id}, verb) - - if do_trailing_comma { io.write_string(fi.writer, ",\n", &fi.n) } - } - } - } + fmt_map(fi, v, info, verb) case runtime.Type_Info_Struct: fmt_struct(fi, v, verb, info, "") diff --git a/core/image/general.odin b/core/image/general.odin index 1662cf14e..779f5d0b1 100644 --- a/core/image/general.odin +++ b/core/image/general.odin @@ -86,7 +86,7 @@ which_bytes :: proc(data: []byte) -> Which_File_Type { return v } get16le :: #force_inline proc(s: ^string) -> u16 { - v := u16(s[0]) | u16(s[1])<<16 + v := u16(s[0]) | u16(s[1])<<8 s^ = s[2:] return v } diff --git a/core/image/tga/tga.odin b/core/image/tga/tga.odin index 260720bb4..1941b53f9 100644 --- a/core/image/tga/tga.odin +++ b/core/image/tga/tga.odin @@ -152,7 +152,7 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a // Intentionally blank case .Uncompressed_Black_White: black_white = true - dest_depth = 24 + dest_depth = 8 if .do_not_expand_grayscale in options else 24 case .Uncompressed_Color_Mapped: color_mapped = true case .Compressed_Color_Mapped: @@ -161,7 +161,7 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a case .Compressed_Black_White: black_white = true rle_encoding = true - dest_depth = 24 + dest_depth = 8 if .do_not_expand_grayscale in options else 24 case: return nil, .Unsupported_Format @@ -180,6 +180,9 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a } switch dest_depth { + case 8: // R8 + src_channels = 1 + dest_channels = 1 case 15: // B5G5R5 src_channels = 2 dest_channels = 3 diff --git a/core/io/util.odin b/core/io/util.odin index 86a89cfb1..a82a80be0 100644 --- a/core/io/util.odin +++ b/core/io/util.odin @@ -21,12 +21,12 @@ write_ptr_at :: proc(w: Writer_At, p: rawptr, byte_size: int, offset: i64, n_wri } write_u64 :: proc(w: Writer, i: u64, base: int = 10, n_written: ^int = nil) -> (n: int, err: Error) { - buf: [32]byte + buf: [64]byte s := strconv.write_bits(buf[:], i, base, false, 64, strconv.digits, nil) return write_string(w, s, n_written) } write_i64 :: proc(w: Writer, i: i64, base: int = 10, n_written: ^int = nil) -> (n: int, err: Error) { - buf: [32]byte + buf: [65]byte s := strconv.write_bits(buf[:], u64(i), base, true, 64, strconv.digits, nil) return write_string(w, s, n_written) } @@ -39,12 +39,12 @@ write_int :: proc(w: Writer, i: int, base: int = 10, n_written: ^int = nil) -> ( } write_u128 :: proc(w: Writer, i: u128, base: int = 10, n_written: ^int = nil) -> (n: int, err: Error) { - buf: [39]byte + buf: [128]byte s := strconv.write_bits_128(buf[:], i, base, false, 128, strconv.digits, nil) return write_string(w, s, n_written) } write_i128 :: proc(w: Writer, i: i128, base: int = 10, n_written: ^int = nil) -> (n: int, err: Error) { - buf: [40]byte + buf: [129]byte s := strconv.write_bits_128(buf[:], u128(i), base, true, 128, strconv.digits, nil) return write_string(w, s, n_written) } diff --git a/core/math/rand/rand.odin b/core/math/rand/rand.odin index 41b066255..2ed2c9e70 100644 --- a/core/math/rand/rand.odin +++ b/core/math/rand/rand.odin @@ -260,7 +260,7 @@ Example: Possible Output: 6 - 500 + 13 */ @(require_results) @@ -301,7 +301,7 @@ Example: Possible Output: 6 - 500 + 13 */ @(require_results) @@ -342,7 +342,7 @@ Example: Possible Output: 6 - 500 + 13 */ @(require_results) diff --git a/core/math/rand/rand_pcg.odin b/core/math/rand/rand_pcg.odin index 009e139be..79c18acbb 100644 --- a/core/math/rand/rand_pcg.odin +++ b/core/math/rand/rand_pcg.odin @@ -55,16 +55,20 @@ pcg_random_generator_proc :: proc(data: rawptr, mode: runtime.Random_Generator_M intrinsics.unaligned_store((^u64)(raw_data(p)), read_u64(r)) case: // All other cases. - pos := i8(0) - val := u64(0) - for &v in p { - if pos == 0 { - val = read_u64(r) - pos = 8 + n := len(p) / size_of(u64) + buff := ([^]u64)(raw_data(p))[:n] + for &e in buff { + intrinsics.unaligned_store(&e, read_u64(r)) + } + // Handle remaining bytes + rem := len(p) % size_of(u64) + if rem > 0 { + val := read_u64(r) + tail := p[len(p) - rem:] + for &b in tail { + b = byte(val) + val >>= 8 } - v = byte(val) - val >>= 8 - pos -= 1 } } diff --git a/core/math/rand/rand_xoshiro256.odin b/core/math/rand/rand_xoshiro256.odin index 54dd02130..7326ba8d5 100644 --- a/core/math/rand/rand_xoshiro256.odin +++ b/core/math/rand/rand_xoshiro256.odin @@ -74,16 +74,20 @@ xoshiro256_random_generator_proc :: proc(data: rawptr, mode: runtime.Random_Gene intrinsics.unaligned_store((^u64)(raw_data(p)), read_u64(r)) case: // All other cases. - pos := i8(0) - val := u64(0) - for &v in p { - if pos == 0 { - val = read_u64(r) - pos = 8 + n := len(p) / size_of(u64) + buff := ([^]u64)(raw_data(p))[:n] + for &e in buff { + intrinsics.unaligned_store(&e, read_u64(r)) + } + // Handle remaining bytes + rem := len(p) % size_of(u64) + if rem > 0 { + val := read_u64(r) + tail := p[len(p) - rem:] + for &b in tail { + b = byte(val) + val >>= 8 } - v = byte(val) - val >>= 8 - pos -= 1 } } diff --git a/core/nbio/doc.odin b/core/nbio/doc.odin new file mode 100644 index 000000000..706d9d42f --- /dev/null +++ b/core/nbio/doc.odin @@ -0,0 +1,213 @@ +/* +package nbio implements a non-blocking I/O and event loop abstraction layer +over several platform-specific asynchronous I/O APIs. + +More examples can be found in Odin's examples repository +at [[ examples/nbio ; https://github.com/odin-lang/examples/tree/master/nbio ]]. + +**Event Loop**: + +Each thread may have at most one event loop associated with it. +This is enforced by the package, as running multiple event loops on a single +thread does not make sense. + +Event loops are reference counted and managed by the package. + +`acquire_thread_event_loop` and `release_thread_event_loop` can be used +to acquire and release a reference. Acquiring must be done before any operation +is done. + +The event loop progresses in ticks. A tick checks if any work is to be done, +and based on the given timeout may block waiting for work. + +Ticks are typically done using the `tick`, `run`, and `run_until` procedures. + +Example: + package main + + import "core:nbio" + import "core:time" + import "core:fmt" + + main :: proc() { + err := nbio.acquire_thread_event_loop() + assert(err == nil) + defer nbio.release_thread_event_loop() + + nbio.timeout(time.Second, proc(_: ^nbio.Operation) { + fmt.println("Hellope after 1 second!") + }) + + err = nbio.run() + assert(err == nil) + } + + +**Time and timeouts**: + +Timeouts are intentionally *slightly inaccurate* by design. + +A timeout is not checked continuously, instead, it is evaluated only when +a tick occurs. This means if a tick took a long time, your timeout may be ready +for a bit of time already before the callback is called. + +The function `now` returns the current time as perceived by the event +loop. This value is cached at least once per tick so it is fast to retrieve. + +Most operations also take an optional timeout when executed. +If the timeout completes before the operation, the operation is cancelled and +called back with a `.Timeout` error. + + +**Threading**: + +The package has a concept of I/O threads (threads that are ticking) and worker +threads (any other thread). + +An I/O thread is mostly self contained, operations are executed on it, and +callbacks run on it. + +If you try to execute an operation on a thread that has no running event loop +a panic will be executed. Instead a worker thread can execute operations onto +a running event loop by taking it's reference and executing operations with +that reference. + +In this case: +- The operation is enqueued from the worker thread +- The I/O thread is optionally woken up from blocking for work with `wake_up` +- The next tick, the operation is executed by the I/O thread +- The callback is invoked on the I/O thread + +Example: + package main + + import "core:nbio" + import "core:net" + import "core:thread" + import "core:time" + + Connection :: struct { + loop: ^nbio.Event_Loop, + socket: net.TCP_Socket, + } + + main :: proc() { + workers: thread.Pool + thread.pool_init(&workers, context.allocator, 2) + thread.pool_start(&workers) + + err := nbio.acquire_thread_event_loop() + defer nbio.release_thread_event_loop() + assert(err == nil) + + server, listen_err := nbio.listen_tcp({nbio.IP4_Any, 1234}) + assert(listen_err == nil) + nbio.accept_poly(server, &workers, on_accept) + + err = nbio.run() + assert(err == nil) + + on_accept :: proc(op: ^nbio.Operation, workers: ^thread.Pool) { + assert(op.accept.err == nil) + + nbio.accept_poly(op.accept.socket, workers, on_accept) + + thread.pool_add_task(workers, context.allocator, do_work, new_clone(Connection{ + loop = op.l, + socket = op.accept.client, + })) + } + + do_work :: proc(t: thread.Task) { + connection := (^Connection)(t.data) + + // Imagine CPU intensive work that's been ofloaded to a worker thread. + time.sleep(time.Second * 1) + + nbio.send_poly(connection.socket, {transmute([]byte)string("Hellope!\n")}, connection, on_sent, l=connection.loop) + } + + on_sent :: proc(op: ^nbio.Operation, connection: ^Connection) { + assert(op.send.err == nil) + // Client got our message, clean up. + nbio.close(connection.socket) + free(connection) + } + } + + +**Handle and socket association**: + +Most platforms require handles (files, sockets, etc.) to be explicitly +associated with an event loop or configured for non-blocking/asynchronous +operation. + +On some platforms (notably Windows), this requires a specific flag at open +time (`.Non_Blocking` for `core:os`) and association may fail if the handle was +not created correctly. + +For this reason, prefer `open` and `create_socket` from this package instead. + +`associate_handle`, `associate_file`, and `associate_socket` can be used for +externally opened files/sockets. + + +**Offsets and positional I/O**: + +Operations do not implicitly use or modify a handle’s internal file +offset. + +Instead, operations such as `read` and `write` are *positional* and require +an explicit offset. + +This avoids ambiguity and subtle bugs when multiple asynchronous operations +are issued concurrently against the same handle. + + +**Contexts and callbacks**: + +The `context` inside a callback is *not* the context that submitted the +operation. + +Instead, the callback receives the context that was active when the event +loop function (`tick`, `run`, etc.) was called. + +This is because otherwise the context would have to be copied and held onto for +each operation. + +If the submitting context is required inside the callback, it must be copied +into the operation’s user data explicitly. + +Example: + nbio.timeout_poly(time.Second, new_clone(context), proc(_: ^Operation, ctx: ^runtime.Context) { + context = ctx^ + free(ctx) + }) + + +**Callback scheduling guarantees**: + +Callbacks are guaranteed to be invoked in a later tick, never synchronously. +This means that the operation returned from a procedure is at least valid till +the end of the current tick, because an operation is freed after it's callback +is called. Thus you can set user data after an execution is queued, or call +`remove`, removing subtle "race" conditions and simplifying control flow. + +**Why does the design of this package use callbacks?** + +Callbacks are the simplest interface an event loop can reasonably expose: "Run +this when the operation completes". This means the loop itself doesn’t need to +know how the result is consumed (You could give control of the entire loop to +the user, but that comes with all the problems in that). + +Other mechanisms can be built on top of this, such as coroutines or even a queue +you comsume at your own time. + +The choice of one `Operation` type and one callback type for all the operations +is partly so it is easy to bind into Lua-like or native coroutines. + +Callbacks also allow multiple independent users to share the same event loop. +A package can register its own operations, and application code can register +others, without either seeing or handling the other’s completions. +*/ +package nbio diff --git a/core/nbio/errors.odin b/core/nbio/errors.odin new file mode 100644 index 000000000..f3bd381d5 --- /dev/null +++ b/core/nbio/errors.odin @@ -0,0 +1,84 @@ +package nbio + +import "base:intrinsics" + +import "core:reflect" + +Error :: intrinsics.type_merge( + Network_Error, + union #shared_nil { + General_Error, + FS_Error, + }, +) +#assert(size_of(Error) == 8) + +// Errors regarding general usage of the event loop. +General_Error :: enum i32 { + None, + + Allocation_Failed = i32(PLATFORM_ERR_ALLOCATION_FAILED), + Unsupported = i32(PLATFORM_ERR_UNSUPPORTED), +} + +// Errors gotten from file system operations. +FS_Error :: enum i32 { + None, + Unsupported = i32(PLATFORM_ERR_UNSUPPORTED), + Allocation_Failed = i32(PLATFORM_ERR_ALLOCATION_FAILED), + Timeout = i32(PLATFORM_ERR_TIMEOUT), + Invalid_Argument = i32(PLATFORM_ERR_INVALID_ARGUMENT), + Permission_Denied = i32(PLATFORM_ERR_PERMISSION_DENIED), + EOF = i32(PLATFORM_ERR_EOF), + Exists = i32(PLATFORM_ERR_EXISTS), + Not_Found = i32(PLATFORM_ERR_NOT_FOUND), +} + +Platform_Error :: _Platform_Error + +error_string :: proc(err: Error) -> string { + err := err + variant := any{ + id = reflect.union_variant_typeid(err), + data = &err, + } + str := reflect.enum_string(variant) + + if str == "" { + #partial switch uerr in err { + case FS_Error: + str, _ = reflect.enum_name_from_value(Platform_Error(uerr)) + case General_Error: + str, _ = reflect.enum_name_from_value(Platform_Error(uerr)) + } + } + if str == "" { + str = "Unknown" + } + + return str +} + +error_string_recv :: proc(recv_err: Recv_Error) -> string { + switch err in recv_err { + case TCP_Recv_Error: return error_string(err) + case UDP_Recv_Error: return error_string(err) + case: return "Unknown" + } +} + +error_string_send :: proc(send_err: Send_Error) -> string { + switch err in send_err { + case TCP_Send_Error: return error_string(err) + case UDP_Send_Error: return error_string(err) + case: return "Unknown" + } +} + +error_string_sendfile :: proc(send_err: Send_File_Error) -> string { + switch err in send_err { + case TCP_Send_Error: return error_string(err) + case FS_Error: return error_string(err) + case: return "Unknown" + } +} diff --git a/core/nbio/errors_linux.odin b/core/nbio/errors_linux.odin new file mode 100644 index 000000000..5c3472500 --- /dev/null +++ b/core/nbio/errors_linux.odin @@ -0,0 +1,16 @@ +#+private +package nbio + +import "core:sys/linux" + +PLATFORM_ERR_UNSUPPORTED :: linux.Errno.ENOSYS +PLATFORM_ERR_ALLOCATION_FAILED :: linux.Errno.ENOMEM +PLATFORM_ERR_TIMEOUT :: linux.Errno.ECANCELED +PLATFORM_ERR_INVALID_ARGUMENT :: linux.Errno.EINVAL +PLATFORM_ERR_OVERFLOW :: linux.Errno.E2BIG +PLATFORM_ERR_NOT_FOUND :: linux.Errno.ENOENT +PLATFORM_ERR_EXISTS :: linux.Errno.EEXIST +PLATFORM_ERR_PERMISSION_DENIED :: linux.Errno.EPERM +PLATFORM_ERR_EOF :: -100 // There is no EOF errno, we use negative for our own error codes. + +_Platform_Error :: linux.Errno diff --git a/core/nbio/errors_others.odin b/core/nbio/errors_others.odin new file mode 100644 index 000000000..f27c91178 --- /dev/null +++ b/core/nbio/errors_others.odin @@ -0,0 +1,20 @@ +#+build !darwin +#+build !freebsd +#+build !openbsd +#+build !netbsd +#+build !linux +#+build !windows +#+private +package nbio + +PLATFORM_ERR_UNSUPPORTED :: 1 +PLATFORM_ERR_ALLOCATION_FAILED :: 2 +PLATFORM_ERR_TIMEOUT :: 3 +PLATFORM_ERR_INVALID_ARGUMENT :: 4 +PLATFORM_ERR_OVERFLOW :: 5 +PLATFORM_ERR_NOT_FOUND :: 6 +PLATFORM_ERR_EXISTS :: 7 +PLATFORM_ERR_PERMISSION_DENIED :: 8 +PLATFORM_ERR_EOF :: 9 + +_Platform_Error :: enum i32 {} diff --git a/core/nbio/errors_posix.odin b/core/nbio/errors_posix.odin new file mode 100644 index 000000000..3dd8f781d --- /dev/null +++ b/core/nbio/errors_posix.odin @@ -0,0 +1,17 @@ +#+build darwin, freebsd, netbsd, openbsd +#+private +package nbio + +import "core:sys/posix" + +PLATFORM_ERR_UNSUPPORTED :: posix.Errno.ENOSYS +PLATFORM_ERR_ALLOCATION_FAILED :: posix.Errno.ENOMEM +PLATFORM_ERR_TIMEOUT :: posix.Errno.ECANCELED +PLATFORM_ERR_INVALID_ARGUMENT :: posix.Errno.EINVAL +PLATFORM_ERR_OVERFLOW :: posix.Errno.E2BIG +PLATFORM_ERR_NOT_FOUND :: posix.Errno.ENOENT +PLATFORM_ERR_EXISTS :: posix.Errno.EEXIST +PLATFORM_ERR_PERMISSION_DENIED :: posix.Errno.EPERM +PLATFORM_ERR_EOF :: -100 // There is no EOF errno, we use negative for our own error codes. + +_Platform_Error :: posix.Errno diff --git a/core/nbio/errors_windows.odin b/core/nbio/errors_windows.odin new file mode 100644 index 000000000..d9b3b7e4d --- /dev/null +++ b/core/nbio/errors_windows.odin @@ -0,0 +1,17 @@ +#+private +package nbio + +import win "core:sys/windows" + +PLATFORM_ERR_UNSUPPORTED :: win.System_Error.NOT_SUPPORTED + +PLATFORM_ERR_ALLOCATION_FAILED :: win.System_Error.OUTOFMEMORY +PLATFORM_ERR_TIMEOUT :: win.System_Error.WAIT_TIMEOUT +PLATFORM_ERR_INVALID_ARGUMENT :: win.System_Error.BAD_ARGUMENTS +PLATFORM_ERR_OVERFLOW :: win.System_Error.BUFFER_OVERFLOW +PLATFORM_ERR_NOT_FOUND :: win.System_Error.FILE_NOT_FOUND +PLATFORM_ERR_EXISTS :: win.System_Error.FILE_EXISTS +PLATFORM_ERR_PERMISSION_DENIED :: win.System_Error.ACCESS_DENIED +PLATFORM_ERR_EOF :: win.System_Error.HANDLE_EOF + +_Platform_Error :: win.System_Error diff --git a/core/nbio/impl.odin b/core/nbio/impl.odin new file mode 100644 index 000000000..476b8ab43 --- /dev/null +++ b/core/nbio/impl.odin @@ -0,0 +1,259 @@ +#+private +package nbio + +import "base:runtime" +import "base:intrinsics" + +import "core:container/pool" +import "core:net" +import "core:strings" +import "core:time" +import "core:reflect" + +@(init, private) +init_thread_local_cleaner :: proc "contextless" () { + runtime.add_thread_local_cleaner(proc() { + l := &_tls_event_loop + if l.refs > 0 { + l.refs = 1 + _release_thread_event_loop() + } + }) +} + +@(thread_local) +_tls_event_loop: Event_Loop + +_acquire_thread_event_loop :: proc() -> General_Error { + l := &_tls_event_loop + if l.err == nil && l.refs == 0 { + when ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32 && ODIN_OS != .Orca { + allocator := runtime.default_wasm_allocator() + } else { + allocator := runtime.heap_allocator() + } + + l.allocator = allocator + + if alloc_err := mpsc_init(&l.queue, 128, l.allocator); alloc_err != nil { + l.err = .Allocation_Failed + return l.err + } + defer if l.err != nil { mpsc_destroy(&l.queue, l.allocator) } + + if pool_err := pool.init(&l.operation_pool, "_pool_link"); pool_err != nil { + l.err = .Allocation_Failed + return l.err + } + defer if l.err != nil { pool.destroy(&l.operation_pool) } + + l.err = _init(l, allocator) + l.now = time.now() + } + + if l.err != nil { + return l.err + } + + l.refs += 1 + return nil +} + +_release_thread_event_loop :: proc() { + l := &_tls_event_loop + if l.err != nil { + assert(l.refs == 0) + return + } + + if l.refs > 0 { + l.refs -= 1 + if l.refs == 0 { + mpsc_destroy(&l.queue, l.allocator) + pool.destroy(&l.operation_pool) + _destroy(l) + l^ = {} + } + } +} + +_current_thread_event_loop :: #force_inline proc(loc := #caller_location) -> (^Event_Loop) { + l := &_tls_event_loop + + if intrinsics.expect(l.refs == 0, false) { + return nil + } + + return l +} + +_tick :: proc(l: ^Event_Loop, timeout: time.Duration) -> (err: General_Error) { + // Receive operations queued from other threads first. + for { + op := (^Operation)(mpsc_dequeue(&l.queue)) + if op == nil { break } + _exec(op) + } + + return __tick(l, timeout) +} + +_listen_tcp :: proc( + l: ^Event_Loop, + endpoint: Endpoint, + backlog := 1000, + loc := #caller_location, +) -> ( + socket: TCP_Socket, + err: Network_Error, +) { + family := family_from_endpoint(endpoint) + socket = create_tcp_socket(family, l, loc) or_return + defer if err != nil { close(socket, l=l) } + + net.set_option(socket, .Reuse_Address, true) + + bind(socket, endpoint) or_return + + _listen(socket, backlog) or_return + return +} + +_read_entire_file :: proc(l: ^Event_Loop, path: string, user_data: rawptr, cb: Read_Entire_File_Callback, allocator := context.allocator, dir := CWD) { + open_poly3(path, user_data, cb, allocator, on_open, dir=dir, l=l) + + on_open :: proc(op: ^Operation, user_data: rawptr, cb: Read_Entire_File_Callback, allocator: runtime.Allocator) { + if op.open.err != nil { + cb(user_data, nil, {.Open, op.open.err}) + return + } + + stat_poly3(op.open.handle, user_data, cb, allocator, on_stat) + } + + on_stat :: proc(op: ^Operation, user_data: rawptr, cb: Read_Entire_File_Callback, allocator: runtime.Allocator) { + if op.stat.err != nil { + close(op.stat.handle) + cb(user_data, nil, {.Stat, op.stat.err}) + return + } + + if op.stat.type != .Regular { + close(op.stat.handle) + cb(user_data, nil, {.Stat, .Unsupported}) + return + } + + buf, err := make([]byte, op.stat.size, allocator) + if err != nil { + close(op.stat.handle) + cb(user_data, nil, {.Read, .Allocation_Failed}) + return + } + + read_poly3(op.stat.handle, 0, buf, user_data, cb, allocator, on_read, all=true) + } + + on_read :: proc(op: ^Operation, user_data: rawptr, cb: Read_Entire_File_Callback, allocator: runtime.Allocator) { + close(op.read.handle) + + if op.read.err != nil { + delete(op.read.buf, allocator) + cb(user_data, nil, {.Read, op.read.err}) + return + } + + assert(op.read.read == len(op.read.buf)) + cb(user_data, op.read.buf, {}) + } +} + +NBIO_DEBUG :: #config(NBIO_DEBUG, false) + +Debuggable :: union { + Operation_Type, + string, + int, + time.Time, + time.Duration, +} + +@(disabled=!NBIO_DEBUG) +debug :: proc(contents: ..Debuggable, location := #caller_location) { + if context.logger.procedure == nil || .Debug < context.logger.lowest_level { + return + } + + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() + + b: strings.Builder + b.buf.allocator = context.temp_allocator + + strings.write_string(&b, "[nbio] ") + + for content, i in contents { + switch val in content { + case Operation_Type: + name, _ := reflect.enum_name_from_value(val) + strings.write_string(&b, name) + case string: + strings.write_string(&b, val) + case int: + strings.write_int(&b, val) + case time.Duration: + ms := time.duration_milliseconds(val) + strings.write_f64(&b, ms, 'f') + strings.write_string(&b, "ms") + + case time.Time: + buf: [time.MIN_HMS_LEN+1]byte + h, m, s, ns := time.precise_clock_from_time(val) + buf[8] = '.' + buf[7] = '0' + u8(s % 10); s /= 10 + buf[6] = '0' + u8(s) + buf[5] = ':' + buf[4] = '0' + u8(m % 10); m /= 10 + buf[3] = '0' + u8(m) + buf[2] = ':' + buf[1] = '0' + u8(h % 10); h /= 10 + buf[0] = '0' + u8(h) + + strings.write_string(&b, string(buf[:])) + strings.write_int(&b, ns) + } + + if i < len(contents)-1 { + strings.write_byte(&b, ' ') + } + } + + context.logger.procedure(context.logger.data, .Debug, strings.to_string(b), context.logger.options, location) +} + +warn :: proc(text: string, location := #caller_location) { + if context.logger.procedure == nil || .Warning < context.logger.lowest_level { + return + } + + context.logger.procedure(context.logger.data, .Warning, text, context.logger.options, location) +} + +@(require_results) +constraint_bufs_to_max_rw :: proc(bufs: [][]byte) -> (constrained: [][]byte, total: int) { + for buf in bufs { + total += len(buf) + } + + constrained = bufs + for n := total; n > MAX_RW; { + last := &constrained[len(constrained)-1] + take := min(len(last), n-MAX_RW) + last^ = last[:take] + if len(last) == 0 { + constrained = constrained[:len(constrained)-1] + } + n -= take + } + + return +} diff --git a/core/nbio/impl_linux.odin b/core/nbio/impl_linux.odin new file mode 100644 index 000000000..47d47d77c --- /dev/null +++ b/core/nbio/impl_linux.odin @@ -0,0 +1,1423 @@ +#+private file +package nbio + +import "base:intrinsics" + +import "core:container/pool" +import "core:container/queue" +import "core:mem" +import "core:net" +import "core:slice" +import "core:strings" +import "core:sys/linux" +import "core:sys/linux/uring" +import "core:time" + +@(private="package") +_FULLY_SUPPORTED :: true + +@(private="package") +_Event_Loop :: struct { + ring: uring.Ring, + // Ready to be submitted to kernel, if kernel is full. + unqueued: queue.Queue(^Operation), + // Ready to run callbacks, mainly next tick, some other ops that error outside the kernel. + completed: queue.Queue(^Operation), + wake: ^Operation, +} + +@(private="package") +_Handle :: linux.Fd + +@(private="package") +_CWD :: linux.AT_FDCWD + +@(private="package") +MAX_RW :: mem.Gigabyte + +@(private="package") +_Operation :: struct { + removal: ^Operation, + sqe: ^linux.IO_Uring_SQE, + expires: linux.Time_Spec, +} + +@(private="package") +_Accept :: struct { + sockaddr: linux.Sock_Addr_Any, + sockaddr_len: i32, +} + +@(private="package") +_Close :: struct {} + +@(private="package") +_Dial :: struct { + sockaddr: linux.Sock_Addr_Any, +} + +@(private="package") +_Read :: struct {} + +@(private="package") +_Write :: struct {} + +@(private="package") +_Send :: struct { + endpoint: linux.Sock_Addr_Any, + msghdr: linux.Msg_Hdr, + small_bufs: [1][]byte, +} + +@(private="package") +_Recv :: struct { + addr_out: linux.Sock_Addr_Any, + msghdr: linux.Msg_Hdr, + small_bufs: [1][]byte, +} + +@(private="package") +_Timeout :: struct { + expires: linux.Time_Spec, +} + +@(private="package") +_Poll :: struct {} + +@(private="package") +_Remove :: struct { + target: ^Operation, +} + +@(private="package") +_Link_Timeout :: struct { + target: ^Operation, + expires: linux.Time_Spec, +} + +@(private="package") +_Send_File :: struct { + len: int, + pipe: Handle, + + splice: ^Operation, +} + +@(private="package") +_Splice :: struct { + off: int, + len: int, + file: Handle, + pipe: Handle, + + written: int, + + sendfile: ^Operation, +} + +@(private="package") +_Open :: struct { + cpath: cstring, +} + +@(private="package") +_Stat :: struct { + buf: linux.Statx, +} + +@(private="package") +_init :: proc(l: ^Event_Loop, alloc: mem.Allocator) -> (err: General_Error) { + params := uring.DEFAULT_PARAMS + params.flags += {.SUBMIT_ALL, .COOP_TASKRUN, .SINGLE_ISSUER} + + uerr := uring.init(&l.ring, ¶ms, QUEUE_SIZE) + if uerr != nil { + err = General_Error(uerr) + return + } + defer if err != nil { uring.destroy(&l.ring) } + + if perr := queue.init(&l.unqueued, allocator = alloc); perr != nil { + err = .Allocation_Failed + return + } + defer if err != nil { queue.destroy(&l.unqueued) } + + if perr := queue.init(&l.completed, allocator = alloc); perr != nil { + err = .Allocation_Failed + return + } + defer if err != nil { queue.destroy(&l.completed) } + + set_up_wake_up(l) or_return + + return + + set_up_wake_up :: proc(l: ^Event_Loop) -> General_Error { + wakefd, wakefd_err := linux.eventfd(0, {.SEMAPHORE, .CLOEXEC, .NONBLOCK}) + if wakefd_err != nil { + return General_Error(wakefd_err) + } + + op, alloc_err := new(Operation, l.allocator) + if alloc_err != nil { + linux.close(wakefd) + return .Allocation_Failed + } + + l.wake = op + l.wake.detached = true + l.wake.l = l + l.wake.type = .Read + l.wake.cb = wake_up_callback + l.wake.read.handle = wakefd + l.wake.read.buf = ([^]byte)(&l.wake.user_data)[:8] + _exec(l.wake) + + return nil + } + + wake_up_callback :: proc(op: ^Operation) { + assert(op.type == .Read) + assert(op == op.l.wake) + assert(op.read.err == nil) + assert(op.read.read == 8) + value := intrinsics.unaligned_load((^u64)(&op.user_data)) + assert(value > 0) + debug(int(value), "wake_up calls handled") + + op.read.read = 0 + op.user_data = {} + _exec(op) + } +} + +@(private="package") +_destroy :: proc(l: ^Event_Loop) { + linux.close(l.wake.read.handle) + free(l.wake, l.allocator) + + queue.destroy(&l.unqueued) + queue.destroy(&l.completed) + uring.destroy(&l.ring) +} + +@(private="package") +__tick :: proc(l: ^Event_Loop, timeout: time.Duration) -> General_Error { + debug("tick") + + // Execute completed operations, mostly next tick ops, also some other ops that may error before + // adding it to the Uring. + n := queue.len(l.completed) + if n > 0 { + l.now = time.now() + for _ in 0 ..< n { + completed := queue.pop_front(&l.completed) + if completed._impl.removal == nil { + completed.cb(completed) + } else if completed._impl.removal != (^Operation)(REMOVED) { + completed._impl.removal._remove.target = nil + } + if !completed.detached { + pool.put(&l.operation_pool, completed) + } + } + } + + err := _flush_submissions(l, timeout) + if err != nil { return General_Error(err) } + + l.now = time.now() + + err = _flush_completions(l, false) + if err != nil { return General_Error(err) } + + return nil + + _flush_completions :: proc(l: ^Event_Loop, wait: bool) -> linux.Errno { + wait := wait + cqes: [128]linux.IO_Uring_CQE = --- + for { + completed, err := uring.copy_cqes(&l.ring, cqes[:], 1 if wait else 0) + if err == .EINTR { + continue + } else if err != nil { + return err + } + + _flush_unqueued(l) + + if completed > 0 { + debug(int(completed), "operations returned from uring") + } + + for cqe in cqes[:completed] { + assert(cqe.user_data != 0) + op, is_timeout := unpack_operation(cqe.user_data) + if is_timeout { + link_timeout_callback(op, cqe.res) + } else { + handle_completed(op, cqe.res) + } + } + + if completed < len(cqes) { break } + + debug("more events ready than our results buffer handles, getting more") + wait = false + } + + return nil + } + + _flush_submissions :: proc(l: ^Event_Loop, timeout: time.Duration) -> linux.Errno { + for { + ts: linux.Time_Spec + ts.time_nsec = uint(timeout) + _, err := uring.submit(&l.ring, 0 if timeout == 0 else 1, nil if timeout < 0 else &ts) + #partial switch err { + case .NONE, .ETIME: + case .EINTR: + warn("uring interrupted") + continue + case .ENOMEM: + // It's full, wait for at least one operation to complete and try again. + warn("could not flush submissions, ENOMEM, waiting for operations to complete before continuing") + ferr := _flush_completions(l, true) + if ferr != nil { return ferr } + continue + case: + return err + } + + break + } + + return nil + } + + _flush_unqueued :: proc(l: ^Event_Loop) { + n := queue.len(l.unqueued) + for _ in 0.. (handle: Handle, err: FS_Error) { + if path == "" { + err = .Invalid_Argument + return + } + + cpath, cerr := strings.clone_to_cstring(path, l.allocator) + if cerr != nil { + err = .Allocation_Failed + return + } + defer delete(cpath, l.allocator) + + sys_flags := linux.Open_Flags{.NOCTTY, .CLOEXEC, .NONBLOCK} + + if .Write in mode { + if .Read in mode { + sys_flags += {.RDWR} + } else { + sys_flags += {.WRONLY} + } + } + + if .Append in mode { sys_flags += {.APPEND} } + if .Create in mode { sys_flags += {.CREAT} } + if .Excl in mode { sys_flags += {.EXCL} } + if .Sync in mode { sys_flags += {.DSYNC} } + if .Trunc in mode { sys_flags += {.TRUNC} } + // if .Inheritable in mode { sys_flags -= {.CLOEXEC} } + + errno: linux.Errno + handle, errno = linux.openat(dir, cpath, sys_flags, transmute(linux.Mode)perm) + if errno != nil { + err = FS_Error(errno) + } + + return +} + +@(private="package") +_create_socket :: proc( + _: ^Event_Loop, + family: Address_Family, + protocol: Socket_Protocol, +) -> ( + socket: Any_Socket, + err: Create_Socket_Error, +) { + socket = net.create_socket(family, protocol) or_return + // NOTE: this doesn't seem needed with io uring. + // defer if err != nil { net.close(socket) } + // net.set_blocking(socket, false) or_return + return +} + +@(private="package") +_listen :: proc(socket: TCP_Socket, backlog := 1000) -> Listen_Error { + err := linux.listen(linux.Fd(socket), i32(backlog)) + if err != nil { + return net._listen_error(err) + } + return nil +} + +@(private="package") +_remove :: proc(target: ^Operation) { + target := target + assert(target != nil) + + if target._impl.removal != nil { + return + } + + op := _prep(target.l, proc(_: ^Operation) {}, ._Remove) + op._remove.target = target + + target._impl.removal = op + + enqueue(op, uring.async_cancel( + &op.l.ring, + u64(uintptr(target)), + u64(uintptr(op)), + )) +} + +@(private="package") +_associate_handle :: proc(handle: uintptr, l: ^Event_Loop) -> (Handle, Association_Error) { + // Works by default. + return Handle(handle), nil +} + +@(private="package") +_associate_socket :: proc(socket: Any_Socket, l: ^Event_Loop) -> Association_Error { + // Works by default. + return nil +} + +@(private="package") +_wake_up :: proc(l: ^Event_Loop) { + assert(l != &_tls_event_loop) + one: u64 = 1 + // Called from another thread, in which we can't use the uring. + n, err := linux.write(l.wake.read.handle, ([^]byte)(&one)[:size_of(one)]) + // Shouldn't fail. + assert(err == nil) + assert(n == 8) +} + +@(private="package") +_yield :: proc() { + linux.sched_yield() +} + +// Start file private. + +// The size of the IO Uring queues. +QUEUE_SIZE :: #config(ODIN_NBIO_QUEUE_SIZE, 2048) +#assert(QUEUE_SIZE <= uring.MAX_ENTRIES) + +#assert(size_of(Operation) <= 384) // Just so we see when we make it bigger. +#assert(size_of(Specifics) <= 288) // Just so we see when we make it bigger. + +REMOVED :: rawptr(max(uintptr)-1) + +handle_completed :: proc(op: ^Operation, res: i32) { + debug("handling", op.type, "result", int(res)) + + switch op.type { + case .Accept: + accept_callback(op, res) + case .Dial: + dial_callback(op, res) + case .Timeout: + timeout_callback(op, res) + case .Write: + if !write_callback(op, res) { return } + case .Read: + if !read_callback(op, res) { return } + case .Close: + close_callback(op, res) + case .Poll: + poll_callback(op, res) + case .Send: + if !send_callback(op, res) { return } + maybe_callback(op) + if len(op.send.bufs) > 1 { delete(op.send.bufs, op.l.allocator) } + cleanup(op) + return + case .Recv: + if !recv_callback(op, res) { return } + maybe_callback(op) + if len(op.recv.bufs) > 1 { delete(op.recv.bufs, op.l.allocator) } + cleanup(op) + return + case .Open: + open_callback(op, res) + case .Stat: + stat_callback(op, res) + case .Send_File: + if !sendfile_callback(op, res) { return } + case ._Splice: + if !splice_callback(op, res) { return } + case ._Remove: + if !remove_callback(op, res) { return } + case ._Link_Timeout: + unreachable() + case .None: + fallthrough + case: + panic("corrupted operation") + } + + maybe_callback(op) + cleanup(op) + + maybe_callback :: proc(op: ^Operation) { + if op._impl.removal == nil { + debug("done, calling back", op.type) + op.cb(op) + } else if op._impl.removal == (^Operation)(REMOVED) { + debug("done but was cancelled by remove", op.type) + } else { + debug("done but has removal pending", op.type) + // If the remove callback sees their target is nil, they know it is done already. + op._impl.removal._remove.target = nil + } + } + + cleanup :: proc(op: ^Operation) { + if !op.detached { + pool.put(&op.l.operation_pool, op) + } + } +} + +enqueue :: proc(op: ^Operation, sqe: ^linux.IO_Uring_SQE, ok: bool) { + assert(uintptr(op) & LINK_TIMEOUT_MASK == 0) + debug("enqueue", op.type) + if !ok { + warn("queueing for next tick because the ring is full, queue size may need increasing") + pok, _ := queue.push_back(&op.l.unqueued, op) + ensure(pok, "unqueued queue allocation failure") + return + } + + op._impl.sqe = sqe +} + +LINK_TIMEOUT_MASK :: 1 + +link_timeout :: proc(target: ^Operation, expires: time.Time) { + if expires == {} { + return + } + + // If the last op was queued because kernel is full, return. + if target._impl.sqe == nil { + assert(queue.len(target.l.unqueued) > 0 && queue.back_ptr(&target.l.unqueued)^ == target) + return + } + + target._impl.sqe.flags += {.IO_LINK} + target._impl.expires = ns_to_time_spec(expires._nsec) + + // Tag the pointer as a timeout. + p := uintptr(target) + assert(p & LINK_TIMEOUT_MASK == 0) + p |= LINK_TIMEOUT_MASK + + _, ok := uring.link_timeout( + &target.l.ring, + u64(p), + &target._impl.expires, + {.ABS, .REALTIME}, + ) + // If the target wasn't queued, the link timeout should not need to be queued, because uring + // leaves one spot specifically for a link. + assert(ok) +} + +link_timeout_callback :: proc(op: ^Operation, res: i32) { + err := linux.Errno(-res) + if err != nil && err != .ETIME && err != .ECANCELED { + panic("unexpected nbio.link_timeout() error") + } +} + +unpack_operation :: #force_inline proc(user_data: u64) -> (op: ^Operation, timed_out: bool) { + p := uintptr(user_data) + return (^Operation)(p &~ LINK_TIMEOUT_MASK), bool(p & LINK_TIMEOUT_MASK) +} + +@(require_results) +remove_callback :: proc(op: ^Operation, res: i32) -> bool { + assert(op.type == ._Remove) + err := linux.Errno(-res) + + target := op._remove.target + if target == nil { + debug("remove target nil, already handled") + return true + } + + assert(target.type != .None) + assert(target._impl.removal == op) + + if err == .ENOENT { + debug("remove ENOENT, trying again") + + enqueue(op, uring.async_cancel( + &op.l.ring, + u64(uintptr(target)), + u64(uintptr(op)), + )) + + return false + } else if err == .EALREADY { + debug("remove is accepted and will be tried") + } else if err != nil { + assert(false, "unexpected nbio.remove() error") + } + + // Set to sentinel so nothing references the operation that will be reused. + target._impl.removal = (^Operation)(REMOVED) + return true +} + +accept_exec :: proc(op: ^Operation) { + assert(op.type == .Accept) + op.accept._impl.sockaddr_len = size_of(op.accept._impl.sockaddr) + enqueue(op, uring.accept( + &op.l.ring, + u64(uintptr(op)), + linux.Fd(op.accept.socket), + &op.accept._impl.sockaddr, + &op.accept._impl.sockaddr_len, + {}, + )) + link_timeout(op, op.accept.expires) +} + +accept_callback :: proc(op: ^Operation, res: i32) { + assert(op.type == .Accept) + if res < 0 { + errno := linux.Errno(-res) + #partial switch errno { + case .ECANCELED: + op.accept.err = .Timeout + case: + op.accept.err = net._accept_error(errno) + } + + return + } + + op.accept.client = TCP_Socket(res) + // net.set_blocking(net.TCP_Socket(op.accept.client), false) + op.accept.client_endpoint = sockaddr_storage_to_endpoint(&op.accept._impl.sockaddr) +} + +dial_exec :: proc(op: ^Operation) { + assert(op.type == .Dial) + if op.dial.socket == {} { + if op.dial.endpoint.port == 0 { + op.dial.err = .Port_Required + queue.push_back(&op.l.completed, op) + return + } + + sock, err := create_socket(net.family_from_endpoint(op.dial.endpoint), .TCP) + if err != nil { + op.dial.err = err + queue.push_back(&op.l.completed, op) + return + } + + op.dial.socket = sock.(TCP_Socket) + op.dial._impl.sockaddr = endpoint_to_sockaddr(op.dial.endpoint) + } + + enqueue(op, uring.connect( + &op.l.ring, + u64(uintptr(op)), + linux.Fd(op.dial.socket), + &op.dial._impl.sockaddr, + )) + link_timeout(op, op.dial.expires) +} + +dial_callback :: proc(op: ^Operation, res: i32) { + assert(op.type == .Dial) + errno := linux.Errno(-res) + if errno != nil { + #partial switch errno { + case .ECANCELED: + op.dial.err = Dial_Error.Timeout + case: + op.dial.err = net._dial_error(errno) + } + close(op.dial.socket) + } +} + +timeout_exec :: proc(op: ^Operation) { + assert(op.type == .Timeout) + if op.timeout.duration <= 0 { + queue.push_back(&op.l.completed, op) + return + } + + expires := time.time_add(op.l.now, op.timeout.duration) + op.timeout._impl.expires = ns_to_time_spec(expires._nsec) + + enqueue(op, uring.timeout( + &op.l.ring, + u64(uintptr(op)), + &op.timeout._impl.expires, + 0, + {.ABS, .REALTIME}, + )) +} + +timeout_callback :: proc(op: ^Operation, res: i32) { + if res < 0 { + errno := linux.Errno(-res) + #partial switch errno { + case .ETIME, .ECANCELED: // OK. + case: + debug("unexpected timeout error:", int(errno)) + panic("unexpected timeout error") + } + } +} + +close_exec :: proc(op: ^Operation) { + assert(op.type == .Close) + + fd: linux.Fd + switch closable in op.close.subject { + case Handle: fd = linux.Fd(closable) + case TCP_Socket: fd = linux.Fd(closable) + case UDP_Socket: fd = linux.Fd(closable) + case: op.close.err = .Invalid_Argument; return + } + + enqueue(op, uring.close( + &op.l.ring, + u64(uintptr(op)), + fd, + )) +} + +close_callback :: proc(op: ^Operation, res: i32) { + assert(op.type == .Close) + op.close.err = FS_Error(linux.Errno(-res)) +} + +recv_exec :: proc(op: ^Operation) { + assert(op.type == .Recv) + + if op.recv.err != nil { + queue.push_back(&op.l.completed, op) + return + } + + bufs := slice.advance_slices(op.recv.bufs, op.recv.received) + bufs, _ = constraint_bufs_to_max_rw(bufs) + op.recv._impl.msghdr.iov = transmute([]linux.IO_Vec)bufs + + sock: linux.Fd + switch socket in op.recv.socket { + case TCP_Socket: + sock = linux.Fd(socket) + case UDP_Socket: + sock = linux.Fd(socket) + op.recv._impl.msghdr.name = &op.recv._impl.addr_out + op.recv._impl.msghdr.namelen = size_of(op.recv._impl.addr_out) + } + + enqueue(op, uring.recvmsg( + &op.l.ring, + u64(uintptr(op)), + linux.Fd(sock), + &op.recv._impl.msghdr, + {.NOSIGNAL}, + )) + link_timeout(op, op.recv.expires) +} + +@(require_results) +recv_callback :: proc(op: ^Operation, res: i32) -> bool { + assert(op.type == .Recv) + + if res < 0 { + errno := linux.Errno(-res) + switch sock in op.recv.socket { + case TCP_Socket: + #partial switch errno { + case .ECANCELED: + op.recv.err = TCP_Recv_Error.Timeout + case: + op.recv.err = net._tcp_recv_error(errno) + } + case UDP_Socket: + #partial switch errno { + case .ECANCELED: + op.recv.err = UDP_Recv_Error.Timeout + case: + op.recv.err = net._udp_recv_error(errno) + } + } + + return true + } + + op.recv.received += int(res) + + switch sock in op.recv.socket { + case TCP_Socket: + if res == 0 { + // Connection closed. + return true + } + + if op.recv.all { + total: int + for buf in op.recv.bufs { + total += len(buf) + } + + if op.recv.received < total { + recv_exec(op) + return false + } + } + + case UDP_Socket: + op.recv.source = sockaddr_storage_to_endpoint(&op.recv._impl.addr_out) + } + + return true +} + +send_exec :: proc(op: ^Operation) { + assert(op.type == .Send) + + if op.send.err != nil { + queue.push_back(&op.l.completed, op) + return + } + + bufs := slice.advance_slices(op.send.bufs, op.send.sent) + bufs, _ = constraint_bufs_to_max_rw(bufs) + op.send._impl.msghdr.iov = transmute([]linux.IO_Vec)bufs + + sock: linux.Fd + switch socket in op.send.socket { + case TCP_Socket: + sock = linux.Fd(socket) + case UDP_Socket: + sock = linux.Fd(socket) + op.send._impl.endpoint = endpoint_to_sockaddr(op.send.endpoint) + op.send._impl.msghdr.name = &op.send._impl.endpoint + op.send._impl.msghdr.namelen = size_of(op.send._impl.endpoint) + } + + enqueue(op, uring.sendmsg( + &op.l.ring, + u64(uintptr(op)), + sock, + &op.send._impl.msghdr, + {.NOSIGNAL}, + )) + link_timeout(op, op.send.expires) +} + +@(require_results) +send_callback :: proc(op: ^Operation, res: i32) -> bool { + assert(op.type == .Send) + if res < 0 { + errno := linux.Errno(-res) + switch sock in op.send.socket { + case TCP_Socket: + #partial switch errno { + case .ECANCELED: + op.send.err = TCP_Send_Error.Timeout + case: + op.send.err = net._tcp_send_error(errno) + } + case UDP_Socket: + #partial switch errno { + case .ECANCELED: + op.send.err = UDP_Send_Error.Timeout + case: + op.send.err = net._udp_send_error(errno) + } + case: panic("corrupted socket") + } + + return true + } + + op.send.sent += int(res) + + if op.send.all { + total: int + for buf in op.send.bufs { + total += len(buf) + } + + if op.send.sent < total { + assert(res > 0) + send_exec(op) + return false + } + } + + return true +} + +write_exec :: proc(op: ^Operation) { + assert(op.type == .Write) + + buf := op.write.buf[op.write.written:] + buf = buf[:min(MAX_RW, len(buf))] + + enqueue(op, uring.write( + &op.l.ring, + u64(uintptr(op)), + op.write.handle, + buf, + u64(op.write.offset) + u64(op.write.written), + )) + link_timeout(op, op.write.expires) +} + +@(require_results) +write_callback :: proc(op: ^Operation, res: i32) -> bool { + if res < 0 { + errno := linux.Errno(-res) + op.write.err = FS_Error(errno) + return true + } + + op.write.written += int(res) + + if op.write.all && op.write.written < len(op.write.buf) { + write_exec(op) + return false + } + + return true +} + +read_exec :: proc(op: ^Operation) { + assert(op.type == .Read) + + buf := op.read.buf[op.read.read:] + buf = buf[:min(MAX_RW, len(buf))] + + enqueue(op, uring.read( + &op.l.ring, + u64(uintptr(op)), + op.read.handle, + buf, + u64(op.read.offset) + u64(op.read.read), + )) + link_timeout(op, op.read.expires) +} + +@(require_results) +read_callback :: proc(op: ^Operation, res: i32) -> bool { + if res < 0 { + errno := linux.Errno(-res) + op.read.err = FS_Error(errno) + return true + } else if res == 0 { + if op.read.read == 0 { + op.read.err = .EOF + } + return true + } + + op.read.read += int(res) + + if op.read.all && op.read.read < len(op.read.buf) { + read_exec(op) + return false + } + + return true +} + +poll_exec :: proc(op: ^Operation) { + assert(op.type == .Poll) + + events: linux.Fd_Poll_Events + switch op.poll.event { + case .Receive: events = { .IN } + case .Send: events = { .OUT } + } + + fd: linux.Fd + switch sock in op.poll.socket { + case TCP_Socket: fd = linux.Fd(sock) + case UDP_Socket: fd = linux.Fd(sock) + } + + enqueue(op, uring.poll_add( + &op.l.ring, + u64(uintptr(op)), + fd, + events, + {}, + )) + link_timeout(op, op.poll.expires) +} + +poll_callback :: proc(op: ^Operation, res: i32) { + if res < 0 { + errno := linux.Errno(-res) + #partial switch errno { + case .NONE: // no-op + case .ECANCELED: + op.poll.result = .Timeout + case .EINVAL, .EFAULT, .EBADF: + op.poll.result = .Invalid_Argument + case: + op.poll.result = .Error + } + + return + } + + op.poll.result = .Ready +} + +/* +`sendfile` is implemented with 2 splices over a pipe. + +Splice A: from file to pipe +Splice B: from pipe to socket (optionally linked to a timeout) + +The splices are hard-linked which means A completes before B. +B could get an `EWOULDBLOCK`, which is when the remote end has not read enough of the socket data yet. +In that case we enqueue a poll on the socket and continue when that completes. +A shouldn't get `EWOULDBLOCK`, but as a cautionary measure we handle it. + +The timeout is either linked to the splice B op, or the poll op, either of these is also always in progress in the kernel. +*/ +sendfile_exec :: proc(op: ^Operation, splice := true) { + assert(op.type == .Send_File) + + splice_done := !splice + if splice_op := op.sendfile._impl.splice; splice && splice_op != nil { + splice_done = splice_op._splice.written == splice_op._splice.len + } + + debug("sendfile_exec") + + if op.sendfile._impl.splice == nil { + // First stat for the file size. + if op.sendfile.nbytes == SEND_ENTIRE_FILE { + debug("sendfile SEND_ENTIRE_FILE, doing stat") + + stat_poly(op.sendfile.file, op, proc(stat_op: ^Operation, sendfile_op: ^Operation) { + if stat_op.stat.err != nil { + sendfile_op.sendfile.err = stat_op.stat.err + } else if stat_op.stat.type != .Regular { + sendfile_op.sendfile.err = FS_Error.Invalid_Argument + } else { + sendfile_op.sendfile.nbytes = int(i64(stat_op.stat.size) - i64(sendfile_op.sendfile.offset)) + if sendfile_op.sendfile.nbytes <= 0 { + sendfile_op.sendfile.err = FS_Error.Invalid_Argument + } + } + + if sendfile_op.sendfile.err != nil { + handle_completed(sendfile_op, 0) + return + } + + sendfile_exec(sendfile_op) + }) + return + } + + debug("sendfile setting up") + + rw: [2]linux.Fd + err := linux.pipe2(&rw, {.NONBLOCK, .CLOEXEC}) + if err != nil { + op.sendfile.err = FS_Error(err) + queue.push_back(&op.l.completed, op) + return + } + + splice_op := _prep(op.l, proc(_: ^Operation) { debug("sendfile splice helper callback") }, ._Splice) + splice_op._splice.sendfile = op + splice_op._splice.file = op.sendfile.file + splice_op._splice.pipe = rw[1] + splice_op._splice.off = op.sendfile.offset + splice_op._splice.len = op.sendfile.nbytes + + op.sendfile._impl.splice = splice_op + op.sendfile._impl.pipe = rw[0] + op.sendfile._impl.len = op.sendfile.nbytes + } + + splice_op: ^Operation + if !splice_done { + splice_op = op.sendfile._impl.splice + enqueue(splice_op, uring.splice( + &splice_op.l.ring, + u64(uintptr(splice_op)), + splice_op._splice.file, + i64(splice_op._splice.off) + i64(splice_op._splice.written), + splice_op._splice.pipe, + -1, + u32(min(splice_op._splice.len - splice_op._splice.written, MAX_RW)), + {.NONBLOCK}, + )) + } + + b, b_added := uring.splice( + &op.l.ring, + u64(uintptr(op)), + op.sendfile._impl.pipe, + -1, + linux.Fd(op.sendfile.socket), + -1, + u32(min(op.sendfile._impl.len - op.sendfile.sent, MAX_RW)), + {.NONBLOCK}, + ) + if !splice_done && b_added { + assert(splice_op._impl.sqe != nil) // if b was added successfully, a should've been too. + // Makes sure splice A (file to pipe) completes before splice B (pipe to socket). + splice_op._impl.sqe.flags += {.IO_HARDLINK} + } + enqueue(op, b, b_added) + + link_timeout(op, op.sendfile.expires) +} + +@(require_results) +splice_callback :: proc(op: ^Operation, res: i32) -> bool { + assert(op.type == ._Splice) + + if res < 0 { + errno := linux.Errno(-res) + #partial switch errno { + case .EAGAIN: + // Splice A (from file to pipe) would block, this means the buffer is full and it first needs + // to be sent over the socket by splice B (from pipe to socket). + // So we don't do anything here, once a splice B completes a new splice A will be created. + + case: + // Splice A (from file to pipe) error, we need to close the pipes, cancel the pending splice B, + // and call the callback with the error. + + debug("sendfile helper splice error, closing pipe") + + close(op._splice.pipe) + + // This is nil if this is a cancel originating from the sendfile. + // This is not nil if it is an actual error that happened on this splice. + sendfile_op := op._splice.sendfile + if sendfile_op != nil { + debug("sendfile helper splice error, cancelling main sendfile") + assert(sendfile_op.type == .Send_File) + + sendfile_op.sendfile._impl.splice = nil + sendfile_op.sendfile.err = FS_Error(errno) + } + } + + return true + } + + op._splice.written += int(res) + + sendfile_op := op._splice.sendfile + if sendfile_op != nil { + if op._splice.written < sendfile_op.sendfile.nbytes { + return false + } + + sendfile_op.sendfile._impl.splice = nil + } + + assert(op._splice.pipe > 0) + close(op._splice.pipe) + + debug("sendfile helper splice completely done") + return true +} + +@(require_results) +sendfile_callback :: proc(op: ^Operation, res: i32) -> bool { + assert(op.type == .Send_File) + + if op.sendfile.err == nil && res < 0 { + errno := linux.Errno(-res) + #partial switch errno { + case .EAGAIN: + // Splice B (from pipe to socket) would block. We are waiting on the remote to read more + // of our buffer before we can send more to it. + // We use a poll to find out when this is. + + debug("sendfile needs to poll") + + poll_op := poll_poly(op.sendfile.socket, .Send, op, proc(poll_op: ^Operation, sendfile_op: ^Operation) { + #partial switch poll_op.poll.result { + case .Ready: + // Do not enqueue a splice right away, we know there is at least one splice call worth of data in the kernel buffer. + sendfile_exec(sendfile_op, splice=false) + return + + case .Timeout: + sendfile_op.sendfile.err = TCP_Send_Error.Timeout + case: + sendfile_op.sendfile.err = TCP_Send_Error.Unknown + } + + debug("sendfile poll error") + handle_completed(sendfile_op, 0) + }) + + link_timeout(poll_op, op.sendfile.expires) + return false + + case .ECANCELED: + op.sendfile.err = TCP_Send_Error.Timeout + case: + op.sendfile.err = net._tcp_send_error(errno) + } + } + + if op.sendfile.err != nil { + debug("sendfile error") + + if op.sendfile._impl.pipe > 0 { + close(op.sendfile._impl.pipe) + } + + splice_op := op.sendfile._impl.splice + if splice_op != nil { + assert(splice_op.type == ._Splice) + splice_op._splice.sendfile = nil + _remove(splice_op) + } + + return true + } + + op.sendfile.sent += int(res) + if op.sendfile.sent < op.sendfile._impl.len { + debug("sendfile not completely done yet") + sendfile_exec(op) + if op.sendfile.progress_updates { op.cb(op) } + return false + } + + debug("sendfile completely done") + return true +} + +open_exec :: proc(op: ^Operation) { + assert(op.type == .Open) + + sys_flags := linux.Open_Flags{.NOCTTY, .CLOEXEC, .NONBLOCK} + + if .Write in op.open.mode { + if .Read in op.open.mode { + sys_flags += {.RDWR} + } else { + sys_flags += {.WRONLY} + } + } + + if .Append in op.open.mode { sys_flags += {.APPEND} } + if .Create in op.open.mode { sys_flags += {.CREAT} } + if .Excl in op.open.mode { sys_flags += {.EXCL} } + if .Sync in op.open.mode { sys_flags += {.DSYNC} } + if .Trunc in op.open.mode { sys_flags += {.TRUNC} } + // if .Inheritable in op.open.mode { sys_flags -= {.CLOEXEC} } + + cpath, err := strings.clone_to_cstring(op.open.path, op.l.allocator) + if err != nil { + op.open.err = .Allocation_Failed + queue.push_back(&op.l.completed, op) + return + } + op.open._impl.cpath = cpath + + enqueue(op, uring.openat( + &op.l.ring, + u64(uintptr(op)), + linux.Fd(op.open.dir), + op.open._impl.cpath, + transmute(linux.Mode)op.open.perm, + sys_flags, + )) +} + +open_callback :: proc(op: ^Operation, res: i32) { + assert(op.type == .Open) + + delete(op.open._impl.cpath, op.l.allocator) + + if res < 0 { + errno := linux.Errno(-res) + op.open.err = FS_Error(errno) + return + } + + op.open.handle = Handle(res) +} + +stat_exec :: proc(op: ^Operation) { + assert(op.type == .Stat) + + enqueue(op, uring.statx( + &op.l.ring, + u64(uintptr(op)), + op.stat.handle, + "", + {.EMPTY_PATH}, + {.TYPE, .SIZE}, + &op.stat._impl.buf, + )) +} + +stat_callback :: proc(op: ^Operation, res: i32) { + assert(op.type == .Stat) + + if res < 0 { + errno := linux.Errno(-res) + op.stat.err = FS_Error(errno) + return + } + + type := File_Type.Regular + switch op.stat._impl.buf.mode & linux.S_IFMT { + case linux.S_IFBLK, linux.S_IFCHR: type = .Device + case linux.S_IFDIR: type = .Directory + case linux.S_IFIFO: type = .Pipe_Or_Socket + case linux.S_IFLNK: type = .Symlink + case linux.S_IFREG: type = .Regular + case linux.S_IFSOCK: type = .Pipe_Or_Socket + } + + op.stat.type = type + op.stat.size = i64(op.stat._impl.buf.size) +} + +@(require_results) +sockaddr_storage_to_endpoint :: proc(addr: ^linux.Sock_Addr_Any) -> (ep: Endpoint) { + #partial switch addr.family { + case .INET: + return Endpoint { + address = IP4_Address(addr.sin_addr), + port = int(addr.sin_port), + } + case .INET6: + return Endpoint { + address = IP6_Address(transmute([8]u16be)addr.sin6_addr), + port = int(addr.sin6_port), + } + case: + return {} + } +} + +@(require_results) +endpoint_to_sockaddr :: proc(ep: Endpoint) -> (sockaddr: linux.Sock_Addr_Any) { + switch a in ep.address { + case IP4_Address: + sockaddr.sin_family = .INET + sockaddr.sin_port = u16be(ep.port) + sockaddr.sin_addr = cast([4]u8)a + return + case IP6_Address: + sockaddr.sin6_family = .INET6 + sockaddr.sin6_port = u16be(ep.port) + sockaddr.sin6_addr = transmute([16]u8)a + return + } + + unreachable() +} + +@(require_results) +ns_to_time_spec :: proc(nsec: i64) -> linux.Time_Spec { + NANOSECONDS_PER_SECOND :: 1e9 + return { + time_sec = uint(nsec / NANOSECONDS_PER_SECOND), + time_nsec = uint(nsec % NANOSECONDS_PER_SECOND), + } +} diff --git a/core/nbio/impl_others.odin b/core/nbio/impl_others.odin new file mode 100644 index 000000000..0a4564454 --- /dev/null +++ b/core/nbio/impl_others.odin @@ -0,0 +1,218 @@ +#+build !darwin +#+build !freebsd +#+build !openbsd +#+build !netbsd +#+build !linux +#+build !windows +#+private +package nbio + +import "core:container/avl" +import "core:container/pool" +import "core:container/queue" +import "core:mem" +import "core:slice" +import "core:time" + +_FULLY_SUPPORTED :: false + +_Event_Loop :: struct { + completed: queue.Queue(^Operation), + timeouts: avl.Tree(^Operation), +} + +_Handle :: uintptr + +_CWD :: Handle(-100) + +MAX_RW :: mem.Gigabyte + +_Operation :: struct { + removed: bool, +} + +_Accept :: struct {} + +_Close :: struct {} + +_Dial :: struct {} + +_Recv :: struct { + small_bufs: [1][]byte, +} + +_Send :: struct { + small_bufs: [1][]byte, +} + +_Read :: struct {} + +_Write :: struct {} + +_Timeout :: struct { + expires: time.Time, +} + +_Poll :: struct {} + +_Send_File :: struct {} + +_Open :: struct {} + +_Stat :: struct {} + +_Splice :: struct {} + +_Remove :: struct {} + +_Link_Timeout :: struct {} + +_init :: proc(l: ^Event_Loop, allocator: mem.Allocator) -> (rerr: General_Error) { + l.completed.data.allocator = allocator + + avl.init_cmp(&l.timeouts, timeouts_cmp, allocator) + + return nil + + timeouts_cmp :: #force_inline proc(a, b: ^Operation) -> slice.Ordering { + switch { + case a.timeout._impl.expires._nsec < b.timeout._impl.expires._nsec: + return .Less + case a.timeout._impl.expires._nsec > b.timeout._impl.expires._nsec: + return .Greater + case uintptr(a) < uintptr(b): + return .Less + case uintptr(a) > uintptr(b): + return .Greater + case: + assert(a == b) + return .Equal + } + } +} + +_destroy :: proc(l: ^Event_Loop) { + queue.destroy(&l.completed) + avl.destroy(&l.timeouts, false) +} + +__tick :: proc(l: ^Event_Loop, timeout: time.Duration) -> General_Error { + l.now = time.now() + + for op in queue.pop_front_safe(&l.completed) { + if !op._impl.removed { + op.cb(op) + } + if !op.detached { + pool.put(&l.operation_pool, op) + } + } + + iter := avl.iterator(&l.timeouts, .Forward) + for node in avl.iterator_next(&iter) { + op := node.value + cexpires := time.diff(l.now, op.timeout._impl.expires) + + done := cexpires <= 0 + if done { + op.cb(op) + avl.remove_node(&l.timeouts, node) + if !op.detached { + pool.put(&l.operation_pool, op) + } + continue + } + + break + } + + return nil +} + +_create_socket :: proc(l: ^Event_Loop, family: Address_Family, protocol: Socket_Protocol) -> (socket: Any_Socket, err: Create_Socket_Error) { + return nil, .Network_Unreachable +} + +_listen :: proc(socket: TCP_Socket, backlog := 1000) -> Listen_Error { + return .Network_Unreachable +} + +_exec :: proc(op: ^Operation) { + switch op.type { + case .Timeout: + _, _, err := avl.find_or_insert(&op.l.timeouts, op) + if err != nil { + panic("nbio: allocation failure") + } + return + case .Accept: + op.accept.err = .Network_Unreachable + case .Close: + op.close.err = .Unsupported + case .Dial: + op.dial.err = Dial_Error.Network_Unreachable + case .Recv: + switch _ in op.recv.socket { + case TCP_Socket: op.recv.err = TCP_Recv_Error.Network_Unreachable + case UDP_Socket: op.recv.err = UDP_Recv_Error.Network_Unreachable + case: op.recv.err = TCP_Recv_Error.Network_Unreachable + } + case .Send: + switch _ in op.send.socket { + case TCP_Socket: op.send.err = TCP_Send_Error.Network_Unreachable + case UDP_Socket: op.send.err = UDP_Send_Error.Network_Unreachable + case: op.send.err = TCP_Send_Error.Network_Unreachable + } + case .Send_File: + op.sendfile.err = .Network_Unreachable + case .Read: + op.read.err = .Unsupported + case .Write: + op.write.err = .Unsupported + case .Poll: + op.poll.result = .Error + case .Open: + op.open.err = .Unsupported + case .Stat: + op.stat.err = .Unsupported + case .None, ._Link_Timeout, ._Remove, ._Splice: + fallthrough + case: + unreachable() + } + + _, err := queue.push_back(&op.l.completed, op) + if err != nil { + panic("nbio: allocation failure") + } +} + +_remove :: proc(target: ^Operation) { + #partial switch target.type { + case .Timeout: + avl.remove_value(&target.l.timeouts, target) + if !target.detached { + pool.put(&target.l.operation_pool, target) + } + case: + target._impl.removed = true + } +} + +_open_sync :: proc(l: ^Event_Loop, path: string, dir: Handle, mode: File_Flags, perm: Permissions) -> (handle: Handle, err: FS_Error) { + return 0, FS_Error.Unsupported +} + +_associate_handle :: proc(handle: uintptr, l: ^Event_Loop) -> (Handle, Association_Error) { + return Handle(handle), nil +} + +_associate_socket :: proc(socket: Any_Socket, l: ^Event_Loop) -> Association_Error { + return nil +} + +_wake_up :: proc(l: ^Event_Loop) { +} + +_yield :: proc() { +} diff --git a/core/nbio/impl_posix.odin b/core/nbio/impl_posix.odin new file mode 100644 index 000000000..9b4863710 --- /dev/null +++ b/core/nbio/impl_posix.odin @@ -0,0 +1,1407 @@ +#+build darwin, freebsd, openbsd, netbsd +#+private file +package nbio + +import "core:c" +import "core:container/pool" +import "core:container/queue" +import "core:mem" +import "core:net" +import "core:slice" +import "core:strings" +import "core:sys/posix" +import "core:time" +import kq "core:sys/kqueue" +import sa "core:container/small_array" + +@(private="package") +_FULLY_SUPPORTED :: true + +@(private="package") +_Event_Loop :: struct { + // kqueue does not permit multiple {ident, filter} pairs in the kqueue. + // We have to keep record of what we currently have in the kqueue, and if we get an operation + // that would be the same (ident, filter) pair we need to bundle the operations under one kevent. + submitted: map[Queue_Identifier]^Operation, + // Holds all events we want to flush. Flushing is done each tick at which point this is emptied. + pending: sa.Small_Array(QUEUE_SIZE, kq.KEvent), + // Holds what should be in `pending` but didn't fit. + // When `pending`is flushed these are moved to `pending`. + overflow: queue.Queue(kq.KEvent), + // Contains all operations that were immediately completed in `exec`. + // These ops did not block so can call back next tick. + completed: queue.Queue(^Operation), + kqueue: kq.KQ, +} + +@(private="package") +_Handle :: posix.FD + +@(private="package") +_CWD :: posix.AT_FDCWD + +@(private="package") +MAX_RW :: mem.Gigabyte + +@(private="package") +_Operation :: struct { + // Linked list of operations that are bundled (same {ident, filter} pair) with this one. + next: ^Operation, + prev: ^Operation, + + flags: Operation_Flags, + result: i64, +} + +@(private="package") +_Accept :: struct {} + +@(private="package") +_Close :: struct {} + +@(private="package") +_Dial :: struct {} + +@(private="package") +_Recv :: struct { + small_bufs: [1][]byte, +} + +@(private="package") +_Send :: struct { + small_bufs: [1][]byte, +} + +@(private="package") +_Read :: struct {} + +@(private="package") +_Write :: struct {} + +@(private="package") +_Timeout :: struct {} + +@(private="package") +_Poll :: struct {} + +@(private="package") +_Send_File :: struct { + mapping: []byte, // `mmap`'d buffer (if native `sendfile` is not supported). +} + +@(private="package") +_Open :: struct {} + +@(private="package") +_Stat :: struct {} + +@(private="package") +_Splice :: struct {} + +@(private="package") +_Remove :: struct {} + +@(private="package") +_Link_Timeout :: struct {} + +@(private="package") +_init :: proc(l: ^Event_Loop, allocator: mem.Allocator) -> (rerr: General_Error) { + l.submitted.allocator = allocator + l.overflow.data.allocator = allocator + l.completed.data.allocator = allocator + + kqueue, err := kq.kqueue() + if err != nil { + return General_Error(posix.errno()) + } + + l.kqueue = kqueue + + sa.append(&l.pending, kq.KEvent{ + ident = IDENT_WAKE_UP, + filter = .User, + flags = {.Add, .Enable, .Clear}, + }) + + return nil +} + +@(private="package") +_destroy :: proc(l: ^Event_Loop) { + delete(l.submitted) + queue.destroy(&l.overflow) + queue.destroy(&l.completed) + posix.close(l.kqueue) +} + +@(private="package") +__tick :: proc(l: ^Event_Loop, timeout: time.Duration) -> General_Error { + debug("tick") + + if n := queue.len(l.completed); n > 0 { + l.now = time.now() + debug("processing", n, "already completed") + + for _ in 0 ..< n { + op := queue.pop_front(&l.completed) + handle_completed(op) + } + + if pool.num_outstanding(&l.operation_pool) == 0 { return nil } + } + + if NBIO_DEBUG { + npending := sa.len(l.pending) + if npending > 0 { + debug("queueing", npending, "new events, there are", int(len(l.submitted)), "events pending") + } else { + debug("there are", int(len(l.submitted)), "events pending") + } + } + + ts_backing: posix.timespec + ts_pointer: ^posix.timespec // nil means forever. + if queue.len(l.completed) == 0 && len(l.submitted) > 0 { + if timeout >= 0 { + debug("timeout", timeout) + ts_backing = {tv_sec=posix.time_t(timeout/time.Second), tv_nsec=c.long(timeout%time.Second)} + ts_pointer = &ts_backing + } else { + debug("timeout forever") + } + } else { + debug("timeout 0, there is completed work pending") + ts_pointer = &ts_backing + } + + for { + results_buf: [128]kq.KEvent + results := kevent(l, results_buf[:], ts_pointer) or_return + + sa.clear(&l.pending) + for overflow in queue.pop_front_safe(&l.overflow) { + sa.append(&l.pending, overflow) or_break + } + + l.now = time.now() + + handle_results(l, results) + + if len(results) < len(results_buf) { + break + } + + debug("more events ready than our results buffer handles, getting more") + + // No timeout for the next call. + ts_backing = {} + ts_pointer = &ts_backing + } + + + return nil + + kevent :: proc(l: ^Event_Loop, buf: []kq.KEvent, ts: ^posix.timespec) -> ([]kq.KEvent, General_Error) { + for { + new_events, err := kq.kevent(l.kqueue, sa.slice(&l.pending), buf, ts) + #partial switch err { + case nil: + assert(new_events >= 0) + return buf[:new_events], nil + case .EINTR: + warn("kevent interrupted") + case: + warn("kevent error") + warn(string(posix.strerror(err))) + return nil, General_Error(err) + } + } + } + + is_internal_timeout :: proc(filter: kq.Filter, op: ^Operation) -> bool { + // A `.Timeout` that `.Has_Timeout` is a `remove()`'d timeout. + return filter == .Timer && (op.type != .Timeout || .Has_Timeout in op._impl.flags) + } + + handle_results :: proc(l: ^Event_Loop, results: []kq.KEvent) { + if len(results) > 0 { + debug(len(results), "events completed") + } + + // Mark all operations that have an event returned as not `.For_Kernel`. + // We have to do this right away, or we may process an operation as if we think the kernel is responsible. + for &event in results { + if ODIN_OS != .Darwin { + // On the BSDs, a `.Delete` that results in an `.Error` does not keep the `.Delete` flag in the result. + // We only have `udata == nil` when we do a delete, so we can add it back here to keep consistent. + if .Error in event.flags && event.udata == nil { + event.flags += {.Delete} + } + } + + if .Delete in event.flags { + continue + } + + if event.filter == .User && event.ident == IDENT_WAKE_UP { + continue + } + + op := cast(^Operation)event.udata + assert(op != nil) + assert(op.type != .None) + + if is_internal_timeout(event.filter, op) { + continue + } + + _, del := delete_key(&l.submitted, Queue_Identifier{ ident = event.ident, filter = event.filter }) + assert(del != nil) + + for next := op; next != nil; next = next._impl.next { + assert(.For_Kernel in next._impl.flags) + next._impl.flags -= {.For_Kernel} + } + } + + // If we get a timeout and an actual result, ignore the timeout. + // We have to do this after the previous loop so we know if the target op of a timeout was also completed. + // We have to do this before the next loop so we handle timeouts before their target ops. Otherwise the target could already be done. + for &event in results { + if .Delete in event.flags { + continue + } + + if event.filter == .User && event.ident == IDENT_WAKE_UP { + continue + } + + op := cast(^Operation)event.udata + if is_internal_timeout(event.filter, op) { + // If the actual event has also been returned this tick, we need to ignore the timeout to not get a uaf. + if .For_Kernel not_in op._impl.flags { + assert(.Has_Timeout in op._impl.flags) + op._impl.flags -= {.Has_Timeout} + + event.filter = kq.Filter(FILTER_IGNORE) + debug(op.type, "timed out but was also completed this tick, ignoring timeout") + } + + } + } + + for event in results { + if event.filter == kq.Filter(FILTER_IGNORE) { + // Previous loop told us to ignore. + continue + } + + if event.filter == .User && event.ident == IDENT_WAKE_UP { + debug("woken up") + continue + } + + if .Delete in event.flags { + assert(.Error in event.flags) + // Seems to happen when you delete at the same time or just after a close. + debug("delete error", int(event.data)) + if err := posix.Errno(event.data); err != .ENOENT && err != .EBADF { + warn("unexpected delete error") + warn(string(posix.strerror(err))) + } + continue + } + + op := cast(^Operation)event.udata + assert(op != nil) + assert(op.type != .None) + + // Timeout result that is a non-timeout op, meaning the operation timed out. + // Because of the previous loop we are sure that the target op is not also in this tick's results. + if is_internal_timeout(event.filter, op) { + debug("got timeout for", op.type) + + assert(.Error not_in event.flags) + + assert(.Has_Timeout in op._impl.flags) + op._impl.flags -= {.Has_Timeout} + + // Remove the actual operation. + timeout_and_delete(op) + handle_completed(op) + continue + } + + // Weird loop, but we need to get the next ptr before handle_completed(curr), curr is freed in handle_completed. + for curr, next := op, op._impl.next; curr != nil; curr, next = next, next == nil ? nil : next._impl.next { + if .Error in event.flags { curr._impl.flags += {.Error} } + if .EOF in event.flags { curr._impl.flags += {.EOF} } + curr._impl.result = event.data + handle_completed(curr) + } + } + } +} + +@(private="package") +_create_socket :: proc(l: ^Event_Loop, family: Address_Family, protocol: Socket_Protocol) -> (socket: Any_Socket, err: Create_Socket_Error) { + socket = net.create_socket(family, protocol) or_return + + berr := net.set_blocking(socket, false) + // This shouldn't be able to fail. + assert(berr == nil) + + return +} + +@(private="package") +_listen :: proc(socket: TCP_Socket, backlog := 1000) -> Listen_Error { + if res := posix.listen(posix.FD(socket), i32(backlog)); res != .OK { + return posix_listen_error() + } + return nil +} + +@(private="package") +_exec :: proc(op: ^Operation) { + assert(op.l == &_tls_event_loop) + + debug("exec", op.type) + + result: Op_Result + switch op.type { + case .Accept: + result = accept_exec(op) + case .Close: + // no-op + case .Timeout: + result = timeout_exec(op) + case .Dial: + result = dial_exec(op) + case .Recv: + result = recv_exec(op) + case .Send: + result = send_exec(op) + case .Send_File: + result = sendfile_exec(op) + case .Read: + result = read_exec(op) + case .Write: + result = write_exec(op) + case .Poll: + result = poll_exec(op) + assert(result == .Pending) + case .Open: + open_exec(op) + case .Stat: + stat_exec(op) + case .None, ._Link_Timeout, ._Remove, ._Splice: + fallthrough + case: + unreachable() + } + + switch result { + case .Pending: + // no-op, in kernel. + debug(op.type, "pending") + case .Done: + debug(op.type, "done immediately") + op._impl.flags += {.Done} + _, err := queue.push_back(&op.l.completed, op) // Got result, handle it next tick. + ensure(err == nil, "allocation failure") + } +} + +@(private="package") +_remove :: proc(target: ^Operation) { + assert(target != nil) + + debug("remove", target.type) + + if .Removed in target._impl.flags { + debug("already removed") + return + } + + target._impl.flags += {.Removed, .Has_Timeout} + link_timeout(target, target.l.now) +} + +@(private="package") +_open_sync :: proc(l: ^Event_Loop, path: string, dir: Handle, mode: File_Flags, perm: Permissions) -> (handle: Handle, err: FS_Error) { + if path == "" { + err = .Invalid_Argument + return + } + + cpath, cerr := strings.clone_to_cstring(path, l.allocator) + if cerr != nil { + err = .Allocation_Failed + return + } + defer delete(cpath, l.allocator) + + sys_flags := posix.O_Flags{.NOCTTY, .CLOEXEC, .NONBLOCK} + + if .Write in mode { + if .Read in mode { + sys_flags += {.RDWR} + } else { + sys_flags += {.WRONLY} + } + } + + if .Append in mode { sys_flags += {.APPEND} } + if .Create in mode { sys_flags += {.CREAT} } + if .Excl in mode { sys_flags += {.EXCL} } + if .Sync in mode { sys_flags += {.DSYNC} } + if .Trunc in mode { sys_flags += {.TRUNC} } + + handle = posix.openat(dir, cpath, sys_flags, transmute(posix.mode_t)posix._mode_t(transmute(u32)perm)) + if handle < 0 { + err = FS_Error(posix.errno()) + } + + return +} + +@(private="package") +_associate_handle :: proc(handle: uintptr, l: ^Event_Loop) -> (Handle, Association_Error) { + flags_ := posix.fcntl(posix.FD(handle), .GETFL) + if flags_ < 0 { + #partial switch errno := posix.errno(); errno { + case .EBADF: return -1, .Invalid_Handle + case: return -1, Association_Error(errno) + } + } + flags := transmute(posix.O_Flags)(flags_) + + if .NONBLOCK in flags { + return Handle(handle), nil + } + + if posix.fcntl(posix.FD(handle), .SETFL, flags) < 0 { + #partial switch errno := posix.errno(); errno { + case .EBADF: return -1, .Invalid_Handle + case: return -1, Association_Error(errno) + } + } + + return Handle(handle), nil +} + +@(private="package") +_associate_socket :: proc(socket: Any_Socket, l: ^Event_Loop) -> Association_Error { + if err := net.set_blocking(socket, false); err != nil { + switch err { + case .None: unreachable() + case .Network_Unreachable: return .Network_Unreachable + case .Invalid_Argument: return .Invalid_Handle + case .Unknown: fallthrough + case: return Association_Error(net.last_platform_error()) + } + } + + return nil +} + +@(private="package") +_wake_up :: proc(l: ^Event_Loop) { + // TODO: only if we are sleeping (like Windows). + ev := [1]kq.KEvent{ + { + ident = IDENT_WAKE_UP, + filter = .User, + flags = {}, + fflags = { + user = {.Trigger}, + }, + }, + } + t: posix.timespec + n, err := kq.kevent(l.kqueue, ev[:], nil, &t) + assert(err == nil) + assert(n == 0) +} + +@(private="package") +_yield :: proc() { + posix.sched_yield() +} + +// Start file private. + +// Max operations that can be enqueued per tick. +QUEUE_SIZE :: #config(ODIN_NBIO_QUEUE_SIZE, 256) + +FILTER_IGNORE :: kq.Filter(max(kq._Filter_Backing)) + +IDENT_WAKE_UP :: 69 + +Op_Result :: enum { + Done, + Pending, +} + +Operation_Flag :: enum { + Done, + Removed, + Has_Timeout, + For_Kernel, + EOF, + Error, +} +Operation_Flags :: bit_set[Operation_Flag] + +// Operations in the kqueue are uniquely identified using these 2 fields. You may not have more +// than one operation with the same identity submitted. +// So we need to keep track of the operations we have submitted, and if we add another, link it to a previously +// added operation. +Queue_Identifier :: struct { + filter: kq.Filter, + ident: uintptr, +} + +handle_completed :: proc(op: ^Operation) { + debug("handling", op.type) + + result: Op_Result + #partial switch op.type { + case .Accept: + result = accept_exec(op) + case .Dial: + result = dial_exec(op) + case .Send: + if send_exec(op) == .Done { + maybe_callback(op) + bufs_destroy(op.send.bufs, op.l.allocator) + cleanup(op) + } + return + case .Recv: + if recv_exec(op) == .Done { + maybe_callback(op) + bufs_destroy(op.recv.bufs, op.l.allocator) + cleanup(op) + } + return + case .Send_File: + result = sendfile_exec(op) + case .Read: + result = read_exec(op) + case .Write: + result = write_exec(op) + case .Poll: + result = poll_exec(op) + case .Open: + open_exec(op) + case .Close: + close_exec(op) + case .Timeout, .Stat: + // no-op + case: + unimplemented() + } + + if result == .Done { + maybe_callback(op) + cleanup(op) + } + + maybe_callback :: proc(op: ^Operation) { + if .Removed not_in op._impl.flags { + debug("done", op.type, "calling back") + op.cb(op) + } else { + debug("done but removed", op.type) + } + } + + bufs_destroy :: proc(bufs: [][]byte, allocator: mem.Allocator) { + if len(bufs) > 1 { + delete(bufs, allocator) + } + } + + cleanup :: proc(op: ^Operation) { + if .Has_Timeout in op._impl.flags { + remove_link_timeout(op) + } + if !op.detached { + pool.put(&op.l.operation_pool, op) + } + } +} + +@(require_results) +accept_exec :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Accept) + + defer if op.accept.err != nil && op.accept.client > 0 { + posix.close(posix.FD(op.accept.client)) + } + + if op.accept.err != nil || .Done in op._impl.flags { + return .Done + } + + op.accept.client, op.accept.client_endpoint, op.accept.err = net.accept_tcp(op.accept.socket) + if op.accept.err != nil { + if op.accept.err == .Would_Block { + op.accept.err = nil + add_pending(op, .Read, uintptr(op.accept.socket)) + link_timeout(op, op.accept.expires) + return .Pending + } + + return .Done + } + + if err := net.set_blocking(op.accept.client, false); err != nil { + op.accept.err = posix_accept_error() + } + + return .Done +} + +@(require_results) +dial_exec :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Dial) + + defer if op.dial.err != nil && op.dial.socket > 0 { + posix.close(posix.FD(op.dial.socket)) + } + + if op.dial.err != nil || .Done in op._impl.flags { + return .Done + } + + if op.dial.socket > 0 { + // We have already called connect, retrieve potential error number only. + err: posix.Errno + size := posix.socklen_t(size_of(err)) + posix.getsockopt(posix.FD(op.dial.socket), posix.SOL_SOCKET, .ERROR, &err, &size) + if err != nil { + posix.errno(err) + op.dial.err = posix_dial_error() + } + return .Done + } + + if op.dial.endpoint.port == 0 { + op.dial.err = .Port_Required + return .Done + } + + family := family_from_endpoint(op.dial.endpoint) + osocket, socket_err := _create_socket(op.l, family, .TCP) + if socket_err != nil { + op.dial.err = socket_err + return .Done + } + + op.dial.socket = osocket.(TCP_Socket) + + sockaddr := endpoint_to_sockaddr(op.dial.endpoint) + if posix.connect(posix.FD(op.dial.socket), (^posix.sockaddr)(&sockaddr), posix.socklen_t(sockaddr.ss_len)) != .OK { + if posix.errno() == .EINPROGRESS { + add_pending(op, .Write, uintptr(op.dial.socket)) + link_timeout(op, op.dial.expires) + return .Pending + } + + op.dial.err = posix_dial_error() + return .Done + } + + return .Done +} + +@(require_results) +poll_exec :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Poll) + + if .Error in op._impl.flags { + #partial switch posix.Errno(op._impl.result) { + case .EBADF: op.poll.result = .Invalid_Argument + case: op.poll.result = .Error + } + return .Done + } + + if op._impl.result != 0 { + op.poll.result = .Ready + return .Done + } + + if op.poll.result != .Ready { + return .Done + } + + filter: kq.Filter + switch op.poll.event { + case .Receive: filter = .Read + case .Send: filter = .Write + } + + add_pending(op, filter, uintptr(net.any_socket_to_socket(op.poll.socket))) + link_timeout(op, op.poll.expires) + return .Pending +} + +close_exec :: proc(op: ^Operation) { + assert(op.type == .Close) + + if op.close.err != nil || op.close.subject == nil { + return + } + + fd: posix.FD + switch subject in op.close.subject { + case TCP_Socket: fd = posix.FD(subject) + case UDP_Socket: fd = posix.FD(subject) + case Handle: fd = posix.FD(subject) + case: op.close.err = .Invalid_Argument; return + } + + if posix.close(fd) != .OK { + op.close.err = FS_Error(posix.errno()) + } +} + +@(require_results) +send_exec :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Send) + + if op.send.err != nil || .Done in op._impl.flags { + return .Done + } + + total: int + bufs := slice.advance_slices(op.send.bufs, op.send.sent) + bufs, total = constraint_bufs_to_max_rw(op.send.bufs) + + sock, n := sendv(op.send.socket, bufs, op.send.endpoint) + if n < 0 { + if posix.errno() == .EWOULDBLOCK { + if !op.send.all && op.send.sent > 0 { + return .Done + } + + add_pending(op, .Write, uintptr(sock)) + link_timeout(op, op.send.expires) + return .Pending + } + + switch _ in op.send.socket { + case TCP_Socket: op.send.err = posix_tcp_send_error() + case UDP_Socket: op.send.err = posix_udp_send_error() + } + return .Done + } + + op.send.sent += n + + if op.send.sent < total { + return send_exec(op) + } + + return .Done + + sendv :: proc(socket: Any_Socket, bufs: [][]byte, to: net.Endpoint) -> (posix.FD, int) { + assert(len(bufs) < int(max(i32))) + + msg: posix.msghdr + msg.msg_iov = cast([^]posix.iovec)raw_data(bufs) + msg.msg_iovlen = i32(len(bufs)) + + toaddr: posix.sockaddr_storage + fd: posix.FD + switch sock in socket { + case TCP_Socket: + fd = posix.FD(sock) + case UDP_Socket: + fd = posix.FD(sock) + toaddr = endpoint_to_sockaddr(to) + msg.msg_name = &toaddr + msg.msg_namelen = posix.socklen_t(toaddr.ss_len) + } + + return fd, posix.sendmsg(fd, &msg, {.NOSIGNAL}) + } +} + +@(require_results) +recv_exec :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Recv) + + if op.recv.err != nil || .Done in op._impl.flags { + return .Done + } + + total: int + bufs := slice.advance_slices(op.recv.bufs, op.recv.received) + bufs, total = constraint_bufs_to_max_rw(op.recv.bufs) + + _, is_tcp := op.recv.socket.(net.TCP_Socket) + + sock, n := recvv(op.recv.socket, bufs, &op.recv.source) + if n < 0 { + if posix.errno() == .EWOULDBLOCK { + if is_tcp && !op.recv.all && op.recv.received > 0 { + return .Done + } + + add_pending(op, .Read, uintptr(sock)) + link_timeout(op, op.recv.expires) + return .Pending + } + + if is_tcp { + op.recv.err = posix_tcp_recv_error() + } else { + op.recv.err = posix_udp_recv_error() + } + + return .Done + } + + assert(is_tcp || op.recv.received == 0) + op.recv.received += n + + if is_tcp && n != 0 && op.recv.received < total { + return recv_exec(op) + } + + return .Done + + recvv :: proc(socket: Any_Socket, bufs: [][]byte, from: ^Endpoint) -> (fd: posix.FD, n: int) { + assert(len(bufs) < int(max(i32))) + + msg: posix.msghdr + msg.msg_iov = cast([^]posix.iovec)raw_data(bufs) + msg.msg_iovlen = i32(len(bufs)) + + udp: bool + fromaddr: posix.sockaddr_storage + switch sock in socket { + case TCP_Socket: + fd = posix.FD(sock) + case UDP_Socket: + fd = posix.FD(sock) + udp = true + msg.msg_name = &fromaddr + msg.msg_namelen = posix.socklen_t(size_of(fromaddr)) + } + + n = posix.recvmsg(fd, &msg, {.NOSIGNAL}) + if n >= 0 && udp { + from^ = sockaddr_to_endpoint(&fromaddr) + } + + return + } +} + +@(require_results) +sendfile_exec :: proc(op: ^Operation) -> (result: Op_Result) { + assert(op.type == .Send_File) + + defer if result == .Done && op.sendfile._impl.mapping != nil { + posix.munmap(raw_data(op.sendfile._impl.mapping), len(op.sendfile._impl.mapping)) + } + + if op.sendfile.err != nil || .Done in op._impl.flags { + return .Done + } + + when ODIN_OS == .NetBSD || ODIN_OS == .OpenBSD { + // Doesn't have `sendfile`, emulate it with `mmap` + normal `send`. + return sendfile_exec_emulated(op) + } else { + return sendfile_exec_native(op) + + @(require_results) + sendfile_exec_native :: proc(op: ^Operation) -> Op_Result { + nbytes := op.sendfile.nbytes + assert(nbytes != 0) + if nbytes == SEND_ENTIRE_FILE { + nbytes = 0 // special value for entire file. + + // If we want progress updates we need nbytes to be the actual size, or the user + // won't be able to check `sent < nbytes` to know if it's the final callback. + if op.sendfile.progress_updates { + stat: posix.stat_t + if posix.fstat(op.sendfile.file, &stat) != .OK { + op.sendfile.err = FS_Error(posix.errno()) + return .Done + } + op.sendfile.nbytes = int(stat.st_size - posix.off_t(op.sendfile.offset)) + } + } else { + nbytes -= op.sendfile.sent + } + + n, ok := posix_sendfile(op.sendfile.file, op.sendfile.socket, op.sendfile.offset + op.sendfile.sent, nbytes) + + assert(n >= 0) + op.sendfile.sent += n + + if !ok { + op.sendfile.err = posix_tcp_send_error() + if op.sendfile.err == .Would_Block { + op.sendfile.err = nil + if op.sendfile.progress_updates { op.cb(op) } + add_pending(op, .Write, uintptr(op.sendfile.socket)) + link_timeout(op, op.sendfile.expires) + return .Pending + } + + return .Done + } + + assert(op.sendfile.nbytes == SEND_ENTIRE_FILE || op.sendfile.sent == op.sendfile.nbytes) + return .Done + } + } + + @(require_results) + sendfile_exec_emulated :: proc(op: ^Operation) -> Op_Result { + if op.sendfile.nbytes == SEND_ENTIRE_FILE { + stat: posix.stat_t + if posix.fstat(op.sendfile.file, &stat) != .OK { + op.sendfile.err = FS_Error(posix.errno()) + return .Done + } + op.sendfile.nbytes = int(stat.st_size - posix.off_t(op.sendfile.offset)) + } + + if op.sendfile._impl.mapping == nil { + addr := posix.mmap(nil, uint(op.sendfile.nbytes), {.READ}, {}, op.sendfile.file, posix.off_t(op.sendfile.offset)) + if addr == posix.MAP_FAILED { + op.sendfile.err = FS_Error(posix.errno()) + return .Done + } + op.sendfile._impl.mapping = ([^]byte)(addr)[:op.sendfile.nbytes] + } + + n := posix.send( + posix.FD(op.sendfile.socket), + raw_data(op.sendfile._impl.mapping)[op.sendfile.sent:], + uint(min(MAX_RW, op.sendfile.nbytes - op.sendfile.sent)), + {.NOSIGNAL}, + ) + if n < 0 { + op.sendfile.err = posix_tcp_send_error() + if op.sendfile.err == .Would_Block { + op.sendfile.err = nil + add_pending(op, .Write, uintptr(op.sendfile.socket)) + link_timeout(op, op.sendfile.expires) + return .Pending + } + + return .Done + } + + op.sendfile.sent += n + + if op.sendfile.sent < op.sendfile.nbytes { + if op.sendfile.progress_updates { op.cb(op) } + return sendfile_exec_emulated(op) + } + + return .Done + } +} + +@(require_results) +read_exec :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Read) + + if op.read.err != nil || .Done in op._impl.flags { + return .Done + } + + to_read := op.read.buf[op.read.read:] + to_read = to_read[:min(MAX_RW, len(to_read))] + + res := posix.pread(op.read.handle, raw_data(to_read), len(to_read), posix.off_t(op.read.offset) + posix.off_t(op.read.read)) + if res < 0 { + errno := posix.errno() + if errno == .EWOULDBLOCK { + if !op.read.all && op.read.read > 0 { + return .Done + } + + add_pending(op, .Read, uintptr(op.read.handle)) + link_timeout(op, op.read.expires) + return .Pending + } + + op.read.err = FS_Error(errno) + return .Done + } else if res == 0 { + if op.read.read == 0 { + op.read.err = .EOF + } + return .Done + } + + op.read.read += res + + if op.read.read < len(op.read.buf) { + return read_exec(op) + } + + return .Done +} + +@(require_results) +write_exec :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Write) + + if op.write.err != nil || .Done in op._impl.flags { + return .Done + } + + to_write := op.write.buf[op.write.written:] + to_write = to_write[:min(MAX_RW, len(to_write))] + + res := posix.pwrite(op.write.handle, raw_data(to_write), len(to_write), posix.off_t(op.write.offset) + posix.off_t(op.write.written)) + if res < 0 { + errno := posix.errno() + if errno == .EWOULDBLOCK { + if !op.write.all && op.write.written > 0 { + return .Done + } + + add_pending(op, .Write, uintptr(op.write.handle)) + link_timeout(op, op.write.expires) + return .Pending + } + + op.write.err = FS_Error(errno) + return .Done + } + + op.write.written += res + + if op.write.written < len(op.write.buf) { + return write_exec(op) + } + + return .Done +} + +timeout_exec :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Timeout) + + if op.timeout.duration <= 0 { + return .Done + } + + op.l.submitted[Queue_Identifier{ ident = uintptr(op), filter = .Timer }] = op + + op._impl.flags += {.For_Kernel} + + append_pending(op.l, kq.KEvent { + ident = uintptr(op), + filter = .Timer, + flags = {.Add, .Enable, .One_Shot}, + fflags = { + timer = kq.TIMER_FLAGS_NSECONDS + {.Absolute}, + }, + data = op.l.now._nsec + i64(op.timeout.duration), + udata = op, + }) + return .Pending +} + +open_exec :: proc(op: ^Operation) { + assert(op.type == .Open) + + if op.open.err != nil && op.open.handle > 0 { + posix.close(op.open.handle) + return + } + + if .Done in op._impl.flags { + return + } + + op.open.handle, op.open.err = _open_sync(op.l, op.open.path, op.open.dir, op.open.mode, op.open.perm) +} + +stat_exec :: proc(op: ^Operation) { + assert(op.type == .Stat) + + stat: posix.stat_t + if posix.fstat(op.stat.handle, &stat) != .OK { + op.stat.err = FS_Error(posix.errno()) + return + } + + op.stat.type = .Undetermined + switch { + case posix.S_ISBLK(stat.st_mode) || posix.S_ISCHR(stat.st_mode): + op.stat.type = .Device + case posix.S_ISDIR(stat.st_mode): + op.stat.type = .Directory + case posix.S_ISFIFO(stat.st_mode) || posix.S_ISSOCK(stat.st_mode): + op.stat.type = .Pipe_Or_Socket + case posix.S_ISLNK(stat.st_mode): + op.stat.type = .Symlink + case posix.S_ISREG(stat.st_mode): + op.stat.type = .Regular + } + + op.stat.size = i64(stat.st_size) +} + +add_pending :: proc(op: ^Operation, filter: kq.Filter, ident: uintptr) { + debug("adding pending", op.type) + op._impl.flags += {.For_Kernel} + + _, val, just_inserted, err := map_entry(&op.l.submitted, Queue_Identifier{ ident = ident, filter = filter }) + ensure(err == nil, "allocation failure") + if just_inserted { + val^ = op + + append_pending(op.l, kq.KEvent { + filter = filter, + ident = ident, + flags = {.Add, .Enable, .One_Shot}, + udata = op, + }) + } else { + debug("already have this operation on the kqueue, bundling it") + + last := val^ + for last._impl.next != nil { + last = last._impl.next + } + last._impl.next = op + op._impl.prev = last + } +} + +append_pending :: #force_inline proc(l: ^Event_Loop, ev: kq.KEvent) { + if !sa.append(&l.pending, ev) { + warn("queue is full, adding to overflow, should QUEUE_SIZE be increased?") + _, err := queue.append(&l.overflow, ev) + ensure(err == nil, "allocation failure") + } +} + +link_timeout :: proc(op: ^Operation, expires: time.Time) { + if expires == {} { + return + } + + debug(op.type, "times out at", expires) + + op._impl.flags += {.Has_Timeout} + + append_pending(op.l, kq.KEvent { + ident = uintptr(op), + filter = .Timer, + flags = {.Add, .Enable, .One_Shot}, + fflags = { + timer = kq.TIMER_FLAGS_NSECONDS + {.Absolute}, + }, + data = expires._nsec, + udata = op, + }) +} + +remove_link_timeout :: proc(op: ^Operation) { + debug("removing timeout of", op.type) + assert(.Has_Timeout in op._impl.flags) + + append_pending(op.l, kq.KEvent { + ident = uintptr(op), + filter = .Timer, + flags = {.Delete, .Disable, .One_Shot}, + }) +} + +timeout_and_delete :: proc(target: ^Operation) { + filter: kq.Filter + ident: uintptr + switch target.type { + case .Accept: + target.accept.err = .Timeout + filter = .Read + ident = uintptr(target.accept.socket) + case .Dial: + target.dial.err = Dial_Error.Timeout + filter = .Write + ident = uintptr(target.dial.socket) + case .Read: + target.read.err = .Timeout + filter = .Read + ident = uintptr(target.read.handle) + case .Write: + target.write.err = .Timeout + filter = .Write + ident = uintptr(target.write.handle) + case .Recv: + switch sock in target.recv.socket { + case TCP_Socket: + target.recv.err = TCP_Recv_Error.Timeout + ident = uintptr(sock) + case UDP_Socket: + target.recv.err = UDP_Recv_Error.Timeout + ident = uintptr(sock) + } + filter = .Read + case .Send: + switch sock in target.send.socket { + case TCP_Socket: + target.send.err = TCP_Send_Error.Timeout + ident = uintptr(sock) + case UDP_Socket: + target.send.err = UDP_Send_Error.Timeout + ident = uintptr(sock) + } + filter = .Write + case .Send_File: + target.send.err = TCP_Send_Error.Timeout + filter = .Write + ident = uintptr(target.sendfile.socket) + case .Poll: + target.poll.result = .Timeout + ident = uintptr(net.any_socket_to_socket(target.poll.socket)) + + switch target.poll.event { + case .Receive: filter = .Read + case .Send: filter = .Write + } + + case .Timeout: + ident = uintptr(target) + filter = .Timer + + case .Close: + target.close.err = .Timeout + return + + case .Open: + target.open.err = .Timeout + return + + case .Stat: + target.stat.err = .Timeout + return + + case .None, ._Link_Timeout, ._Remove, ._Splice: + return + } + + // If there are other ops linked to this kevent, don't remove it. + if target._impl.next != nil || target._impl.prev != nil { + debug("removing target by pulling it out of the linked list, other ops depend on the kevent") + assert(filter != .Timer) + + if target._impl.next != nil { + target._impl.next._impl.prev = target._impl.prev + } + + if target._impl.prev != nil { + target._impl.prev._impl.next = target._impl.next + } else { + debug("target was the head of the list, updating map to point at new head") + + _, vp, _, err := map_entry(&target.l.submitted, Queue_Identifier{ ident = ident, filter = filter }) + ensure(err == nil, "allocation failure") + assert(vp^ == target) + vp^ = target._impl.next + + ev := kq.KEvent{ + filter = filter, + ident = ident, + flags = {.Add, .Enable, .One_Shot}, + udata = target._impl.next, + } + if !sa.append(&target.l.pending, ev) { + warn("just removed the head operation of a list of multiple, and the queue is full, have to force this update through inefficiently") + // This has to happen the next time we submit or we could have udata pointing wrong. + // Very inefficient but probably never hit. + + // Makes kevent return a receipt for our addition, so we don't take any new events from it. + // This forces .Error to be added and data being 0 means it's added. + ev.flags += {.Receipt} + + timeout: posix.timespec + n, err := kq.kevent(target.l.kqueue, ([^]kq.KEvent)(&ev)[:1], ([^]kq.KEvent)(&ev)[:1], &timeout) + assert(n == 1) + assert(err == nil) + + // The receipt flag makes this occur on the event. + assert(.Error in ev.flags) + assert(ev.data == 0) + } + } + + } else if .For_Kernel in target._impl.flags { + debug("adding delete event") + + _, dval := delete_key(&target.l.submitted, Queue_Identifier{ ident = ident, filter = filter }) + assert(dval != nil) + + append_pending(target.l, kq.KEvent{ + ident = ident, + filter = filter, + flags = {.Delete, .Disable, .One_Shot}, + }) + } else { + debug("remove without delete event, because target is not in kernel") + } +} + +@(require_results) +endpoint_to_sockaddr :: proc(ep: Endpoint) -> (sockaddr: posix.sockaddr_storage) { + switch a in ep.address { + case IP4_Address: + (^posix.sockaddr_in)(&sockaddr)^ = posix.sockaddr_in { + sin_port = u16be(ep.port), + sin_addr = transmute(posix.in_addr)a, + sin_family = .INET, + sin_len = size_of(posix.sockaddr_in), + } + return + case IP6_Address: + (^posix.sockaddr_in6)(&sockaddr)^ = posix.sockaddr_in6 { + sin6_port = u16be(ep.port), + sin6_addr = transmute(posix.in6_addr)a, + sin6_family = .INET6, + sin6_len = size_of(posix.sockaddr_in6), + } + return + } + unreachable() +} + +@(require_results) +sockaddr_to_endpoint :: proc(native_addr: ^posix.sockaddr_storage) -> (ep: Endpoint) { + #partial switch native_addr.ss_family { + case .INET: + addr := cast(^posix.sockaddr_in)native_addr + port := int(addr.sin_port) + ep = Endpoint { + address = IP4_Address(transmute([4]byte)addr.sin_addr), + port = port, + } + case .INET6: + addr := cast(^posix.sockaddr_in6)native_addr + port := int(addr.sin6_port) + ep = Endpoint { + address = IP6_Address(transmute([8]u16be)addr.sin6_addr), + port = port, + } + case: + panic("native_addr is neither IP4 or IP6 address") + } + return +} diff --git a/core/nbio/impl_posix_darwin.odin b/core/nbio/impl_posix_darwin.odin new file mode 100644 index 000000000..7ec64c2df --- /dev/null +++ b/core/nbio/impl_posix_darwin.odin @@ -0,0 +1,29 @@ +#+private +package nbio + +import "core:net" +import "core:sys/posix" + +foreign import lib "system:System" + +posix_sendfile :: proc(fd: Handle, s: TCP_Socket, offset, nbytes: int) -> (sent: int, ok := true) { + foreign lib { + @(link_name="sendfile") + _posix_sendfile :: proc (fd, s: posix.FD, offset: posix.off_t, len: ^posix.off_t, hdtr: rawptr, flags: i32) -> posix.result --- + } + + len := posix.off_t(nbytes) + if _posix_sendfile(posix.FD(fd), posix.FD(s), posix.off_t(offset), &len, nil, 0) != .OK { + ok = false + } + sent = int(len) + return +} + +posix_listen_error :: net._listen_error +posix_accept_error :: net._accept_error +posix_dial_error :: net._dial_error +posix_tcp_send_error :: net._tcp_send_error +posix_udp_send_error :: net._udp_send_error +posix_tcp_recv_error :: net._tcp_recv_error +posix_udp_recv_error :: net._udp_recv_error diff --git a/core/nbio/impl_posix_freebsd.odin b/core/nbio/impl_posix_freebsd.odin new file mode 100644 index 000000000..50089510b --- /dev/null +++ b/core/nbio/impl_posix_freebsd.odin @@ -0,0 +1,52 @@ +#+private +package nbio + +import "core:net" +import "core:sys/posix" +import "core:sys/freebsd" + +foreign import lib "system:c" + +// TODO: rewrite freebsd implementation to use `sys/freebsd` instead of `sys/posix`. + +posix_sendfile :: proc(fd: Handle, s: TCP_Socket, offset, nbytes: int) -> (sent: int, ok := true) { + foreign lib { + @(link_name="sendfile") + _posix_sendfile :: proc (fd, s: posix.FD, offset: posix.off_t, nbytes: uint, hdtr: rawptr, sbytes: ^posix.off_t, flags: i32) -> posix.result --- + } + + len: posix.off_t + if _posix_sendfile(posix.FD(fd), posix.FD(s), posix.off_t(offset), uint(nbytes), nil, &len, 0) != .OK { + ok = false + } + sent = int(len) + return +} + +posix_listen_error :: proc() -> Listen_Error { + return net._listen_error(freebsd.Errno(posix.errno())) +} + +posix_accept_error :: proc() -> Accept_Error { + return net._accept_error(freebsd.Errno(posix.errno())) +} + +posix_dial_error :: proc() -> Dial_Error { + return net._dial_error(freebsd.Errno(posix.errno())) +} + +posix_tcp_send_error :: proc() -> TCP_Send_Error { + return net._tcp_send_error(freebsd.Errno(posix.errno())) +} + +posix_udp_send_error :: proc() -> UDP_Send_Error { + return net._udp_send_error(freebsd.Errno(posix.errno())) +} + +posix_tcp_recv_error :: proc() -> TCP_Recv_Error { + return net._tcp_recv_error(freebsd.Errno(posix.errno())) +} + +posix_udp_recv_error :: proc() -> UDP_Recv_Error { + return net._udp_recv_error(freebsd.Errno(posix.errno())) +} diff --git a/core/nbio/impl_posix_netbsd.odin b/core/nbio/impl_posix_netbsd.odin new file mode 100644 index 000000000..a0e2652f4 --- /dev/null +++ b/core/nbio/impl_posix_netbsd.odin @@ -0,0 +1,12 @@ +#+private +package nbio + +import "core:net" + +posix_listen_error :: net._listen_error +posix_accept_error :: net._accept_error +posix_dial_error :: net._dial_error +posix_tcp_send_error :: net._tcp_send_error +posix_udp_send_error :: net._udp_send_error +posix_tcp_recv_error :: net._tcp_recv_error +posix_udp_recv_error :: net._udp_recv_error diff --git a/core/nbio/impl_posix_openbsd.odin b/core/nbio/impl_posix_openbsd.odin new file mode 100644 index 000000000..a0e2652f4 --- /dev/null +++ b/core/nbio/impl_posix_openbsd.odin @@ -0,0 +1,12 @@ +#+private +package nbio + +import "core:net" + +posix_listen_error :: net._listen_error +posix_accept_error :: net._accept_error +posix_dial_error :: net._dial_error +posix_tcp_send_error :: net._tcp_send_error +posix_udp_send_error :: net._udp_send_error +posix_tcp_recv_error :: net._tcp_recv_error +posix_udp_recv_error :: net._udp_recv_error diff --git a/core/nbio/impl_windows.odin b/core/nbio/impl_windows.odin new file mode 100644 index 000000000..f75193fe4 --- /dev/null +++ b/core/nbio/impl_windows.odin @@ -0,0 +1,1856 @@ +#+private file +package nbio + +import "base:intrinsics" + +import "core:container/avl" +import "core:container/pool" +import "core:container/queue" +import "core:mem" +import "core:net" +import "core:path/filepath" +import "core:slice" +import "core:strings" +import "core:sync" +import "core:time" + +import win "core:sys/windows" + +@(private="package") +_FULLY_SUPPORTED :: true + +@(private="package") +_Event_Loop :: struct { + timeouts: avl.Tree(^Operation), + thread: win.HANDLE, + completed: queue.Queue(^Operation), + completed_oob: Multi_Producer_Single_Consumer, + state: enum { + Working, + Waking, + Sleeping, + }, +} + +@(private="package") +_Handle :: distinct uintptr + +@(private="package") +_CWD :: ~_Handle(99) + +@(private="package") +MAX_RW :: mem.Gigabyte + +@(private="package") +_Operation :: struct { + over: win.OVERLAPPED, + timeout: ^Operation, +} + +@(private="package") +_Accept :: struct { + // Space that gets the local and remote address written into it. + addrs: [(size_of(win.sockaddr_in6)+16)*2]byte, +} + +@(private="package") +_Close :: struct {} + +@(private="package") +_Dial :: struct { + addr: win.SOCKADDR_STORAGE_LH, +} + +@(private="package") +_Read :: struct {} + +@(private="package") +_Write :: struct {} + +@(private="package") +_Send :: struct { + small_bufs: [1][]byte, +} + +@(private="package") +_Recv :: struct { + source: win.SOCKADDR_STORAGE_LH, + source_len: win.INT, + small_bufs: [1][]byte, + flags: win.DWORD, +} + +@(private="package") +_Timeout :: struct { + expires: time.Time, + target: ^Operation, +} + +@(private="package") +_Poll :: struct { + wait_handle: win.HANDLE, +} + +@(private="package") +_Send_File :: struct {} + +@(private="package") +_Remove :: struct {} + +@(private="package") +_Link_Timeout :: struct {} + +@(private="package") +_Splice :: struct {} + +@(private="package") +_Open :: struct {} + +@(private="package") +_Stat :: struct {} + +@(private="package") +_init :: proc(l: ^Event_Loop, alloc: mem.Allocator) -> (err: General_Error) { + l.allocator = alloc + + l.completed.data.allocator = l.allocator + + avl.init(&l.timeouts, timeouts_cmp, alloc) + + mpsc_init(&l.completed_oob, QUEUE_SIZE, l.allocator) + defer if err != nil { mpsc_destroy(&l.completed_oob, l.allocator) } + + dup_ok := win.DuplicateHandle( + win.GetCurrentProcess(), win.GetCurrentThread(), + win.GetCurrentProcess(), &l.thread, + 0, false, win.DUPLICATE_SAME_ACCESS, + ) + ensure(dup_ok == true) + defer if err != nil { win.CloseHandle(l.thread) } + + err = g_ref() + return +} + +@(private="package") +_destroy :: proc(l: ^Event_Loop) { + avl.destroy(&l.timeouts) + queue.destroy(&l.completed) + mpsc_destroy(&l.completed_oob, l.allocator) + win.CloseHandle(l.thread) + g_unref() +} + +@(private="package") +__tick :: proc(l: ^Event_Loop, timeout: time.Duration) -> (err: General_Error) { + debug("tick") + + l.now = time.now() + next_timeout := check_timeouts(l) + + // Prevent infinite loop when callback adds to completed by storing length. + n := queue.len(l.completed) + if n > 0 { + for _ in 0 ..< n { + op := queue.pop_front(&l.completed) + handle_completed(op) + } + } + + for { + op := (^Operation)(mpsc_dequeue(&l.completed_oob)) + if op == nil { break } + handle_completed(op) + } + + if pool.num_outstanding(&l.operation_pool) == 0 { return nil } + + actual_timeout := win.INFINITE + if queue.len(l.completed) > 0 || mpsc_count(&l.completed_oob) > 0 { + actual_timeout = 0 + } else if timeout >= 0 { + actual_timeout = win.DWORD(timeout / time.Millisecond) + } + if nt, ok := next_timeout.?; ok { + actual_timeout = min(actual_timeout, win.DWORD(nt / time.Millisecond)) + } + + if actual_timeout > 0 { + sync.atomic_store_explicit(&l.state, .Sleeping, .Release) + + // There could be a race condition where we go sleeping at the same time as things get queued + // and a wakeup isn't done because the state is not .Sleeping yet. + // So after sleeping we first check our queues. + + for { + op := (^Operation)(mpsc_dequeue(&l.queue)) + if op == nil { break } + _exec(op) + } + + for { + op := (^Operation)(mpsc_dequeue(&l.completed_oob)) + if op == nil { break } + handle_completed(op) + } + } + + for { + events: [256]win.OVERLAPPED_ENTRY + entries_removed: win.ULONG + if !win.GetQueuedCompletionStatusEx(g.iocp, &events[0], len(events), &entries_removed, actual_timeout, true) { + winerr := win.GetLastError() + switch winerr { + case win.WAIT_TIMEOUT, win.WAIT_IO_COMPLETION: + entries_removed = 0 + case: + err = General_Error(winerr) + return + } + } + + sync.atomic_store_explicit(&l.state, .Working, .Relaxed) + + if actual_timeout > 0 { + // We may have just waited some time, lets update the current time. + l.now = time.now() + } + + if entries_removed > 0 { + debug(int(entries_removed), "operations were completed") + } + + for event in events[:entries_removed] { + assert(event.lpOverlapped != nil) + op := container_of(container_of(event.lpOverlapped, _Operation, "over"), Operation, "_impl") + + if op.l == l { + handle_completed(op) + } else { + op_l := op.l + for !mpsc_enqueue(&op.l.completed_oob, op) { + warn("oob queue filled up, QUEUE_SIZE may need increasing") + _wake_up(op_l) + win.SwitchToThread() + } + _wake_up(op_l) + } + } + + if entries_removed < len(events) { + break + } + + // `events` was filled up, get more. + debug("GetQueuedCompletionStatusEx filled entire events buffer, getting more") + actual_timeout = 0 + } + + return nil + + check_timeouts :: proc(l: ^Event_Loop) -> (expires: Maybe(time.Duration)) { + curr := l.now + + if avl.len(&l.timeouts) == 0 { + return + } + + debug(avl.len(&l.timeouts), "timeouts", "threshold", curr) + + iter := avl.iterator(&l.timeouts, .Forward) + for node in avl.iterator_next(&iter) { + op := node.value + cexpires := time.diff(curr, op.timeout._impl.expires) + + debug("expires after", cexpires) + + removed := op._impl.timeout == (^Operation)(REMOVED) + done := cexpires <= 0 + if removed { + debug("timeout removed!") + } else if done { + debug("timeout done!") + handle_completed(op) + } + if removed || done { + avl.remove_node(&l.timeouts, node) + continue + } + + break + } + + // Don't merge this with the previous iteration because the `handle_completed` in that one might queue + // more timeouts which we want to detect here. + // For example: `timeout(time.Second, proc(_: ^Operation) { timeout(time.Second, ...) })` + + first := avl.first(&l.timeouts) + if first != nil { + op := first.value + cexpires := time.diff(curr, op.timeout._impl.expires) + debug("first timeout in the future is at", op.timeout._impl.expires, "after", cexpires) + expires = cexpires + } + return + } + + handle_completed :: proc(op: ^Operation) { + debug("handling", op.type) + + if op._impl.timeout == (^Operation)(REMOVED) { + debug(op.type, "was removed") + + // Set an error, and call the internal callback. + // This way resources are cleaned up properly, for example the result socket for dial. + // If we just do nothing it will be leaked. + + if op._impl.over.Internal == nil { + // There is no error from the kernel, set one ourselves. + // This needs to be an NTSTATUS code, not a win32 error number. + STATUS_REQUEST_ABORTED :: 0xC023000C + op._impl.over.Internal = (^win.c_ulong)(uintptr(STATUS_REQUEST_ABORTED)) + } + } + + result := Op_Result.Done + switch op.type { + case .Read: + result = read_callback(op) + case .Recv: + result = recv_callback(op) + if result == .Done { + maybe_callback(op) + if len(op.recv.bufs) > 1 { + delete(op.recv.bufs, op.l.allocator) + } + cleanup(op) + return + } + case .Write: + result = write_callback(op) + case .Send: + result = send_callback(op) + if result == .Done { + maybe_callback(op) + if len(op.send.bufs) > 1 { + delete(op.send.bufs, op.l.allocator) + } + cleanup(op) + return + } + case .Send_File: + result = sendfile_callback(op) + case .Accept: + accept_callback(op) + case .Dial: + dial_callback(op) + case .Poll: + poll_callback(op) + case .Timeout, .Open, .Stat, .Close: + // no-op. + case .None, ._Link_Timeout, ._Remove, ._Splice: + fallthrough + case: + unreachable() + } + + if result == .Pending { + assert(op._impl.timeout != (^Operation)(REMOVED)) + debug(op.type, "pending") + return + } + + maybe_callback(op) + cleanup(op) + + maybe_callback :: proc(op: ^Operation) { + if op._impl.timeout == (^Operation)(REMOVED) { + debug(op.type, "done but removed") + } else { + debug(op.type, "done") + op.cb(op) + + if op._impl.timeout != nil { + debug("cancelling timeout of", op.type) + op._impl.timeout.timeout._impl.target = nil + _remove(op._impl.timeout) + } + } + } + + cleanup :: proc(op: ^Operation) { + if !op.detached { + pool.put(&op.l.operation_pool, op) + } + } + } + +} + +@(private="package") +_exec :: proc(op: ^Operation) { + assert(op.l == &_tls_event_loop) + + result: Op_Result + switch op.type { + case .Accept: result = accept_exec(op) + case .Close: close_exec(op); result = .Done + case .Dial: result = dial_exec(op) + case .Recv: result = recv_exec(op) + case .Send: result = send_exec(op) + case .Send_File: result = sendfile_exec(op) + case .Read: result = read_exec(op) + case .Write: result = write_exec(op) + case .Timeout: result = timeout_exec(op) + case .Poll: result = poll_exec(op) + case .Open: open_exec(op); result = .Done + case .Stat: stat_exec(op); result = .Done + case .None, ._Link_Timeout, ._Remove, ._Splice: + unreachable() + } + + switch result { + case .Pending: + // no-op, in kernel. + debug("exec", op.type, "pending") + case .Done: + debug("exec", op.type, "done immediately") + _, err := queue.append(&op.l.completed, op) // Got result, handle it next tick. + ensure(err == nil, "allocation failure") + } +} + +@(private="package") +_open_sync :: proc(l: ^Event_Loop, name: string, dir: Handle, mode: File_Flags, perm: Permissions) -> (handle: Handle, err: FS_Error) { + if len(name) == 0 { + err = .Invalid_Argument + return + } + + dir := dir + + is_abs := filepath.is_abs(name) + is_cwd: bool + cwd_path: win.wstring + if !is_abs && dir == CWD { + is_cwd = true + + cwd_len := win.GetCurrentDirectoryW(0, nil) + assert(cwd_len > 0) + cwd_buf, cwd_err := make([]u16, cwd_len, l.allocator) + if cwd_err != nil { return INVALID_HANDLE, .Allocation_Failed } + cwd_len = win.GetCurrentDirectoryW(cwd_len, raw_data(cwd_buf)) + assert(int(cwd_len) == len(cwd_buf)-1) + cwd_path = win.wstring(raw_data(cwd_buf)) + + dir = Handle(win.CreateFileW( + cwd_path, + win.GENERIC_READ, + win.FILE_SHARE_READ|win.FILE_SHARE_WRITE, + nil, + win.OPEN_EXISTING, + win.FILE_FLAG_BACKUP_SEMANTICS, + nil, + )) + if dir == INVALID_HANDLE { + err = FS_Error(win.GetLastError()) + return + } + } + defer if is_cwd { + delete(cwd_path, l.allocator) + win.CloseHandle(win.HANDLE(dir)) + } + + path, was_alloc := _normalize_path(name, l.allocator) + defer if was_alloc { delete(path, l.allocator) } + + wpath := win.utf8_to_utf16(path, l.allocator) + defer delete(wpath, l.allocator) + + if path == "" || wpath == nil { + return INVALID_HANDLE, .Allocation_Failed + } + + path_len := len(wpath) * 2 + if path_len > int(max(u16)) { + err = .Invalid_Argument + return + } + + access: u32 + switch mode & {.Read, .Write} { + case {.Read}: access = win.FILE_GENERIC_READ + case {.Write}: access = win.FILE_GENERIC_WRITE + case {.Read, .Write}: access = win.FILE_GENERIC_READ | win.FILE_GENERIC_WRITE + } + + if .Create in mode { + access |= win.FILE_GENERIC_WRITE + } + if .Append in mode { + access &~= win.FILE_GENERIC_WRITE + access |= win.FILE_APPEND_DATA + } + share_mode := u32(win.FILE_SHARE_READ | win.FILE_SHARE_WRITE) + + create_mode: u32 = win.FILE_OPEN + switch { + case mode & {.Create, .Excl} == {.Create, .Excl}: + create_mode = win.FILE_CREATE + case mode & {.Create, .Trunc} == {.Create, .Trunc}: + create_mode = win.FILE_OVERWRITE_IF + case mode & {.Create} == {.Create}: + create_mode = win.FILE_OPEN_IF + case mode & {.Trunc} == {.Trunc}: + create_mode = win.FILE_OVERWRITE + } + + attrs: u32 = win.FILE_ATTRIBUTE_NORMAL + + if .Write_User not_in perm { + attrs = win.FILE_ATTRIBUTE_READONLY + if create_mode == win.FILE_OVERWRITE_IF { + // NOTE(bill): Open has just asked to create a file in read-only mode. + // If the file already exists, to make it akin to a *nix open call, + // the call preserves the existing permissions. + + h: win.HANDLE + io_status: win.IO_STATUS_BLOCK + status := win.NtCreateFile( + &h, + access, + &{ + Length = size_of(win.OBJECT_ATTRIBUTES), + RootDirectory = is_abs ? nil : win.HANDLE(dir), + ObjectName = &{ + Length = u16(path_len), + MaximumLength = u16(path_len), + Buffer = raw_data(wpath), + }, + }, + &io_status, + nil, + win.FILE_ATTRIBUTE_NORMAL, + share_mode, + win.FILE_OVERWRITE, + 0, + nil, + 0, + ) + syserr := win.System_Error(win.RtlNtStatusToDosError(status)) + #partial switch syserr { + case .FILE_NOT_FOUND, .BAD_NETPATH, .PATH_NOT_FOUND: + // File does not exists, create the file + case .SUCCESS: + association_err: Association_Error + handle, association_err = _associate_handle(uintptr(h), l) + // This shouldn't fail, we just created this file, with correct flags. + assert(association_err != nil) + return + case: + err = FS_Error(syserr) + return + } + } + } + + h: win.HANDLE + io_status: win.IO_STATUS_BLOCK + status := win.NtCreateFile( + &h, + access, + &{ + Length = size_of(win.OBJECT_ATTRIBUTES), + RootDirectory = is_abs ? nil : win.HANDLE(dir), + ObjectName = &{ + Length = u16(path_len), + MaximumLength = u16(path_len), + Buffer = raw_data(wpath), + }, + }, + &io_status, + nil, + attrs, + share_mode, + create_mode, + 0, + nil, + 0, + ) + syserr := win.System_Error(win.RtlNtStatusToDosError(status)) + #partial switch syserr { + case .SUCCESS: + association_err: Association_Error + handle, association_err = _associate_handle(uintptr(h), l) + // This shouldn't fail, we just created this file, with correct flags. + assert(association_err == nil) + return + case: + err = FS_Error(syserr) + return + } + + @(require_results) + _normalize_path :: proc(path: string, allocator := context.allocator) -> (fixed: string, allocated: bool) { + // An UNC path or relative, just replace slashes. + if strings.has_prefix(path, `\\`) || !filepath.is_abs(path) { + return strings.replace_all(path, `/`, `\`) + } + + path_buf, err := make([]byte, len(PREFIX)+len(path)+1, allocator) + if err != nil { return } + defer if !allocated { delete(path_buf, allocator) } + + PREFIX :: `\??` + copy(path_buf, PREFIX) + n := len(path) + r, w := 0, len(PREFIX) + for r < n { + switch { + case filepath.is_separator(path[r]): + r += 1 + case path[r] == '.' && (r+1 == n || filepath.is_separator(path[r+1])): + // \.\ + r += 1 + case r+1 < n && path[r] == '.' && path[r+1] == '.' && (r+2 == n || filepath.is_separator(path[r+2])): + // Skip \..\ paths + return path, false + case: + path_buf[w] = '\\' + w += 1 + for r < n && !filepath.is_separator(path[r]) { + path_buf[w] = path[r] + r += 1 + w += 1 + } + } + } + + // Root directories require a trailing \ + if w == len(`\\?\c:`) { + path_buf[w] = '\\' + w += 1 + } + + allocated = true + fixed = string(path_buf[:w]) + return + } +} + +@(private="package") +_listen :: proc(socket: TCP_Socket, backlog := 1000) -> (err: Listen_Error) { + if res := win.listen(win.SOCKET(socket), i32(backlog)); res == win.SOCKET_ERROR { + err = net._listen_error() + } + return +} + +@(private="package") +_create_socket :: proc( + l: ^Event_Loop, + family: Address_Family, + protocol: Socket_Protocol, +) -> ( + socket: Any_Socket, + err: Create_Socket_Error, +) { + socket = net.create_socket(family, protocol) or_return + + association_err := _associate_socket(socket, l) + // Network unreachable would've happened on creation too. + // Not possible to associate or invalid handle can't happen because we controlled creation. + assert(association_err == nil) + + return +} + +@(private="package") +_remove :: proc(target: ^Operation) { + debug("remove", target.type) + + if target._impl.timeout == (^Operation)(REMOVED) { + return + } + + if target._impl.timeout != nil { + _remove(target._impl.timeout) + } + + target._impl.timeout = (^Operation)(REMOVED) + + switch target.type { + case .Poll: + win.UnregisterWaitEx(target.poll._impl.wait_handle, nil) + target.poll._impl.wait_handle = nil + + ok := win.PostQueuedCompletionStatus( + g.iocp, + 0, + 0, + &target._impl.over, + ) + ensure(ok == true, "unexpected PostQueuedCompletionStatus error") + return + + case .Timeout: + if avl.remove_value(&target.l.timeouts, target) { + debug("removed timeout directly") + if !target.detached { + pool.put(&target.l.operation_pool, target) + } + } else { + debug("timeout is in completed queue, will be picked up there") + } + return + + case .Close, .Open, .Stat: + // Synchronous ops, picked up in handler. + return + + case .Accept, .Dial, .Read, .Recv, .Send, .Write, .Send_File: + if is_pending(target._impl.over) { + handle := operation_handle(target) + assert(handle != win.INVALID_HANDLE) + ok := win.CancelIoEx(handle, &target._impl.over) + if !ok { + err := win.System_Error(win.GetLastError()) + #partial switch err { + case .NOT_FOUND: + debug("Remove: Cancel", target.type, "NOT_FOUND") + case .INVALID_HANDLE: + debug("Remove: Cancel", target.type, "INVALID_HANDLE") // Likely closed already. + case: + assert(false, "unexpected CancelIoEx error") + } + } + } + + case ._Remove: + panic("can't remove a removal") + + case .None, ._Splice, ._Link_Timeout: + fallthrough + case: + unreachable() + } +} + +@(private="package") +_associate_handle :: proc(handle: uintptr, l: ^Event_Loop) -> (Handle, Association_Error) { + handle_iocp := win.CreateIoCompletionPort(win.HANDLE(handle), g.iocp, 0, 0) + if handle_iocp != g.iocp { + return INVALID_HANDLE, .Not_Possible_To_Associate + } + + cmode: byte + cmode |= win.FILE_SKIP_COMPLETION_PORT_ON_SUCCESS + cmode |= win.FILE_SKIP_SET_EVENT_ON_HANDLE + ok := win.SetFileCompletionNotificationModes(win.HANDLE(handle), cmode) + + // This is an assertion because I don't believe this can happen when we just successfully + // called `CreateIoCompletionPort`. + assert(ok == true, "unexpected SetFileCompletionNotificationModes error") + + return Handle(handle), nil +} + +@(private="package") +_associate_socket :: proc(socket: Any_Socket, l: ^Event_Loop) -> Association_Error { + if err := net.set_blocking(socket, false); err != nil { + switch err { + case .None: unreachable() + case .Network_Unreachable: return .Network_Unreachable + case .Invalid_Argument: return .Invalid_Handle + case .Unknown: fallthrough + case: return Association_Error(net.last_platform_error()) + } + } + + _, err := _associate_handle(uintptr(net.any_socket_to_socket(socket)), l) + return err +} + +@(private="package") +_wake_up :: proc(l: ^Event_Loop) { + _, exchanged := sync.atomic_compare_exchange_strong(&l.state, .Sleeping, .Waking) + if exchanged { + win.QueueUserAPC(proc "system" (Parameter: win.ULONG_PTR) {}, l.thread, 0) + } +} + +@(private="package") +_yield :: proc() { + win.SwitchToThread() +} + +// Start file private. + +QUEUE_SIZE :: 128 + +REMOVED :: rawptr(max(uintptr)-1) + +INVALID_HANDLE :: Handle(win.INVALID_HANDLE) + +Op_Result :: enum { + Done, + Pending, +} + +/* +IOCP is designed to be used from multiple threads. +For best performance we need to adhere to that and have one single IOCP for the event loops to share. +*/ +g: struct{ + mu: sync.Mutex, + refs: int, + iocp: win.HANDLE, + err: General_Error, +} + +g_ref :: proc() -> General_Error { + sync.guard(&g.mu) + + if g.refs == 0 { + win.ensure_winsock_initialized() + + // NOTE: setting NumberOfConcurrentThreads to 0 which makes Windows use the amount of processors as a default. + // We may want to make this configurable somehow? + g.iocp = win.CreateIoCompletionPort(win.INVALID_HANDLE_VALUE, nil, 0, 0) + if g.iocp == nil { + g.err = General_Error(win.GetLastError()) + } + } + + sync.atomic_add(&g.refs, 1) + + return sync.atomic_load(&g.err) +} + +g_unref :: proc() { + sync.guard(&g.mu) + + if sync.atomic_sub(&g.refs, 1) == 1 { + win.CloseHandle(g.iocp) + g.err = nil + } +} + +operation_handle :: proc(op: ^Operation) -> win.HANDLE { + switch op.type { + case .Accept: return win.HANDLE(uintptr(op.accept.socket)) + case .Close: + switch fd in op.close.subject { + case TCP_Socket: return win.HANDLE(uintptr(fd)) + case UDP_Socket: return win.HANDLE(uintptr(fd)) + case Handle: return win.HANDLE(uintptr(fd)) + case: + unreachable() + } + case .Dial: return win.HANDLE(uintptr(op.dial.socket)) + case .Read: return win.HANDLE(op.read.handle) + case .Write: return win.HANDLE(op.write.handle) + case .Recv: return win.HANDLE(uintptr(net.any_socket_to_socket(op.recv.socket))) + case .Send: return win.HANDLE(uintptr(net.any_socket_to_socket(op.send.socket))) + case .Send_File: return win.HANDLE(uintptr(net.any_socket_to_socket(op.sendfile.socket))) + case .Poll: return win.HANDLE(uintptr(net.any_socket_to_socket(op.poll.socket))) + case .Stat: return win.HANDLE(uintptr(op.stat.handle)) + + case .Timeout, .Open, ._Splice, ._Link_Timeout, ._Remove, .None: + return win.INVALID_HANDLE + case: + unreachable() + } +} + +close_exec :: proc(op: ^Operation) { + assert(op.type == .Close) + + switch h in op.close.subject { + case Handle: + if !win.CloseHandle(win.HANDLE(h)) { + op.close.err = FS_Error(win.GetLastError()) + } + case TCP_Socket: + if win.closesocket(win.SOCKET(h)) != win.NO_ERROR { + op.close.err = FS_Error(win.WSAGetLastError()) + } + case UDP_Socket: + if win.closesocket(win.SOCKET(h)) != win.NO_ERROR { + op.close.err = FS_Error(win.WSAGetLastError()) + } + case: + op.close.err = .Invalid_Argument + return + } +} + +@(require_results) +accept_exec :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Accept) + assert(is_fresh(op._impl.over)) + + family := Address_Family.IP4 + { + ep, err := bound_endpoint(op.accept.socket) + if err != nil { + op.accept.err = net._accept_error() + return .Done + } + + if _, is_ip6 := ep.address.(IP6_Address); is_ip6 { + family = .IP6 + } + } + + client, err := _create_socket(op.l, family, .TCP) + if err != nil { + op.accept.err = net._accept_error() + return .Done + } + + + op.accept.client = client.(TCP_Socket) + + received: win.DWORD + if !win.AcceptEx( + win.SOCKET(op.accept.socket), + win.SOCKET(op.accept.client), + &op.accept._impl.addrs, + 0, + size_of(win.sockaddr_in6) + 16, + size_of(win.sockaddr_in6) + 16, + &received, + &op._impl.over, + ) { + if is_pending(op._impl.over) || (op._impl.over.Internal == nil && is_incomplete(win.System_Error(win.GetLastError()))) { + link_timeout(op, op.accept.expires) + return .Pending + } else if op._impl.over.Internal == nil { + op.accept.err = net._accept_error() + } + } + + return .Done +} + +accept_callback :: proc(op: ^Operation) { + assert(op.type == .Accept) + + defer if op.accept.err != nil { + win.closesocket(win.SOCKET(op.accept.client)) + } + + if op.accept.err != nil { + return + } + + _, err := wsa_get_result(win.SOCKET(op.accept.socket), op._impl.over) + #partial switch err { + case .SUCCESS: + local_addr: ^win.sockaddr + local_addr_len: win.INT + remote_addr: ^win.sockaddr + remote_addr_len: win.INT + win.GetAcceptExSockaddrs( + &op.accept._impl.addrs, + 0, + size_of(win.sockaddr_in6) + 16, + size_of(win.sockaddr_in6) + 16, + &local_addr, + &local_addr_len, + &remote_addr, + &remote_addr_len, + ) + + assert(remote_addr_len <= size_of(win.SOCKADDR_STORAGE_LH)) + op.accept.client_endpoint = sockaddr_to_endpoint((^win.SOCKADDR_STORAGE_LH)(remote_addr)) + + // enables getsockopt, setsockopt, getsockname, getpeername, etc. + win.setsockopt(win.SOCKET(op.accept.client), win.SOL_SOCKET, win.SO_UPDATE_ACCEPT_CONTEXT, nil, 0) + + case .OPERATION_ABORTED: + // This error could also happen when the user calls close on the socket. + if check_timed_out(op, op.accept.expires) { + op.accept.err = Accept_Error.Timeout + return + } + fallthrough + + case: + op.accept.err = net._accept_error() + } +} + +@(require_results) +dial_exec :: proc(op: ^Operation) -> (result: Op_Result) { + assert(op.type == .Dial) + assert(is_fresh(op._impl.over)) + + if op.dial.endpoint.port == 0 { + op.dial.err = .Port_Required + return .Done + } + + family := family_from_endpoint(op.dial.endpoint) + osocket, socket_err := _create_socket(op.l, family, .TCP) + if socket_err != nil { + op.dial.err = socket_err + return .Done + } + + op.dial.socket = osocket.(TCP_Socket) + + sockaddr := endpoint_to_sockaddr({IP6_Any if family == .IP6 else net.IP4_Any, 0}) + res := win.bind(win.SOCKET(op.dial.socket), &sockaddr, size_of(sockaddr)) + if res < 0 { + op.dial.err = net._bind_error() + win.closesocket(win.SOCKET(op.dial.socket)) + return .Done + } + + op.dial._impl.addr = endpoint_to_sockaddr(op.dial.endpoint) + + connect_ex: win.LPFN_CONNECTEX + load_socket_fn(win.SOCKET(op.dial.socket), win.WSAID_CONNECTEX, &connect_ex) + + transferred: win.DWORD + if !connect_ex( + win.SOCKET(op.dial.socket), + &op.dial._impl.addr, + size_of(op.dial._impl.addr), + nil, + 0, + &transferred, + &op._impl.over, + ) { + if is_pending(op._impl.over) || (op._impl.over.Internal == nil && is_incomplete(win.System_Error(win.GetLastError()))) { + link_timeout(op, op.dial.expires) + return .Pending + } else if op._impl.over.Internal == nil { + op.dial.err = net._dial_error() + } + } + + return .Done +} + +dial_callback :: proc(op: ^Operation) { + assert(op.type == .Dial) + + defer if op.dial.err != nil { + win.closesocket(win.SOCKET(op.dial.socket)) + } + + if op.dial.err != nil { + return + } + + _, err := wsa_get_result(win.SOCKET(op.dial.socket), op._impl.over) + #partial switch err { + case .SUCCESS: + // enables getsockopt, setsockopt, getsockname, getpeername, etc. + win.setsockopt(win.SOCKET(op.dial.socket), win.SOL_SOCKET, win.SO_UPDATE_CONNECT_CONTEXT, nil, 0) + + case .OPERATION_ABORTED: + op.dial.err = Dial_Error.Timeout + + case: + op.dial.err = net._dial_error() + } +} + +@(require_results) +read_exec :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Read) + op._impl.over = {} // Can be called multiple times. + + op._impl.over.OffsetFull = u64(op.read.offset) + u64(op.read.read) + + to_read := op.read.buf[op.read.read:] + + read: win.DWORD + if !win.ReadFile( + win.HANDLE(op.read.handle), + raw_data(to_read), + win.DWORD(min(len(to_read), MAX_RW)), + &read, + &op._impl.over, + ) { + assert(read == 0) + if is_pending(op._impl.over) { + link_timeout(op, op.read.expires) + return .Pending + } else if op._impl.over.Internal == nil { + err := win.GetLastError() + if is_incomplete(win.System_Error(err)) { + link_timeout(op, op.read.expires) + return .Pending + } + op.read.err = FS_Error(err) + } + } + + assert(uintptr(read) == uintptr(op._impl.over.InternalHigh)) + return .Done +} + +@(require_results) +read_callback :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Read) + + if op.read.err != nil { + return .Done + } + + n, err := get_result(op._impl.over) + #partial switch err { + case .SUCCESS: + case .OPERATION_ABORTED: + // This error could also happen when the user calls close on the handle. + if check_timed_out(op, op.read.expires) { + op.read.err = .Timeout + return .Done + } + fallthrough + case .HANDLE_EOF: + if op.read.read == 0 { + op.read.err = .EOF + return .Done + } + case: + op.read.err = FS_Error(err) + return .Done + } + + op.read.read += n + if op.read.all && op.read.read < len(op.read.buf) { + switch read_exec(op) { + case .Done: return read_callback(op) + case .Pending: return .Pending + } + } + + return .Done +} + +@(require_results) +write_exec :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Write) + op._impl.over = {} // Can be called multiple times. + + op._impl.over.OffsetFull = u64(op.write.offset) + u64(op.write.written) + + to_write := op.write.buf[op.write.written:] + + written: win.DWORD + if !win.WriteFile( + win.HANDLE(op.write.handle), + raw_data(to_write), + win.DWORD(min(len(to_write), MAX_RW)), + &written, + &op._impl.over, + ) { + assert(written == 0) + if is_pending(op._impl.over) { + link_timeout(op, op.write.expires) + return .Pending + } else if op._impl.over.Internal == nil { + err := win.GetLastError() + if is_incomplete(win.System_Error(err)) { + link_timeout(op, op.write.expires) + return .Pending + } + op.write.err = FS_Error(err) + } + } + + assert(uintptr(written) == uintptr(op._impl.over.InternalHigh)) + return .Done +} + +@(require_results) +write_callback :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Write) + + if op.write.err != nil { + return .Done + } + + n, err := get_result(op._impl.over) + #partial switch err { + case .SUCCESS: + case .OPERATION_ABORTED: + // This error could also happen when the user calls close on the handle. + if check_timed_out(op, op.write.expires) { + op.write.err = .Timeout + return .Done + } + fallthrough + case: + op.write.err = FS_Error(err) + return .Done + } + + op.write.written += n + if op.write.all && op.write.written < len(op.write.buf) { + switch write_exec(op) { + case .Done: return write_callback(op) + case .Pending: return .Pending + } + } + + return .Done +} + +@(require_results) +recv_exec :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Recv) + op._impl.over = {} // Can be called multiple times. + + if op.recv.err != nil { + return .Done + } + + bufs := slice.advance_slices(op.recv.bufs, op.recv.received) + bufs, _ = constraint_bufs_to_max_rw(op.recv.bufs) + + win_bufs := ([^]win.WSABUF)(intrinsics.alloca(size_of(win.WSABUF) * len(bufs), align_of(win.WSABUF))) + for buf, i in bufs { + assert(i64(len(buf)) < i64(max(u32))) + win_bufs[i] = {len=u32(len(buf)), buf=raw_data(buf)} + } + + status: win.c_int + switch sock in op.recv.socket { + case TCP_Socket: + status = win.WSARecv( + win.SOCKET(sock), + win_bufs, + u32(len(bufs)), + nil, + &op.recv._impl.flags, + win.LPWSAOVERLAPPED(&op._impl.over), + nil, + ) + case UDP_Socket: + op.recv._impl.source_len = size_of(op.recv._impl.source) + status = win.WSARecvFrom( + win.SOCKET(sock), + win_bufs, + u32(len(bufs)), + nil, + &op.recv._impl.flags, + (^win.sockaddr)(&op.recv._impl.source), + &op.recv._impl.source_len, + win.LPWSAOVERLAPPED(&op._impl.over), + nil, + ) + } + + if status == win.SOCKET_ERROR { + if is_pending(op._impl.over) || (op._impl.over.Internal == nil && is_incomplete(win.System_Error(win.GetLastError()))) { + link_timeout(op, op.recv.expires) + return .Pending + } else if op._impl.over.Internal == nil { + switch _ in op.recv.socket { + case TCP_Socket: op.recv.err = net._tcp_recv_error() + case UDP_Socket: op.recv.err = net._udp_recv_error() + } + } + } + + return .Done +} + +@(require_results) +recv_callback :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Recv) + + if op.recv.err != nil { + return .Done + } + + n, err := wsa_get_result(win.SOCKET((^net.Socket)(&op.recv.socket)^), op._impl.over) + #partial switch err { + case .SUCCESS: + case .OPERATION_ABORTED: + // This error could also happen when the user calls close on the socket. + if check_timed_out(op, op.recv.expires) { + switch _ in op.recv.socket { + case TCP_Socket: op.recv.err = net.TCP_Recv_Error.Timeout + case UDP_Socket: op.recv.err = net.UDP_Recv_Error.Timeout + } + return .Done + } + fallthrough + case: + switch _ in op.recv.socket { + case TCP_Socket: op.recv.err = net._tcp_recv_error() + case UDP_Socket: op.recv.err = net._udp_recv_error() + } + return .Done + } + + op.recv.received += n + + switch sock in op.recv.socket { + case TCP_Socket: + if n == 0 { + // Connection closed. + return .Done + } + + if op.recv.all { + total: int + for buf in op.recv.bufs { + total += len(buf) + } + + if op.recv.received < total { + switch recv_exec(op) { + case .Done: return recv_callback(op) + case .Pending: return .Pending + } + } + } + + case UDP_Socket: + assert(op.recv._impl.source_len > 0) + op.recv.source = sockaddr_to_endpoint(&op.recv._impl.source) + } + + return .Done +} + +@(require_results) +send_exec :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Send) + op._impl.over = {} // Can be called multiple times. + + if op.send.err != nil { + return .Done + } + + bufs := slice.advance_slices(op.send.bufs, op.send.sent) + bufs, _ = constraint_bufs_to_max_rw(op.send.bufs) + + win_bufs := ([^]win.WSABUF)(intrinsics.alloca(size_of(win.WSABUF) * len(bufs), align_of(win.WSABUF))) + for buf, i in bufs { + assert(i64(len(buf)) < i64(max(u32))) + win_bufs[i] = {len=u32(len(buf)), buf=raw_data(buf)} + } + + status: win.c_int + switch sock in op.send.socket { + case TCP_Socket: + status = win.WSASend( + win.SOCKET(sock), + win_bufs, + u32(len(bufs)), + nil, + 0, + win.LPWSAOVERLAPPED(&op._impl.over), + nil, + ) + case UDP_Socket: + addr := endpoint_to_sockaddr(op.send.endpoint) + status = win.WSASendTo( + win.SOCKET(sock), + win_bufs, + u32(len(bufs)), + nil, + 0, + (^win.sockaddr)(&addr), + size_of(addr), + win.LPWSAOVERLAPPED(&op._impl.over), + nil, + ) + } + + if status == win.SOCKET_ERROR { + if is_pending(op._impl.over) || (op._impl.over.Internal == nil && is_incomplete(win.System_Error(win.GetLastError()))) { + link_timeout(op, op.send.expires) + return .Pending + } else if op._impl.over.Internal == nil { + switch _ in op.send.socket { + case TCP_Socket: op.send.err = net._tcp_send_error() + case UDP_Socket: op.send.err = net._udp_send_error() + } + } + } + + return .Done +} + +@(require_results) +send_callback :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Send) + + if op.send.err != nil { + return .Done + } + + n, err := wsa_get_result(win.SOCKET((^net.Socket)(&op.send.socket)^), op._impl.over) + #partial switch err { + case .SUCCESS: + case .OPERATION_ABORTED: + // This error could also happen when the user calls close on the socket. + if check_timed_out(op, op.send.expires) { + switch _ in op.send.socket { + case TCP_Socket: op.send.err = net.TCP_Send_Error.Timeout + case UDP_Socket: op.send.err = net.UDP_Send_Error.Timeout + } + return .Done + } + fallthrough + case: + switch _ in op.send.socket { + case TCP_Socket: op.send.err = net._tcp_send_error() + case UDP_Socket: op.send.err = net._udp_send_error() + } + return .Done + } + + op.send.sent += n + + if op.send.all { + total: int + for buf in op.send.bufs { + total += len(buf) + } + + if op.send.sent < total { + switch send_exec(op) { + case .Done: return send_callback(op) + case .Pending: return .Pending + } + } + } + + return .Done +} + +@(require_results) +sendfile_exec :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Send_File) + op._impl.over = {} // Can be called multiple times. + + if op.sendfile.nbytes == SEND_ENTIRE_FILE { + type, size, stat_err := stat(op.sendfile.file) + if stat_err != nil { + op.sendfile.err = stat_err + return .Done + } + + op.sendfile.nbytes = int(size - i64(op.sendfile.offset)) + if type != .Regular || op.sendfile.nbytes <= 0 { + op.sendfile.err = FS_Error.Invalid_Argument + return .Done + } + } + + op._impl.over.OffsetFull = u64(op.sendfile.offset) + u64(op.sendfile.sent) + + if !win.TransmitFile( + win.SOCKET(op.sendfile.socket), + win.HANDLE(op.sendfile.file), + u32(min(op.sendfile.nbytes - op.sendfile.sent, MAX_RW)), + 0, + &op._impl.over, + nil, + 0, + ) { + if is_pending(op._impl.over) || (op._impl.over.Internal == nil && is_incomplete(win.System_Error(win.GetLastError()))) { + link_timeout(op, op.sendfile.expires) + return .Pending + } else if op._impl.over.Internal == nil { + op.sendfile.err = net._tcp_send_error() + } + } + + return .Done +} + +@(require_results) +sendfile_callback :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Send_File) + + if op.sendfile.err != nil { + return .Done + } + + n, err := wsa_get_result(win.SOCKET(op.sendfile.socket), op._impl.over) + #partial switch err { + case .SUCCESS: + case .OPERATION_ABORTED: + // This error could also happen when the user calls close on the socket. + if check_timed_out(op, op.sendfile.expires) { + op.sendfile.err = TCP_Send_Error.Timeout + return .Done + } + fallthrough + case: + op.sendfile.err = net._tcp_send_error() + return .Done + } + + op.sendfile.sent += n + if op.sendfile.sent < op.sendfile.nbytes { + switch sendfile_exec(op) { + case .Done: + return sendfile_callback(op) + case .Pending: + if op.sendfile.progress_updates { op.cb(op) } + return .Pending + } + } + + return .Done +} + +@(require_results) +poll_exec :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Poll) + + events: i32 = win.FD_CLOSE + switch op.poll.event { + case .Send: events |= win.FD_WRITE|win.FD_CONNECT + case .Receive: events |= win.FD_READ|win.FD_ACCEPT + case: + op.poll.result = .Invalid_Argument + return .Done + } + + op._impl.over.hEvent = win.WSACreateEvent() + if win.WSAEventSelect( + win.SOCKET(net.any_socket_to_socket(op.poll.socket)), + op._impl.over.hEvent, + events, + ) != 0 { + #partial switch win.System_Error(win.GetLastError()) { + case .WSAEINVAL, .WSAENOTSOCK: op.poll.result = .Invalid_Argument + case: op.poll.result = .Error + } + return .Done + } + + timeout := win.INFINITE + if op.poll.expires != {} { + diff := max(0, time.diff(op.l.now, op.poll.expires)) + timeout = win.DWORD(diff / time.Millisecond) + } + + ok := win.RegisterWaitForSingleObject( + &op.poll._impl.wait_handle, + op._impl.over.hEvent, + wait_callback, + op, + timeout, + win.WT_EXECUTEINWAITTHREAD|win.WT_EXECUTEONLYONCE, + ) + ensure(ok == true, "unexpected RegisterWaitForSingleObject error") + + return .Pending + + wait_callback :: proc "system" (lpParameter: win.PVOID, TimerOrWaitFired: win.BOOLEAN) { + op := (^Operation)(lpParameter) + assert_contextless(op.type == .Poll) + + if TimerOrWaitFired { + op.poll.result = .Timeout + } + + ok := win.PostQueuedCompletionStatus( + g.iocp, + 0, + 0, + &op._impl.over, + ) + ensure_contextless(ok == true, "unexpected PostQueuedCompletionStatus error") + } +} + +poll_callback :: proc(op: ^Operation) { + assert(op.type == .Poll) + + if op._impl.over.hEvent != nil { + win.WSACloseEvent(op._impl.over.hEvent) + } + + if op.poll._impl.wait_handle != nil { + win.UnregisterWaitEx(op.poll._impl.wait_handle, nil) + } + + if op.poll.result != nil { + return + } + + _, err := get_result(op._impl.over) + #partial switch err { + case .SUCCESS: + case: + op.poll.result = .Error + } +} + +open_exec :: proc(op: ^Operation) { + assert(op.type == .Open) + // No async way of doing this. + op.open.handle, op.open.err = _open_sync(op.l, op.open.path, op.open.dir, op.open.mode, op.open.perm) +} + +stat_exec :: proc(op: ^Operation) { + assert(op.type == .Stat) + // No async way of doing this. + op.stat.type, op.stat.size, op.stat.err = stat(op.stat.handle) +} + +@(require_results) +timeout_exec :: proc(op: ^Operation) -> Op_Result { + assert(op.type == .Timeout) + + if op.timeout.duration <= 0 { + return .Done + } else { + op.timeout._impl.expires = time.time_add(now(), op.timeout.duration) + node, inserted, alloc_err := avl.find_or_insert(&op.l.timeouts, op) + assert(alloc_err == nil) + assert(inserted) + assert(node != nil) + return .Pending + } +} + +link_timeout :: proc(op: ^Operation, expires: time.Time) { + if expires == {} { + return + } + + timeout_op := _prep(op.l, internal_timeout_callback, .Timeout) + timeout_op.timeout._impl.expires = expires + timeout_op.timeout._impl.target = op + op._impl.timeout = timeout_op + + node, inserted, alloc_err := avl.find_or_insert(&op.l.timeouts, timeout_op) + assert(alloc_err == nil) + assert(inserted) + assert(node != nil) +} + +internal_timeout_callback :: proc(op: ^Operation) { + assert(op.type == .Timeout) + + target := op.timeout._impl.target + assert(target != nil) + assert(target._impl.timeout == op) + target._impl.timeout = nil + + #partial switch target.type { + case .Poll: + target.poll.result = .Timeout + target.cb(target) + _remove(target) + return + } + + if is_pending(target._impl.over) { + handle := operation_handle(target) + assert(handle != win.INVALID_HANDLE) + ok := win.CancelIoEx(handle, &target._impl.over) + if !ok { + err := win.System_Error(win.GetLastError()) + #partial switch err { + case .NOT_FOUND: + debug("Timeout: Cancel", target.type, "NOT_FOUND") + case .INVALID_HANDLE: + debug("Timeout: Cancel", target.type, "INVALID_HANDLE") + case: + assert(false, "unexpected CancelIoEx error") + } + } + } +} + +stat :: proc(handle: Handle) -> (type: File_Type, size: i64, err: FS_Error) { + info: win.FILE_STANDARD_INFO + if !win.GetFileInformationByHandleEx(win.HANDLE(handle), .FileStandardInfo, &info, size_of(info)) { + err = FS_Error(win.GetLastError()) + return + } + + size = i64(info.EndOfFile) + + if info.Directory { + type = .Directory + return + } + + switch win.GetFileType(win.HANDLE(handle)) { + case win.FILE_TYPE_PIPE: + type = .Pipe_Or_Socket + return + case win.FILE_TYPE_CHAR: + type = .Device + return + case win.FILE_TYPE_DISK: + type = .Regular + // Don't return, might be a symlink. + case: + type = .Undetermined + return + } + + + tag_info: win.FILE_ATTRIBUTE_TAG_INFO + if !win.GetFileInformationByHandleEx(win.HANDLE(handle), .FileAttributeTagInfo, &tag_info, size_of(tag_info)) { + return + } + + if ( + (tag_info.FileAttributes & win.FILE_ATTRIBUTE_REPARSE_POINT != 0) && + ( + (tag_info.ReparseTag == win.IO_REPARSE_TAG_SYMLINK) || + (tag_info.ReparseTag == win.IO_REPARSE_TAG_MOUNT_POINT) + ) + ) { + type = .Symlink + } + + return +} + +STATUS_PENDING :: rawptr(uintptr(0x103)) + +is_pending :: proc(over: win.OVERLAPPED) -> bool { + return over.Internal == STATUS_PENDING +} + +is_fresh :: proc(over: win.OVERLAPPED) -> bool { + return over.Internal == nil && over.InternalHigh == nil +} + +get_result :: proc(over: win.OVERLAPPED) -> (n: int, err: win.System_Error) { + assert(!is_pending(over)) + + n = int(uintptr(over.InternalHigh)) + + if over.Internal != nil { + err = win.System_Error(win.RtlNtStatusToDosError(win.NTSTATUS(uintptr(over.Internal)))) + assert(!is_incomplete(err)) + } + return +} + +// `get_result` above translates NT status codes to errors through RtlNtStatsToDosError, +// this is context free and can cause weird mappings, thus for sockets we want to call `WSAGetOverlappedResult` +// which does context based mapping of error codes. +// See https://stackoverflow.com/questions/28925003/calling-wsagetlasterror-from-an-iocp-thread-return-incorrect-result +wsa_get_result :: proc(socket: win.SOCKET, over: win.OVERLAPPED) -> (n: int, err: win.System_Error) { + over := over + assert(!is_pending(over)) + + if over.Internal != nil { + flags: win.DWORD + _n: win.DWORD + res := win.WSAGetOverlappedResult(socket, &over, &_n, false, &flags) + assert(!res) + n = int(_n) // NOTE: It is possible that an amount of bytes is present when the operation was cancelled. + err = win.System_Error(win.WSAGetLastError()) + } + + n = int(uintptr(over.InternalHigh)) + return +} + +is_incomplete :: proc(err: win.System_Error) -> bool { + #partial switch err { + case .WSAEWOULDBLOCK, .IO_PENDING, .IO_INCOMPLETE, .WSAEALREADY: return true + case: return false + } +} + +endpoint_to_sockaddr :: proc(ep: Endpoint) -> (sockaddr: win.SOCKADDR_STORAGE_LH) { + switch a in ep.address { + case IP4_Address: + (^win.sockaddr_in)(&sockaddr)^ = win.sockaddr_in { + sin_port = u16be(win.USHORT(ep.port)), + sin_addr = transmute(win.in_addr)a, + sin_family = u16(win.AF_INET), + } + return + case IP6_Address: + (^win.sockaddr_in6)(&sockaddr)^ = win.sockaddr_in6 { + sin6_port = u16be(win.USHORT(ep.port)), + sin6_addr = transmute(win.in6_addr)a, + sin6_family = u16(win.AF_INET6), + } + return + } + unreachable() +} + +sockaddr_to_endpoint :: proc(native_addr: ^win.SOCKADDR_STORAGE_LH) -> (ep: Endpoint) { + switch native_addr.ss_family { + case u16(win.AF_INET): + addr := cast(^win.sockaddr_in)native_addr + port := int(addr.sin_port) + ep = Endpoint { + address = IP4_Address(transmute([4]byte)addr.sin_addr), + port = port, + } + case u16(win.AF_INET6): + addr := cast(^win.sockaddr_in6)native_addr + port := int(addr.sin6_port) + ep = Endpoint { + address = IP6_Address(transmute([8]u16be)addr.sin6_addr), + port = port, + } + case: + panic("native_addr is neither IP4 or IP6 address") + } + return +} + +load_socket_fn :: proc(subject: win.SOCKET, guid: win.GUID, fn: ^$T) { + over: win.OVERLAPPED + + guid := guid + bytes: u32 + rc := win.WSAIoctl( + subject, + win.SIO_GET_EXTENSION_FUNCTION_POINTER, + &guid, + size_of(guid), + fn, + size_of(fn), + &bytes, + // NOTE: I don't think loading a socket fn ever blocks, + // but I would like to hit an assert if it does, so we do pass it. + &over, + nil, + ) + assert(rc != win.SOCKET_ERROR) + assert(bytes == size_of(fn^)) +} + +check_timed_out :: proc(op: ^Operation, expires: time.Time) -> bool { + return expires != {} && time.diff(op.l.now, expires) <= 0 +} + +timeouts_cmp :: #force_inline proc(a, b: ^Operation) -> slice.Ordering { + switch { + case a.timeout._impl.expires._nsec < b.timeout._impl.expires._nsec: + return .Less + case a.timeout._impl.expires._nsec > b.timeout._impl.expires._nsec: + return .Greater + case uintptr(a) < uintptr(b): + return .Less + case uintptr(a) > uintptr(b): + return .Greater + case: + assert(a == b) + return .Equal + } +} \ No newline at end of file diff --git a/core/nbio/mpsc.odin b/core/nbio/mpsc.odin new file mode 100644 index 000000000..7f88829b4 --- /dev/null +++ b/core/nbio/mpsc.odin @@ -0,0 +1,63 @@ +#+private +package nbio + +import "base:runtime" + +import "core:sync" + +Multi_Producer_Single_Consumer :: struct { + count: int, + head: int, + tail: int, + buffer: []rawptr, + mask: int, +} + +mpsc_init :: proc(mpscq: ^Multi_Producer_Single_Consumer, cap: int, allocator: runtime.Allocator) -> runtime.Allocator_Error { + assert(runtime.is_power_of_two_int(cap), "cap must be a power of 2") + mpscq.buffer = make([]rawptr, cap, allocator) or_return + mpscq.mask = cap-1 + sync.atomic_thread_fence(.Release) + return nil +} + +mpsc_destroy :: proc(mpscq: ^Multi_Producer_Single_Consumer, allocator: runtime.Allocator) { + delete(mpscq.buffer, allocator) +} + +mpsc_enqueue :: proc(mpscq: ^Multi_Producer_Single_Consumer, obj: rawptr) -> bool { + count := sync.atomic_add_explicit(&mpscq.count, 1, .Acquire) + if count >= len(mpscq.buffer) { + sync.atomic_sub_explicit(&mpscq.count, 1, .Release) + return false + } + + head := sync.atomic_add_explicit(&mpscq.head, 1, .Acquire) + assert(mpscq.buffer[head & mpscq.mask] == nil) + rv := sync.atomic_exchange_explicit(&mpscq.buffer[head & mpscq.mask], obj, .Release) + assert(rv == nil) + return true +} + +mpsc_dequeue :: proc(mpscq: ^Multi_Producer_Single_Consumer) -> rawptr { + ret := sync.atomic_exchange_explicit(&mpscq.buffer[mpscq.tail], nil, .Acquire) + if ret == nil { + return nil + } + + mpscq.tail += 1 + if mpscq.tail >= len(mpscq.buffer) { + mpscq.tail = 0 + } + r := sync.atomic_sub_explicit(&mpscq.count, 1, .Release) + assert(r > 0) + return ret +} + +mpsc_count :: proc(mpscq: ^Multi_Producer_Single_Consumer) -> int { + return sync.atomic_load_explicit(&mpscq.count, .Relaxed) +} + +mpsc_cap :: proc(mpscq: ^Multi_Producer_Single_Consumer) -> int { + return len(mpscq.buffer) +} \ No newline at end of file diff --git a/core/nbio/nbio.odin b/core/nbio/nbio.odin new file mode 100644 index 000000000..703a2b4d7 --- /dev/null +++ b/core/nbio/nbio.odin @@ -0,0 +1,431 @@ +package nbio + +import "base:intrinsics" +import "base:runtime" + +import "core:container/pool" +import "core:net" +import "core:time" + +/* +If the package is fully supported on the current target. If it is not it will compile but work +in a matter where things are unimplemented. + +Additionally if it is `FULLY_SUPPORTED` it may still return `.Unsupported` in `acquire_thread_event_loop` +If the target does not support the needed syscalls for operating the package. +*/ +FULLY_SUPPORTED :: _FULLY_SUPPORTED + +/* +An event loop, one per thread, consider the fields private. +Do not copy. +*/ +Event_Loop :: struct /* #no_copy */ { + using impl: _Event_Loop, + allocator: runtime.Allocator, + err: General_Error, + refs: int, + now: time.Time, + + // Queue that is used to queue operations from another thread to be executed on this thread. + queue: Multi_Producer_Single_Consumer, + + operation_pool: pool.Pool(Operation), +} + +Handle :: _Handle + +// The maximum size of user arguments for an operation, can be increased at the cost of more RAM. +MAX_USER_ARGUMENTS :: #config(NBIO_MAX_USER_ARGUMENTS, 4) +#assert(MAX_USER_ARGUMENTS >= 4) + +Operation :: struct { + cb: Callback, + user_data: [MAX_USER_ARGUMENTS + 1]rawptr, + detached: bool, + type: Operation_Type, + using specifics: Specifics, + + _impl: _Operation `fmt:"-"`, + using _: struct #raw_union { + _pool_link: ^Operation, + l: ^Event_Loop, + }, +} + +Specifics :: struct #raw_union { + accept: Accept `raw_union_tag:"type=.Accept"`, + close: Close `raw_union_tag:"type=.Close"`, + dial: Dial `raw_union_tag:"type=.Dial"`, + read: Read `raw_union_tag:"type=.Read"`, + recv: Recv `raw_union_tag:"type=.Recv"`, + send: Send `raw_union_tag:"type=.Send"`, + write: Write `raw_union_tag:"type=.Write"`, + timeout: Timeout `raw_union_tag:"type=.Timeout"`, + poll: Poll `raw_union_tag:"type=.Poll"`, + sendfile: Send_File `raw_union_tag:"type=.Send_File"`, + open: Open `raw_union_tag:"type=.Open"`, + stat: Stat `raw_union_tag:"type=.Stat"`, + + _remove: _Remove `raw_union_tag:"type=._Remove"`, + _link_timeout: _Link_Timeout `raw_union_tag:"type=._Link_Timeout"`, + _splice: _Splice `raw_union_tag:"type=._Splice"`, +} + +Operation_Type :: enum i32 { + None, + Accept, + Close, + Dial, + Read, + Recv, + Send, + Write, + Timeout, + Poll, + Send_File, + Open, + Stat, + + _Link_Timeout, + _Remove, + _Splice, +} + +Callback :: #type proc(op: ^Operation) + +/* +Initialize or increment the reference counted event loop for the current thread. +*/ +acquire_thread_event_loop :: proc() -> General_Error { + return _acquire_thread_event_loop() +} + +/* +Destroy or decrease the reference counted event loop for the current thread. +*/ +release_thread_event_loop :: proc() { + _release_thread_event_loop() +} + +current_thread_event_loop :: proc(loc := #caller_location) -> ^Event_Loop { + return _current_thread_event_loop(loc) +} + +/* +Each time you call this the implementation checks its state +and calls any callbacks which are ready. You would typically call this in a loop. + +Blocks for up-to timeout waiting for events if there is nothing to do. +*/ +tick :: proc(timeout: time.Duration = NO_TIMEOUT) -> General_Error { + l := &_tls_event_loop + if l.refs == 0 { return nil } + return _tick(l, timeout) +} + +/* +Runs the event loop by ticking in a loop until there is no more work to be done. +*/ +run :: proc() -> General_Error { + l := &_tls_event_loop + if l.refs == 0 { return nil } + + acquire_thread_event_loop() + defer release_thread_event_loop() + + for num_waiting() > 0 { + if errno := _tick(l, NO_TIMEOUT); errno != nil { + return errno + } + } + return nil +} + +/* +Runs the event loop by ticking in a loop until there is no more work to be done, or the flag `done` is `true`. +*/ +run_until :: proc(done: ^bool) -> General_Error { + l := &_tls_event_loop + if l.refs == 0 { return nil } + + acquire_thread_event_loop() + defer release_thread_event_loop() + + for num_waiting() > 0 && !intrinsics.volatile_load(done) { + if errno := _tick(l, NO_TIMEOUT); errno != nil { + return errno + } + } + return nil +} + +/* +Returns the number of in-progress operations to be completed on the event loop. +*/ +num_waiting :: proc(l: Maybe(^Event_Loop) = nil) -> int { + l_ := l.? or_else &_tls_event_loop + if l_.refs == 0 { return 0 } + return pool.num_outstanding(&l_.operation_pool) +} + +/* +Returns the current time (cached at most at the beginning of the current tick). +*/ +now :: proc() -> time.Time { + if _tls_event_loop.now == {} { + return time.now() + } + return _tls_event_loop.now +} + +/* +Remove the given operation from the event loop. The callback of it won't be called and resources are freed. + +Calling `remove`: +- Cancels the operation if it has not yet completed +- Prevents the callback from being called + +Cancellation via `remove` is *final* and silent: +- The callback will never be invoked +- No error is delivered +- The operation must be considered dead after removal + +WARN: the operation could have already been (partially or completely) completed. + A send with `all` set to true could have sent a portion already. + But also, a send that could be completed without blocking could have been completed. + You just won't get a callback. + +WARN: once an operation's callback is called it can not be removed anymore (use after free). + +WARN: needs to be called from the thread of the event loop the target belongs to. + +Common use would be to cancel a timeout, remove a polling, or remove an `accept` before calling `close` on it's socket. +*/ +remove :: proc(target: ^Operation) { + if target == nil { + return + } + + assert(target.type != .None) + + if target.l != &_tls_event_loop { + panic("nbio.remove called on different thread") + } + + _remove(target) +} + +/* +Creates a socket for use in `nbio` and relates it to the given event loop. + +Inputs: +- family: Should this be an IP4 or IP6 socket +- protocol: The type of socket (TCP or UDP) +- l: The event loop to associate it with, defaults to the current thread's loop + +Returns: +- socket: The created socket, consider `create_{udp|tcp}_socket` for a typed socket instead of the union +- err: A network error (`Create_Socket_Error`, or `Set_Blocking_Error`) which happened while opening +*/ +create_socket :: proc( + family: Address_Family, + protocol: Socket_Protocol, + l: ^Event_Loop = nil, + loc := #caller_location, +) -> ( + socket: Any_Socket, + err: Create_Socket_Error, +) { + return _create_socket(l if l != nil else _current_thread_event_loop(loc), family, protocol) +} + +/* +Creates a UDP socket for use in `nbio` and relates it to the given event loop. + +Inputs: +- family: Should this be an IP4 or IP6 socket +- l: The event loop to associate it with, defaults to the current thread's loop + +Returns: +- socket: The created UDP socket +- err: A network error (`Create_Socket_Error`, or `Set_Blocking_Error`) which happened while opening +*/ +create_udp_socket :: proc(family: Address_Family, l: ^Event_Loop = nil, loc := #caller_location) -> (net.UDP_Socket, Create_Socket_Error) { + socket, err := create_socket(family, .UDP, l, loc) + if err != nil { + return -1, err + } + + return socket.(UDP_Socket), nil +} + +/* +Creates a TCP socket for use in `nbio` and relates it to the given event loop. + +Inputs: +- family: Should this be an IP4 or IP6 socket +- l: The event loop to associate it with, defaults to the current thread's loop + +Returns: +- socket: The created TCP socket +- err: A network error (`Create_Socket_Error`, or `Set_Blocking_Error`) which happened while opening +*/ +create_tcp_socket :: proc(family: Address_Family, l: ^Event_Loop = nil, loc := #caller_location) -> (net.TCP_Socket, Create_Socket_Error) { + socket, err := create_socket(family, .TCP, l, loc) + if err != nil { + return -1, err + } + + return socket.(TCP_Socket), nil +} + +/* +Creates a socket, sets non blocking mode, relates it to the given IO, binds the socket to the given endpoint and starts listening. + +Inputs: +- endpoint: Where to bind the socket to +- backlog: The maximum length to which the queue of pending connections may grow, before refusing connections +- l: The event loop to associate the socket with, defaults to the current thread's loop + +Returns: +- socket: The opened, bound and listening socket +- err: A network error (`Create_Socket_Error`, `Bind_Error`, or `Listen_Error`) that has happened +*/ +listen_tcp :: proc(endpoint: Endpoint, backlog := 1000, l: ^Event_Loop = nil, loc := #caller_location) -> (socket: TCP_Socket, err: net.Network_Error) { + assert(backlog > 0 && backlog < int(max(i32))) + return _listen_tcp(l if l != nil else _current_thread_event_loop(loc), endpoint, backlog) +} + +/* +Opens a file and associates it with the event loop. + +Inputs: +- path: path to the file, if not absolute: relative from `dir` +- dir: directory that `path` is relative from (if it is relative), defaults to the current working directory +- mode: open mode, defaults to read-only +- perm: permissions to use when creating a file, defaults to read+write for everybody +- l: event loop to associate the file with, defaults to the current thread's + +Returns: +- handle: The file handle +- err: An error if it occurred +*/ +open_sync :: proc(path: string, dir: Handle = CWD, mode: File_Flags = {.Read}, perm := Permissions_Default_File, l: ^Event_Loop = nil, loc := #caller_location) -> (handle: Handle, err: FS_Error) { + return _open_sync(l if l != nil else _current_thread_event_loop(loc), path, dir, mode, perm) +} + +Association_Error :: enum { + None, + // The given file/handle/socket was not opened in a mode that it can be made non-blocking afterwards. + // + // On Windows, this can happen when a file is not opened with the `FILE_FLAG_OVERLAPPED` flag. + // If using `core:os`, that is set when you specify the `O_NONBLOCK` flag. + // There is no way to add that after the fact. + Not_Possible_To_Associate, + // The given handle is not a valid handle. + Invalid_Handle, + // No network connection, or the network stack is not initialized. + Network_Unreachable, +} + +/* +Associate the given OS handle, not opened through this package, with the event loop. + +Consider using this package's `open` or `open_sync` directly instead. + +The handle returned is for convenience, it is actually still the same handle as given. +Thus you should not close the given handle. + +On Windows, this can error when a file is not opened with the `FILE_FLAG_OVERLAPPED` flag. +If using `core:os`, that is set when you specify the `O_NONBLOCK` flag. +There is no way to add that after the fact. +*/ +associate_handle :: proc(handle: uintptr, l: ^Event_Loop = nil, loc := #caller_location) -> (Handle, Association_Error) { + return _associate_handle(handle, l if l != nil else _current_thread_event_loop(loc)) +} + +/* +Associate the given socket, not created through this package, with the event loop. + +Consider using this package's `create_socket` directly instead. +*/ +associate_socket :: proc(socket: Any_Socket, l: ^Event_Loop = nil, loc := #caller_location) -> Association_Error { + return _associate_socket(socket, l if l != nil else _current_thread_event_loop(loc)) +} + +Read_Entire_File_Error :: struct { + operation: Operation_Type, + value: FS_Error, +} + +Read_Entire_File_Callback :: #type proc(user_data: rawptr, data: []byte, err: Read_Entire_File_Error) + +/* +Combines multiple operations (open, stat, read, close) into one that reads an entire regular file. + +The error contains the `operation` that the error happened on. + +Inputs: +- path: path to the file, if not absolute: relative from `dir` +- user_data: a pointer passed through into the callback +- cb: the callback to call once completed, called with the user data, file data, and an optional error +- allocator: the allocator to allocate the file's contents onto +- dir: directory that `path` is relative from (if it is relative), defaults to the current working directory +- l: event loop to execute the operation on +*/ +read_entire_file :: proc(path: string, user_data: rawptr, cb: Read_Entire_File_Callback, allocator := context.allocator, dir := CWD, l: ^Event_Loop = nil, loc := #caller_location) { + _read_entire_file(l if l != nil else _current_thread_event_loop(loc), path, user_data, cb, allocator, dir) +} + +/* +Detach an operation from the package's lifetime management. + +By default the operation's lifetime is managed by the package and freed after a callback is called. +Calling this function detaches the operation from this lifetime. +You are expected to call `reattach` to give the package back this operation. +*/ +detach :: proc(op: ^Operation) { + op.detached = true +} + +/* +Reattach an operation to the package's lifetime management. +*/ +reattach :: proc(op: ^Operation) { + pool.put(&op.l.operation_pool, op) +} + +/* +Execute an operation. + +If the operation is attached to another thread's event loop, it is queued to be executed on that event loop, +optionally waking that loop up (from a blocking `tick`) with `trigger_wake_up`. +*/ +exec :: proc(op: ^Operation, trigger_wake_up := true) { + if op.l == &_tls_event_loop { + _exec(op) + } else { + for !mpsc_enqueue(&op.l.queue, op) { + warn("operation queue on event loop filled up") + wake_up(op.l) + _yield() + } + if trigger_wake_up { + wake_up(op.l) + } + } +} + +/* +Wake up an event loop on another thread which may be blocking for completed operations. + +Commonly used with `exec` from a worker thread to have the event loop pick up that work. +Note that by default `exec` already calls this procedure. +*/ +wake_up :: proc(l: ^Event_Loop) { + if l == &_tls_event_loop { + return + } + _wake_up(l) +} diff --git a/core/nbio/net.odin b/core/nbio/net.odin new file mode 100644 index 000000000..d584639a7 --- /dev/null +++ b/core/nbio/net.odin @@ -0,0 +1,39 @@ +package nbio + +import "core:net" + +Network_Error :: net.Network_Error +Accept_Error :: net.Accept_Error +Dial_Error :: net.Dial_Error +Send_Error :: net.Send_Error +TCP_Send_Error :: net.TCP_Send_Error +UDP_Send_Error :: net.UDP_Send_Error +Recv_Error :: net.Recv_Error +TCP_Recv_Error :: net.TCP_Recv_Error +UDP_Recv_Error :: net.UDP_Recv_Error +Listen_Error :: net.Listen_Error +Create_Socket_Error :: net.Create_Socket_Error + +Address_Family :: net.Address_Family +Socket_Protocol :: net.Socket_Protocol + +Address :: net.Address +IP4_Address :: net.IP4_Address +IP6_Address :: net.IP6_Address + +Endpoint :: net.Endpoint + +TCP_Socket :: net.TCP_Socket +UDP_Socket :: net.UDP_Socket +Any_Socket :: net.Any_Socket + +IP4_Any :: net.IP4_Any +IP6_Any :: net.IP6_Any +IP4_Loopback :: net.IP4_Loopback +IP6_Loopback :: net.IP6_Loopback + +family_from_endpoint :: net.family_from_endpoint +bind :: net.bind +bound_endpoint :: net.bound_endpoint +parse_endpoint :: net.parse_endpoint +endpoint_to_string :: net.endpoint_to_string diff --git a/core/nbio/ops.odin b/core/nbio/ops.odin new file mode 100644 index 000000000..e028c4a76 --- /dev/null +++ b/core/nbio/ops.odin @@ -0,0 +1,2473 @@ +package nbio + +import "base:intrinsics" + +import "core:container/pool" +import "core:time" +import "core:slice" +import "core:mem" + +NO_TIMEOUT: time.Duration: -1 + +Accept :: struct { + // Socket to accept an incoming connection on. + socket: TCP_Socket, + // When this operation expires and should be timed out. + expires: time.Time, + + // The connection that was accepted. + client: TCP_Socket, + // The connection's remote origin. + client_endpoint: Endpoint, + // An error, if it occurred. + err: Accept_Error, + + // Implementation specifics, private. + _impl: _Accept `fmt:"-"`, +} + +/* +Retrieves and preps an operation to do an accept without executing it. + +Executing can then be done with the `exec` procedure. + +The timeout is calculated from the time when this procedure was called, not from when it's executed. + +Any user data can be set on the returned operation's `user_data` field. + +Inputs: +- socket: A bound and listening socket *associated with the event loop* +- cb: The callback to be called when the operation finishes, `Operation.accept` will contain results +- timeout: Optional timeout for the operation, the callback will get a `.Timeout` error after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +prep_accept :: #force_inline proc( + socket: TCP_Socket, + cb: Callback, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation { + op := _prep(l, cb, .Accept) + op.accept.socket = socket + if timeout > 0 { + op.accept.expires = time.time_add(now(), timeout) + } + return op +} + +/* +Using the given socket, accepts the next incoming connection, calling the callback when that happens. + +Any user data can be set on the returned operation's `user_data` field. +Polymorphic variants for type safe user data are available under `accept_poly`, `accept_poly2`, and `accept_poly3`. + +Inputs: +- socket: A bound and listening socket *associated with the event loop* +- cb: The callback to be called when the operation finishes, `Operation.accept` will contain results +- timeout: Optional timeout for the operation, the callback will get a `.Timeout` error after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +accept :: #force_inline proc( + socket: TCP_Socket, + cb: Callback, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation { + res := prep_accept(socket, cb, timeout, l) + exec(res) + return res +} + +/* +Using the given socket, accepts the next incoming connection, calling the callback when that happens. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- socket: A bound and listening socket *associated with the event loop* +- p: User data, the callback will receive this as it's second argument +- cb: The callback to be called when the operation finishes, `Operation.accept` will contain results +- timeout: Optional timeout for the operation, the callback will get a `.Timeout` error after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +accept_poly :: #force_inline proc( + socket: TCP_Socket, + p: $T, + cb: $C/proc(op: ^Operation, p: T), + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil +) -> ^Operation where size_of(T) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_accept(socket, _poly_cb(C, T), timeout, l) + _put_user_data(op, cb, p) + exec(op) + return op +} + +/* +Using the given socket, accepts the next incoming connection, calling the callback when that happens. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- socket: A bound and listening socket *associated with the event loop* +- p: User data, the callback will receive this as it's second argument +- p2: User data, the callback will receive this as it's third argument +- cb: The callback to be called when the operation finishes, `Operation.accept` will contain results +- timeout: Optional timeout for the operation, the callback will get a `.Timeout` error after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +accept_poly2 :: #force_inline proc( + socket: TCP_Socket, + p: $T, p2: $T2, + cb: $C/proc(op: ^Operation, p: T, p2: T2), + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) + size_of(T2) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_accept(socket, _poly_cb2(C, T, T2), timeout, l) + _put_user_data2(op, cb, p, p2) + exec(op) + return op +} + +/* +Using the given socket, accepts the next incoming connection, calling the callback when that happens. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- socket: A bound and listening socket *associated with the event loop* +- p: User data, the callback will receive this as it's second argument +- p2: User data, the callback will receive this as it's third argument +- p3: User data, the callback will receive this as it's fourth argument +- cb: The callback to be called when the operation finishes, `Operation.accept` will contain results +- timeout: Optional timeout for the operation, the callback will get a `.Timeout` error after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +accept_poly3 :: #force_inline proc( + socket: TCP_Socket, + p: $T, p2: $T2, p3: $T3, + cb: $C/proc(op: ^Operation, p: T, p2: T2, p3: T3), + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) + size_of(T2) + size_of(T3) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_accept(socket, _poly_cb3(C, T, T2, T3), timeout, l) + _put_user_data3(op, cb, p, p2, p3) + exec(op) + return op +} + +/* +A union of closable types that can be passed to `close`. +*/ +Closable :: union { + TCP_Socket, + UDP_Socket, + Handle, +} + +Close :: struct { + // The subject to close. + subject: Closable, + + // An error, if it occurred. + err: FS_Error, + + // Implementation specifics, private. + _impl: _Close `fmt:"-"`, +} + +@(private) +empty_callback :: proc(_: ^Operation) {} + +/* +Retrieves and preps an operation to do a close without executing it. + +Executing can then be done with the `exec` procedure. + +Closing something that has IO in progress may or may not cancel it, and may or may not call the callback. +For consistent behavior first call `remove` on in progress IO. + +Any user data can be set on the returned operation's `user_data` field. + +Inputs: +- subject: The subject (socket or file) to close +- cb: The optional callback to be called when the operation finishes, `Operation.close` will contain results +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +prep_close :: #force_inline proc(subject: Closable, cb: Callback = empty_callback, l: ^Event_Loop = nil) -> ^Operation { + op := _prep(l, cb, .Close) + op.close.subject = subject + return op +} + +/* +Closes the given subject (file or socket). + +Closing something that has IO in progress may or may not cancel it, and may or may not call the callback. +For consistent behavior first call `remove` on in progress IO. + +Any user data can be set on the returned operation's `user_data` field. +Polymorphic variants for type safe user data are available under `close_poly`, `close_poly2`, and `close_poly3`. + +Inputs: +- subject: The subject (socket or file) to close +- cb: The optional callback to be called when the operation finishes, `Operation.close` will contain results +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +close :: #force_inline proc(subject: Closable, cb: Callback = empty_callback, l: ^Event_Loop = nil) -> ^Operation { + op := prep_close(subject, cb, l) + exec(op) + return op +} + +/* +Closes the given subject (file or socket). + +Closing something that has IO in progress may or may not cancel it, and may or may not call the callback. +For consistent behavior first call `remove` on in progress IO. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- subject: The subject (socket or file) to close +- p: User data, the callback will receive this as it's second argument +- cb: The optional callback to be called when the operation finishes, `Operation.close` will contain results +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +close_poly :: #force_inline proc(subject: Closable, p: $T, cb: $C/proc(op: ^Operation, p: T), l: ^Event_Loop = nil) -> ^Operation +where size_of(T) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_close(subject, _poly_cb(C, T), l) + _put_user_data(op, cb, p) + exec(op) + return op +} + +/* +Closes the given subject (file or socket). + +Closing something that has IO in progress may or may not cancel it, and may or may not call the callback. +For consistent behavior first call `remove` on in progress IO. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- subject: The subject (socket or file) to close +- p: User data, the callback will receive this as it's second argument +- p2: User data, the callback will receive this as it's third argument +- cb: The optional callback to be called when the operation finishes, `Operation.close` will contain results +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +close_poly2 :: #force_inline proc(subject: Closable, p: $T, p2: $T2, cb: $C/proc(op: ^Operation, p: T, p2: T2), l: ^Event_Loop = nil) -> ^Operation +where size_of(T) + size_of(T2) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_close(subject, _poly_cb2(C, T, T2), l) + _put_user_data2(op, cb, p, p2) + exec(op) + return op +} + +/* +Closes the given subject (file or socket). + +Closing something that has IO in progress may or may not cancel it, and may or may not call the callback. +For consistent behavior first call `remove` on in progress IO. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- subject: The subject (socket or file) to close +- p: User data, the callback will receive this as it's second argument +- p2: User data, the callback will receive this as it's third argument +- p3: User data, the callback will receive this as it's fourth argument +- cb: The optional callback to be called when the operation finishes, `Operation.close` will contain results +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +close_poly3 :: #force_inline proc(subject: Closable, p: $T, p2: $T2, p3: $T3, cb: $C/proc(op: ^Operation, p: T, p2: T2, p3: T3), l: ^Event_Loop = nil) -> ^Operation +where size_of(T) + size_of(T2) + size_of(T3) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_close(subject, _poly_cb3(C, T, T2, T3), l) + _put_user_data3(op, cb, p, p2, p3) + exec(op) + return op +} + +Dial :: struct { + // The endpoint to connect to. + endpoint: Endpoint, + // When this operation expires and should be timed out. + expires: time.Time, + + // Errors that can be returned: `Create_Socket_Error`, or `Dial_Error`. + err: Network_Error, + // The socket to communicate with the connected server. + socket: TCP_Socket, + + // Implementation specifics, private. + _impl: _Dial `fmt:"-"`, +} + +/* +Retrieves and preps an operation to do a dial operation without executing it. + +Executing can then be done with the `exec` procedure. + +The timeout is calculated from the time when this procedure was called, not from when it's executed. + +Any user data can be set on the returned operation's `user_data` field. + +Inputs: +- endpoint: The endpoint to connect to +- cb: The callback to be called when the operation finishes, `Operation.dial` will contain results +- timeout: Optional timeout for the operation, the callback will get a `.Timeout` error after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +prep_dial :: #force_inline proc( + endpoint: Endpoint, + cb: Callback, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation { + op := _prep(l, cb, .Dial) + if timeout > 0 { + op.dial.expires = time.time_add(now(), timeout) + } + op.dial.endpoint = endpoint + return op +} + +/* +Dials the given endpoint. + +Any user data can be set on the returned operation's `user_data` field. +Polymorphic variants for type safe user data are available under `dial_poly`, `dial_poly2`, and `dial_poly3`. + +Inputs: +- endpoint: The endpoint to connect to +- cb: The callback to be called when the operation finishes, `Operation.dial` will contain results +- timeout: Optional timeout for the operation, the callback will get a `.Timeout` error after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +dial :: #force_inline proc( + endpoint: Endpoint, + cb: Callback, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation { + res := prep_dial(endpoint, cb, timeout, l) + exec(res) + return res +} + +/* +Dials the given endpoint. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- endpoint: The endpoint to connect to +- p: User data, the callback will receive this as it's second argument +- cb: The callback to be called when the operation finishes, `Operation.dial` will contain results +- timeout: Optional timeout for the operation, the callback will get a `.Timeout` error after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +dial_poly :: #force_inline proc( + endpoint: Endpoint, + p: $T, + cb: $C/proc(op: ^Operation, p: T), + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_dial(endpoint, _poly_cb(C, T), timeout, l) + _put_user_data(op, cb, p) + exec(op) + + return op +} + +/* +Dials the given endpoint. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- endpoint: The endpoint to connect to +- p: User data, the callback will receive this as it's second argument +- p2: User data, the callback will receive this as it's third argument +- cb: The callback to be called when the operation finishes, `Operation.dial` will contain results +- timeout: Optional timeout for the operation, the callback will get a `.Timeout` error after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +dial_poly2 :: #force_inline proc( + endpoint: Endpoint, + p: $T, p2: $T2, + cb: $C/proc(op: ^Operation, p: T, p2: T2), + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) + size_of(T2) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_dial(endpoint, _poly_cb2(C, T, T2), timeout, l) + _put_user_data2(op, cb, p, p2) + exec(op) + + return op +} + +/* +Dials the given endpoint. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- endpoint: The endpoint to connect to +- p: User data, the callback will receive this as it's second argument +- p2: User data, the callback will receive this as it's third argument +- p3: User data, the callback will receive this as it's fourth argument +- cb: The callback to be called when the operation finishes, `Operation.dial` will contain results +- timeout: Optional timeout for the operation, the callback will get a `.Timeout` error after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +dial_poly3 :: #force_inline proc( + endpoint: Endpoint, + p: $T, p2: $T2, p3: $T3, + cb: $C/proc(op: ^Operation, p: T, p2: T2, p3: T3), + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) + size_of(T2) + size_of(T3) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_dial(endpoint, _poly_cb3(C, T, T2, T3), timeout, l) + _put_user_data3(op, cb, p, p2, p3) + exec(op) + + return op +} + +Recv :: struct { + // The socket to receive from. + socket: Any_Socket, + // The buffers to receive data into. + // The outer slice is copied internally, but the backing arrays must remain alive. + // It is safe to access `bufs` during the callback. + bufs: [][]byte, + // If true, the operation waits until all buffers are filled (TCP only). + all: bool, + // When this operation expires and should be timed out. + expires: time.Time, + + // The source endpoint data was received from (UDP only). + source: Endpoint, + + // An error, if it occurred. + // If `received == 0` and `err == nil`, the connection was closed by the peer. + err: Recv_Error, + // The number of bytes received. + received: int, + + // Implementation specifics, private. + _impl: _Recv `fmt:"-"`, +} + +/* +Retrieves and preps an operation to do a receive without executing it. + +Executing can then be done with the `exec` procedure. + +To avoid ambiguity between a closed connection and a 0-byte read, the provided buffers must have a total capacity greater than 0. + +The `bufs` slice itself is copied into the operation, so it can be temporary (e.g. on the stack), but the underlying memory of the buffers must remain valid until the callback is fired. + +The timeout is calculated from the time when this procedure was called, not from when it's executed. + +Any user data can be set on the returned operation's `user_data` field. + +Inputs: +- socket: The socket to receive from +- bufs: Buffers to fill with received data +- cb: The callback to be called when the operation finishes, `Operation.recv` will contain results +- all: If true, waits until all buffers are full before completing (TCP only, ignored for UDP) +- timeout: Optional timeout for the operation, the callback will get a `.Timeout` error after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +prep_recv :: #force_inline proc( + socket: Any_Socket, + bufs: [][]byte, + cb: Callback, + all := false, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation { + assert(socket != nil) + + // If we accepted `bufs` that total 0 it would be ambiguous if the result of `received == 0 && err == nil` means connection closed or received 0 bytes. + assert(len(bufs) > 0) + assert(slice.any_of_proc(bufs, proc(buf: []byte) -> bool { return len(buf) > 0 })) + + op := _prep(l, cb, .Recv) + op.recv.socket = socket + op.recv.bufs = bufs + op.recv.all = all + if timeout > 0 { + op.recv.expires = time.time_add(now(), timeout) + } + + if len(op.recv.bufs) == 1 { + op.recv._impl.small_bufs = {op.recv.bufs[0]} + op.recv.bufs = op.recv._impl.small_bufs[:] + } else { + err: mem.Allocator_Error + if op.recv.bufs, err = slice.clone(op.recv.bufs, op.l.allocator); err != nil { + switch _ in op.recv.socket { + case TCP_Socket: op.recv.err = TCP_Recv_Error.Insufficient_Resources + case UDP_Socket: op.recv.err = UDP_Recv_Error.Insufficient_Resources + case: unreachable() + } + } + } + + return op +} + +/* +Receives data from the socket. + +If the operation completes with 0 bytes received and no error, it indicates the connection was closed by the peer. + +The `bufs` slice itself is copied into the operation, so it can be temporary (e.g. on the stack), but the underlying memory of the buffers must remain valid until the callback is fired. + +Any user data can be set on the returned operation's `user_data` field. +Polymorphic variants for type safe user data are available under `recv_poly`, `recv_poly2`, and `recv_poly3`. + +Inputs: +- socket: The socket to receive from +- bufs: Buffers to fill with received data +- cb: The callback to be called when the operation finishes, `Operation.recv` will contain results +- all: If true, waits until all buffers are full before completing (TCP only, ignored for UDP) +- timeout: Optional timeout for the operation, the callback will get a `.Timeout` error after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +recv :: #force_inline proc( + socket: Any_Socket, + bufs: [][]byte, + cb: Callback, + all := false, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil +) -> ^Operation { + op := prep_recv(socket, bufs, cb, all, timeout, l) + exec(op) + return op +} + +/* +Receives data from the socket. + +If the operation completes with 0 bytes received and no error, it indicates the connection was closed by the peer. + +The `bufs` slice itself is copied into the operation, so it can be temporary (e.g. on the stack), but the underlying memory of the buffers must remain valid until the callback is fired. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- socket: The socket to receive from +- bufs: Buffers to fill with received data +- p: User data, the callback will receive this as it's second argument +- cb: The callback to be called when the operation finishes, `Operation.recv` will contain results +- all: If true, waits until all buffers are full before completing (TCP only, ignored for UDP) +- timeout: Optional timeout for the operation, the callback will get a `.Timeout` error after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +recv_poly :: #force_inline proc( + socket: Any_Socket, + bufs: [][]byte, + p: $T, + cb: $C/proc(op: ^Operation, p: T), + all := false, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_recv(socket, bufs, _poly_cb(C, T), all, timeout, l) + _put_user_data(op, cb, p) + exec(op) + + return op +} + +/* +Receives data from the socket. + +If the operation completes with 0 bytes received and no error, it indicates the connection was closed by the peer. + +The `bufs` slice itself is copied into the operation, so it can be temporary (e.g. on the stack), but the underlying memory of the buffers must remain valid until the callback is fired. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- socket: The socket to receive from +- bufs: Buffers to fill with received data +- p: User data, the callback will receive this as it's second argument +- p2: User data, the callback will receive this as it's third argument +- cb: The callback to be called when the operation finishes, `Operation.recv` will contain results +- all: If true, waits until all buffers are full before completing (TCP only, ignored for UDP) +- timeout: Optional timeout for the operation, the callback will get a `.Timeout` error after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +recv_poly2 :: #force_inline proc( + socket: Any_Socket, + bufs: [][]byte, + p: $T, p2: $T2, + cb: $C/proc(op: ^Operation, p: T, p2: T2), + all := false, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) + size_of(T2) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_recv(socket, bufs, _poly_cb2(C, T, T2), all, timeout, l) + _put_user_data2(op, cb, p, p2) + exec(op) + + return op +} + +/* +Receives data from the socket. + +If the operation completes with 0 bytes received and no error, it indicates the connection was closed by the peer. + +The `bufs` slice itself is copied into the operation, so it can be temporary (e.g. on the stack), but the underlying memory of the buffers must remain valid until the callback is fired. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- socket: The socket to receive from +- bufs: Buffers to fill with received data +- p: User data, the callback will receive this as it's second argument +- p2: User data, the callback will receive this as it's third argument +- p3: User data, the callback will receive this as it's fourth argument +- cb: The callback to be called when the operation finishes, `Operation.recv` will contain results +- all: If true, waits until all buffers are full before completing (TCP only, ignored for UDP) +- timeout: Optional timeout for the operation, the callback will get a `.Timeout` error after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +recv_poly3 :: #force_inline proc( + socket: Any_Socket, + bufs: [][]byte, + p: $T, p2: $T2, p3: $T3, + cb: $C/proc(op: ^Operation, p: T, p2: T2, p3: T3), + all := false, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) + size_of(T2) + size_of(T3) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_recv(socket, bufs, _poly_cb3(C, T, T2, T3), all, timeout, l) + _put_user_data3(op, cb, p, p2, p3) + exec(op) + + return op +} + +Send :: struct { + // The socket to send to. + socket: Any_Socket, + // The buffers to send. + // The outer slice is copied internally, but the backing arrays must remain alive. + bufs: [][]byte `fmt:"-"`, + // The destination endpoint to send to (UDP only). + endpoint: Endpoint, + // If true, the operation ensures all data is sent before completing. + all: bool, + // When this operation expires and should be timed out. + expires: time.Time, + + // An error, if it occurred. + err: Send_Error, + // The number of bytes sent. + sent: int, + + // Implementation specifics, private. + _impl: _Send `fmt:"-"`, +} + +/* +Retrieves and preps an operation to do a send without executing it. + +Executing can then be done with the `exec` procedure. + +The `bufs` slice itself is copied into the operation, so it can be temporary (e.g. on the stack), but the underlying memory of the buffers must remain valid until the callback is fired. + +The timeout is calculated from the time when this procedure was called, not from when it's executed. + +Any user data can be set on the returned operation's `user_data` field. + +Inputs: +- socket: The socket to send to +- bufs: Buffers containing the data to send +- cb: The callback to be called when the operation finishes, `Operation.send` will contain results +- endpoint: The destination endpoint (UDP only, ignored for TCP) +- all: If true, the operation ensures all data is sent before completing +- timeout: Optional timeout for the operation, the callback will get a `.Timeout` error after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +prep_send :: proc( + socket: Any_Socket, + bufs: [][]byte, + cb: Callback, + endpoint: Endpoint = {}, + all := true, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation { + assert(socket != nil) + op := _prep(l, cb, .Send) + op.send.socket = socket + op.send.bufs = bufs + op.send.endpoint = endpoint + op.send.all = all + if timeout > 0 { + op.send.expires = time.time_add(now(), timeout) + } + + if len(op.send.bufs) == 1 { + op.send._impl.small_bufs = {op.send.bufs[0]} + op.send.bufs = op.send._impl.small_bufs[:] + } else { + err: mem.Allocator_Error + if op.send.bufs, err = slice.clone(op.send.bufs, op.l.allocator); err != nil { + switch _ in op.send.socket { + case TCP_Socket: op.send.err = TCP_Send_Error.Insufficient_Resources + case UDP_Socket: op.send.err = UDP_Send_Error.Insufficient_Resources + case: unreachable() + } + } + } + + return op +} + +/* +Sends data to the socket. + +The `bufs` slice itself is copied into the operation, so it can be temporary (e.g. on the stack), but the underlying memory of the buffers must remain valid until the callback is fired. + +Any user data can be set on the returned operation's `user_data` field. +Polymorphic variants for type safe user data are available under `send_poly`, `send_poly2`, and `send_poly3`. + +Inputs: +- socket: The socket to send to +- bufs: Buffers containing the data to send +- cb: The callback to be called when the operation finishes, `Operation.send` will contain results +- endpoint: The destination endpoint (UDP only, ignored for TCP) +- all: If true, the operation ensures all data is sent before completing +- timeout: Optional timeout for the operation, the callback will get a `.Timeout` error after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +send :: #force_inline proc( + socket: Any_Socket, + bufs: [][]byte, + cb: Callback, + endpoint: Endpoint = {}, + all := true, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation { + op := prep_send(socket, bufs, cb, endpoint, all, timeout, l) + exec(op) + return op +} + +/* +Sends data to the socket. + +The `bufs` slice itself is copied into the operation, so it can be temporary (e.g. on the stack), but the underlying memory of the buffers must remain valid until the callback is fired. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- socket: The socket to send to +- bufs: Buffers containing the data to send +- p: User data, the callback will receive this as it's second argument +- cb: The callback to be called when the operation finishes, `Operation.send` will contain results +- endpoint: The destination endpoint (UDP only, ignored for TCP) +- all: If true, the operation ensures all data is sent before completing +- timeout: Optional timeout for the operation, the callback will get a `.Timeout` error after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +send_poly :: #force_inline proc( + socket: Any_Socket, + bufs: [][]byte, + p: $T, + cb: $C/proc(op: ^Operation, p: T), + endpoint: Endpoint = {}, + all := true, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_send(socket, bufs, _poly_cb(C, T), endpoint, all, timeout, l) + _put_user_data(op, cb, p) + exec(op) + + return op +} + +/* +Sends data to the socket. + +The `bufs` slice itself is copied into the operation, so it can be temporary (e.g. on the stack), but the underlying memory of the buffers must remain valid until the callback is fired. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- socket: The socket to send to +- bufs: Buffers containing the data to send +- p: User data, the callback will receive this as it's second argument +- p2: User data, the callback will receive this as it's third argument +- cb: The callback to be called when the operation finishes, `Operation.send` will contain results +- endpoint: The destination endpoint (UDP only, ignored for TCP) +- all: If true, the operation ensures all data is sent before completing +- timeout: Optional timeout for the operation, the callback will get a `.Timeout` error after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +send_poly2 :: #force_inline proc( + socket: Any_Socket, + bufs: [][]byte, + p: $T, p2: $T2, + cb: $C/proc(op: ^Operation, p: T, p2: T2), + endpoint: Endpoint = {}, + all := true, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) + size_of(T2) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_send(socket, bufs, _poly_cb2(C, T, T2), endpoint, all, timeout, l) + _put_user_data2(op, cb, p, p2) + exec(op) + + return op +} + +/* +Sends data to the socket. + +The `bufs` slice itself is copied into the operation, so it can be temporary (e.g. on the stack), but the underlying memory of the buffers must remain valid until the callback is fired. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- socket: The socket to send to +- bufs: Buffers containing the data to send +- p: User data, the callback will receive this as it's second argument +- p2: User data, the callback will receive this as it's third argument +- p3: User data, the callback will receive this as it's fourth argument +- cb: The callback to be called when the operation finishes, `Operation.send` will contain results +- endpoint: The destination endpoint (UDP only, ignored for TCP) +- all: If true, the operation ensures all data is sent before completing +- timeout: Optional timeout for the operation, the callback will get a `.Timeout` error after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +send_poly3 :: #force_inline proc( + socket: Any_Socket, + bufs: [][]byte, + p: $T, p2: $T2, p3: $T3, + cb: $C/proc(op: ^Operation, p: T, p2: T2, p3: T3), + endpoint: Endpoint = {}, + all := true, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) + size_of(T2) + size_of(T3) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_send(socket, bufs, _poly_cb3(C, T, T2, T3), endpoint, all, timeout, l) + _put_user_data3(op, cb, p, p2, p3) + exec(op) + + return op +} + +Read :: struct { + // Handle to read from. + handle: Handle, + // Buffer to read data into. + buf: []byte `fmt:"v,read"`, + // Offset to read from. + offset: int, + // Whether to read until the buffer is full or an error occurs. + all: bool, + // When this operation expires and should be timed out. + expires: time.Time, + + // Error, if it occurred. + err: FS_Error, + // Number of bytes read. + read: int, + + // Implementation specifics, private. + _impl: _Read `fmt:"-"`, +} + +/* +Retrieves and preps a positional read operation without executing it. + +This is a pread-style operation: the read starts at the given offset and does +not modify the handle's current file position. + +Executing can then be done with the `exec` procedure. + +The timeout is calculated from the time when this procedure was called, +not from when it's executed. + +Any user data can be set on the returned operation's `user_data` field. + +Inputs: +- handle: Handle to read from +- offset: Offset to read from +- buf: Buffer to read data into (must not be empty) +- cb: The callback to be called when the operation finishes, `Operation.read` will contain results +- all: Whether to read until the buffer is full or an error occurs +- timeout: Optional timeout for the operation +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +prep_read :: #force_inline proc( + handle: Handle, + offset: int, + buf: []byte, + cb: Callback, + all := false, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation { + assert(len(buf) > 0) + op := _prep(l, cb, .Read) + op.read.handle = handle + op.read.buf = buf + op.read.offset = offset + op.read.all = all + if timeout > 0 { + op.read.expires = time.time_add(now(), timeout) + } + return op +} + +/* +Reads data from a handle at a specific offset. + +This is a pread-style operation: the read starts at the given offset and does +not modify the handle's current file position. + +Any user data can be set on the returned operation's `user_data` field. +Polymorphic variants for type safe user data are available under `read_poly`, `read_poly2`, and `read_poly3`. + +Inputs: +- handle: Handle to read from +- offset: Offset to read from +- buf: Buffer to read data into (must not be empty) +- cb: The callback to be called when the operation finishes, `Operation.read` will contain results +- all: Whether to read until the buffer is full or an error occurs +- timeout: Optional timeout for the operation +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +read :: #force_inline proc( + handle: Handle, + offset: int, + buf: []byte, + cb: Callback, + all := false, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation { + op := prep_read(handle, offset, buf, cb, all, timeout, l) + exec(op) + return op +} + +/* +Reads data from a handle at a specific offset. + +This is a pread-style operation: the read starts at the given offset and does +not modify the handle's current file position. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- handle: Handle to read from +- offset: Offset to read from +- buf: Buffer to read data into (must not be empty) +- p: User data, the callback will receive this as its second argument +- cb: The callback to be called when the operation finishes, `Operation.read` will contain results +- all: Whether to read until the buffer is full or an error occurs +- timeout: Optional timeout for the operation +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +read_poly :: #force_inline proc( + handle: Handle, + offset: int, + buf: []byte, + p: $T, + cb: $C/proc(op: ^Operation, p: T), + all := false, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil +) -> ^Operation where size_of(T) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_read(handle, offset, buf, _poly_cb(C, T), all=all, timeout=timeout, l=l) + _put_user_data(op, cb, p) + exec(op) + + return op +} + +/* +Reads data from a handle at a specific offset. + +This is a pread-style operation: the read starts at the given offset and does +not modify the handle's current file position. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- handle: Handle to read from +- offset: Offset to read from +- buf: Buffer to read data into (must not be empty) +- p: User data, the callback will receive this as its second argument +- p2: User data, the callback will receive this as its third argument +- cb: The callback to be called when the operation finishes, `Operation.read` will contain results +- all: Whether to read until the buffer is full or an error occurs +- timeout: Optional timeout for the operation +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +read_poly2 :: #force_inline proc( + handle: Handle, + offset: int, + buf: []byte, + p: $T, p2: $T2, + cb: $C/proc(op: ^Operation, p: T, p2: T2), + all := false, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil +) -> ^Operation where size_of(T) + size_of(T2) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_read(handle, offset, buf, _poly_cb2(C, T, T2), all, timeout, l) + _put_user_data2(op, cb, p, p2) + exec(op) + + return op +} + +/* +Reads data from a handle at a specific offset. + +This is a pread-style operation: the read starts at the given offset and does +not modify the handle's current file position. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- handle: Handle to read from +- offset: Offset to read from +- buf: Buffer to read data into (must not be empty) +- p: User data, the callback will receive this as its second argument +- p2: User data, the callback will receive this as its third argument +- p3: User data, the callback will receive this as its fourth argument +- cb: The callback to be called when the operation finishes, `Operation.read` will contain results +- all: Whether to read until the buffer is full or an error occurs +- timeout: Optional timeout for the operation +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +read_poly3 :: #force_inline proc( + handle: Handle, + offset: int, + buf: []byte, + p: $T, p2: $T2, p3: $T3, + cb: $C/proc(op: ^Operation, p: T, p2: T2, p3: T3), + all := false, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil +) -> ^Operation where size_of(T) + size_of(T2) + size_of(T3) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_read(handle, offset, buf, _poly_cb3(C, T, T2, T3), all, timeout, l) + _put_user_data3(op, cb, p, p2, p3) + exec(op) + + return op +} + +Write :: struct { + // Handle to write to. + handle: Handle, + // Buffer containing data to write. + buf: []byte, + // Offset to write to. + offset: int, + // Whether to write until the buffer is fully written or an error occurs. + all: bool, + // When this operation expires and should be timed out. + expires: time.Time, + + // Error, if it occurred. + err: FS_Error, + // Number of bytes written. + written: int, + + // Implementation specifics, private. + _impl: _Write `fmt:"-"`, +} + +/* +Retrieves and preps a positional write operation without executing it. + +This is a pwrite-style operation: the write starts at the given offset and does +not modify the handle's current file position. + +Executing can then be done with the `exec` procedure. + +The timeout is calculated from the time when this procedure was called, +not from when it's executed. + +Any user data can be set on the returned operation's `user_data` field. + +Inputs: +- handle: Handle to write to +- offset: Offset to write to +- buf: Buffer containing data to write (must not be empty) +- cb: The callback to be called when the operation finishes, `Operation.write` will contain results +- all: Whether to write until the entire buffer is written or an error occurs +- timeout: Optional timeout for the operation +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +prep_write :: #force_inline proc( + handle: Handle, + offset: int, + buf: []byte, + cb: Callback, + all := true, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation { + assert(len(buf) > 0) + op := _prep(l, cb, .Write) + op.write.handle = handle + op.write.buf = buf + op.write.offset = offset + op.write.all = all + if timeout > 0 { + op.write.expires = time.time_add(now(), timeout) + } + return op +} + +/* +Writes data to a handle at a specific offset. + +This is a pwrite-style operation: the write starts at the given offset and does +not modify the handle's current file position. + +Any user data can be set on the returned operation's `user_data` field. +Polymorphic variants for type safe user data are available under `write_poly`, `write_poly2`, and `write_poly3`. + +Inputs: +- handle: Handle to write to +- offset: Offset to write to +- buf: Buffer containing data to write (must not be empty) +- cb: The callback to be called when the operation finishes, `Operation.write` will contain results +- all: Whether to write until the entire buffer is written or an error occurs +- timeout: Optional timeout for the operation +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +write :: #force_inline proc( + handle: Handle, + offset: int, + buf: []byte, + cb: Callback, + all := true, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation { + op := prep_write(handle, offset, buf, cb, all, timeout, l) + exec(op) + return op +} + +/* +Writes data to a handle at a specific offset. + +This is a pwrite-style operation: the write starts at the given offset and does +not modify the handle's current file position. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- handle: Handle to write to +- offset: Offset to write to +- buf: Buffer containing data to write (must not be empty) +- p: User data, the callback will receive this as its second argument +- cb: The callback to be called when the operation finishes, `Operation.write` will contain results +- all: Whether to write until the entire buffer is written or an error occurs +- timeout: Optional timeout for the operation +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +write_poly :: #force_inline proc( + handle: Handle, + offset: int, + buf: []byte, + p: $T, + cb: $C/proc(op: ^Operation, p: T), + all := true, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil +) -> ^Operation where size_of(T) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_write(handle, offset, buf, _poly_cb(C, T), all=all, timeout=timeout, l=l) + _put_user_data(op, cb, p) + exec(op) + + return op +} + +/* +Writes data to a handle at a specific offset. + +This is a pwrite-style operation: the write starts at the given offset and does +not modify the handle's current file position. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- handle: Handle to write to +- offset: Offset to write to +- buf: Buffer containing data to write (must not be empty) +- p: User data, the callback will receive this as its second argument +- p2: User data, the callback will receive this as its third argument +- cb: The callback to be called when the operation finishes, `Operation.write` will contain results +- all: Whether to write until the entire buffer is written or an error occurs +- timeout: Optional timeout for the operation +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +write_poly2 :: #force_inline proc( + handle: Handle, + offset: int, + buf: []byte, + p: $T, p2: $T2, + cb: $C/proc(op: ^Operation, p: T, p2: T2), + all := true, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil +) -> ^Operation where size_of(T) + size_of(T2) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_write(handle, offset, buf, _poly_cb2(C, T, T2), all, timeout, l) + _put_user_data2(op, cb, p, p2) + exec(op) + + return op +} + +/* +Writes data to a handle at a specific offset. + +This is a pwrite-style operation: the write starts at the given offset and does +not modify the handle's current file position. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- handle: Handle to write to +- offset: Offset to write to +- buf: Buffer containing data to write (must not be empty) +- p: User data, the callback will receive this as its second argument +- p2: User data, the callback will receive this as its third argument +- p3: User data, the callback will receive this as its fourth argument +- cb: The callback to be called when the operation finishes, `Operation.write` will contain results +- all: Whether to write until the entire buffer is written or an error occurs +- timeout: Optional timeout for the operation +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +write_poly3 :: #force_inline proc( + handle: Handle, + offset: int, + buf: []byte, + p: $T, p2: $T2, p3: $T3, + cb: $C/proc(op: ^Operation, p: T, p2: T2, p3: T3), + all := true, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil +) -> ^Operation where size_of(T) + size_of(T2) + size_of(T3) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_write(handle, offset, buf, _poly_cb3(C, T, T2, T3), all, timeout, l) + _put_user_data3(op, cb, p, p2, p3) + exec(op) + + return op +} + +Timeout :: struct { + // Duration after which the timeout expires. + duration: time.Duration, + + // Implementation specifics, private. + _impl: _Timeout `fmt:"-"`, +} + +/* +Retrieves and preps a timeout operation without executing it. + +Executing can then be done with the `exec` procedure. + +Any user data can be set on the returned operation's `user_data` field. + +Inputs: +- duration: Duration to wait before the operation completes +- cb: The callback to be called when the operation finishes +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +prep_timeout :: #force_inline proc( + duration: time.Duration, + cb: Callback, + l: ^Event_Loop = nil, +) -> ^Operation { + op := _prep(l, cb, .Timeout) + op.timeout.duration = duration + return op +} + +/* +Schedules a timeout that completes after the given duration. + +Any user data can be set on the returned operation's `user_data` field. +Polymorphic variants for type safe user data are available under `timeout_poly`, `timeout_poly2`, and `timeout_poly3`. + +Inputs: +- duration: Duration to wait before the operation completes +- cb: The callback to be called when the operation finishes +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +timeout :: #force_inline proc( + duration: time.Duration, + cb: Callback, + l: ^Event_Loop = nil, +) -> ^Operation { + op := prep_timeout(duration, cb, l) + exec(op) + return op +} + +/* +Schedules a timeout that completes after the given duration. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- dur: Duration to wait before the operation completes +- p: User data, the callback will receive this as its second argument +- cb: The callback to be called when the operation finishes +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +timeout_poly :: #force_inline proc( + dur: time.Duration, + p: $T, + cb: $C/proc(op: ^Operation, p: T), + l: ^Event_Loop = nil, +) -> ^Operation + where size_of(T) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_timeout(dur, _poly_cb(C, T), l) + _put_user_data(op, cb, p) + exec(op) + + return op +} + +/* +Schedules a timeout that completes after the given duration. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- dur: Duration to wait before the operation completes +- p: User data, the callback will receive this as its second argument +- p2: User data, the callback will receive this as its third argument +- cb: The callback to be called when the operation finishes +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +timeout_poly2 :: #force_inline proc( + dur: time.Duration, + p: $T, p2: $T2, + cb: $C/proc(op: ^Operation, p: T, p2: T2), + l: ^Event_Loop = nil, +) -> ^Operation + where size_of(T) + size_of(T2) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_timeout(dur, _poly_cb2(C, T, T2), l) + _put_user_data2(op, cb, p, p2) + exec(op) + + return op +} + +/* +Schedules a timeout that completes after the given duration. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- dur: Duration to wait before the operation completes +- p: User data, the callback will receive this as its second argument +- p2: User data, the callback will receive this as its third argument +- p3: User data, the callback will receive this as its fourth argument +- cb: The callback to be called when the operation finishes +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +timeout_poly3 :: #force_inline proc( + dur: time.Duration, + p: $T, p2: $T2, p3: $T3, + cb: $C/proc(op: ^Operation, p: T, p2: T2, p3: T3), + l: ^Event_Loop = nil, +) -> ^Operation + where size_of(T) + size_of(T2) + size_of(T3) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_timeout(dur, _poly_cb3(C, T, T2, T3), l) + _put_user_data3(op, cb, p, p2, p3) + exec(op) + + return op +} + +/* +Retrieves and preps an operation that completes on the next event loop tick. + +This is equivalent to `prep_timeout(0, ...)`. +*/ +prep_next_tick :: #force_inline proc(cb: Callback, l: ^Event_Loop = nil) -> ^Operation { + return prep_timeout(0, cb, l) +} + +/* +Schedules an operation that completes on the next event loop tick. + +This is equivalent to `timeout(0, ...)`. +*/ +next_tick :: #force_inline proc(cb: Callback, l: ^Event_Loop = nil) -> ^Operation { + return timeout(0, cb, l) +} + +/* +Schedules an operation that completes on the next event loop tick. + +This is equivalent to `timeout_poly(0, ...)`. +*/ +next_tick_poly :: #force_inline proc(p: $T, cb: $C/proc(op: ^Operation, p: T), l: ^Event_Loop = nil) -> ^Operation + where size_of(T) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + return timeout_poly(0, p, cb, l) +} + +/* +Schedules an operation that completes on the next event loop tick. + +This is equivalent to `timeout_poly2(0, ...)`. +*/ +next_tick_poly2 :: #force_inline proc(p: $T, p2: $T2, cb: $C/proc(op: ^Operation, p: T, p2: T2), l: ^Event_Loop = nil) -> ^Operation + where size_of(T) + size_of(T2) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + return timeout_poly2(0, p, p2, cb, l) +} + +/* +Schedules an operation that completes on the next event loop tick. + +This is equivalent to `timeout_poly3(0, ...)`. +*/ +next_tick_poly3 :: #force_inline proc(p: $T, p2: $T2, p3: $T3, cb: $C/proc(op: ^Operation, p: T, p2: T2, p3: T3), l: ^Event_Loop = nil) -> ^Operation + where size_of(T) + size_of(T2) + size_of(T3) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + return timeout_poly3(0, p, p2, p3, cb, l) +} + +Poll_Result :: enum i32 { + // The requested event is ready. + Ready, + // The operation timed out before the event became ready. + Timeout, + // The socket was invalid. + Invalid_Argument, + // An unspecified error occurred. + Error, +} + +Poll_Event :: enum { + // The subject is ready to be received from. + Receive, + // The subject is ready to be sent to. + Send, +} + +Poll :: struct { + // Socket to poll. + socket: Any_Socket, + // Event to poll for. + event: Poll_Event, + // When this operation expires and should be timed out. + expires: time.Time, + + // Result of the poll. + result: Poll_Result, + + // Implementation specifics, private. + _impl: _Poll `fmt:"-"`, +} + +/* +Retrieves and preps an operation to poll a socket without executing it. + +Executing can then be done with the `exec` procedure. + +The timeout is calculated from the time when this procedure was called, +not from when it's executed. + +Any user data can be set on the returned operation's `user_data` field. + +Inputs: +- socket: Socket to poll that is *associated with the event loop* +- event: Event to poll for +- cb: The callback to be called when the operation finishes, `Operation.poll` will contain results +- timeout: Optional timeout for the operation, the callback will receive a `.Timeout` result after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +prep_poll :: #force_inline proc( + socket: Any_Socket, + event: Poll_Event, + cb: Callback, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation { + op := _prep(l, cb, .Poll) + op.poll.socket = socket + op.poll.event = event + if timeout > 0 { + op.poll.expires = time.time_add(now(), timeout) + } + return op +} + +/* +Poll a socket for readiness. + +NOTE: this is provided to help with "legacy" APIs that require polling behavior. +If you can avoid it and use the other procs in this package, do so. + +Any user data can be set on the returned operation's `user_data` field. +Polymorphic variants for type safe user data are available under `poll_poly`, `poll_poly2`, and `poll_poly3`. + +Inputs: +- socket: Socket to poll that is *associated with the event loop* +- event: Event to poll for +- cb: The callback to be called when the operation finishes, `Operation.poll` will contain results +- timeout: Optional timeout for the operation, the callback will receive a `.Timeout` result after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +poll :: #force_inline proc( + socket: Any_Socket, + event: Poll_Event, + cb: Callback, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation { + op := prep_poll(socket, event, cb, timeout, l) + exec(op) + return op +} + +/* +Poll a socket for readiness. + +NOTE: this is provided to help with "legacy" APIs that require polling behavior. +If you can avoid it and use the other procs in this package, do so. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- socket: Socket to poll that is *associated with the event loop* +- event: Event to poll for +- p: User data, the callback will receive this as its second argument +- cb: The callback to be called when the operation finishes, `Operation.poll` will contain results +- timeout: Optional timeout for the operation, the callback will receive a `.Timeout` result after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +poll_poly :: #force_inline proc( + socket: Any_Socket, + event: Poll_Event, + p: $T, + cb: $C/proc(op: ^Operation, p: T), + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_poll(socket, event, _poly_cb(C, T), timeout, l) + _put_user_data(op, cb, p) + exec(op) + + return op +} + +/* +Poll a socket for readiness. + +NOTE: this is provided to help with "legacy" APIs that require polling behavior. +If you can avoid it and use the other procs in this package, do so. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- socket: Socket to poll that is *associated with the event loop* +- event: Event to poll for +- p: User data, the callback will receive this as its second argument +- p2: User data, the callback will receive this as its third argument +- cb: The callback to be called when the operation finishes, `Operation.poll` will contain results +- timeout: Optional timeout for the operation, the callback will receive a `.Timeout` result after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +poll_poly2 :: #force_inline proc( + socket: Any_Socket, + event: Poll_Event, + p: $T, p2: $T2, + cb: $C/proc(op: ^Operation, p: T, p2: T2), + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) + size_of(T2) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_poll(socket, event, _poly_cb2(C, T, T2), timeout, l) + _put_user_data2(op, cb, p, p2) + exec(op) + + return op +} + +/* +Poll a socket for readiness. + +NOTE: this is provided to help with "legacy" APIs that require polling behavior. +If you can avoid it and use the other procs in this package, do so. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- socket: Socket to poll that is *associated with the event loop* +- event: Event to poll for +- p: User data, the callback will receive this as its second argument +- p2: User data, the callback will receive this as its third argument +- p3: User data, the callback will receive this as its fourth argument +- cb: The callback to be called when the operation finishes, `Operation.poll` will contain results +- timeout: Optional timeout for the operation, the callback will receive a `.Timeout` result after that duration +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +poll_poly3 :: #force_inline proc( + socket: Any_Socket, + event: Poll_Event, + p: $T, p2: $T2, p3: $T3, + cb: $C/proc(op: ^Operation, p: T, p2: T2, p3: T3), + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) + size_of(T2) + size_of(T3) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_poll(socket, event, _poly_cb3(C, T, T2, T3), timeout, l) + _put_user_data3(op, cb, p, p2, p3) + exec(op) + + return op +} + +SEND_ENTIRE_FILE :: -1 + +Send_File_Error :: union #shared_nil { + FS_Error, + TCP_Send_Error, +} + +Send_File :: struct { + // The TCP socket to send the file over. + socket: TCP_Socket, + // The handle of the regular file to send. + file: Handle, + // When this operation expires and should be timed out. + expires: time.Time, + // The starting offset within the file. + offset: int, + // Number of bytes to send. If set to SEND_ENTIRE_FILE, the file size is retrieved + // automatically and this field is updated to reflect the full size. + nbytes: int, + // If true, the callback is triggered periodically as data is sent. + // The callback will continue to be called until `sent == nbytes` or an error occurs. + progress_updates: bool, + + // Total number of bytes (so far if `progress_updates` is true). + sent: int, + // An error, if it occurred. Can be a filesystem or networking error. + err: Send_File_Error, + + // Implementation specifics, private. + _impl: _Send_File `fmt:"-"`, +} + +/* +Retrieves and preps an operation to send a file over a socket without executing it. + +Executing can then be done with the `exec` procedure. + +This uses high-performance zero-copy system calls where available. +Note: This is emulated on NetBSD and OpenBSD (stat -> mmap -> send) as they lack a native sendfile implementation. + +Any user data can be set on the returned operation's `user_data` field. + +Inputs: +- socket: The destination TCP socket +- file: The source file handle +- cb: The callback to be called when data is sent (if `progress_updates` is true) or the operation completes +- offset: Byte offset to start reading from the file +- nbytes: Total bytes to send (use SEND_ENTIRE_FILE for the whole file) +- progress_updates: If true, the callback fires multiple times to report progress, `sent == nbytes` means te operation completed +- timeout: Optional timeout for the operation +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the final callback is called +*/ +prep_sendfile :: #force_inline proc( + socket: TCP_Socket, + file: Handle, + cb: Callback, + offset: int = 0, + nbytes: int = SEND_ENTIRE_FILE, + progress_updates := false, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation { + assert(offset >= 0) + assert(nbytes == SEND_ENTIRE_FILE || nbytes > 0) + op := _prep(l, cb, .Send_File) + op.sendfile.socket = socket + op.sendfile.file = file + if timeout > 0 { + op.sendfile.expires = time.time_add(now(), timeout) + } + op.sendfile.offset = offset + op.sendfile.nbytes = nbytes + op.sendfile.progress_updates = progress_updates + return op +} + +/* +Sends a file over a TCP socket. + +This uses high-performance zero-copy system calls where available. +Note: This is emulated on NetBSD and OpenBSD (stat -> mmap -> send) as they lack a native sendfile implementation. + +Any user data can be set on the returned operation's `user_data` field. +Polymorphic variants for type safe user data are available under `sendfile_poly`, `sendfile_poly2`, and `sendfile_poly3`. + +Inputs: +- socket: The destination TCP socket +- file: The source file handle +- cb: The callback to be called when data is sent (if `progress_updates` is true) or the operation completes +- offset: Byte offset to start reading from the file +- nbytes: Total bytes to send (use SEND_ENTIRE_FILE for the whole file) +- progress_updates: If true, the callback fires multiple times to report progress, `sent == nbytes` means te operation completed +- timeout: Optional timeout for the operation +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the final callback is called +*/ +sendfile :: #force_inline proc( + socket: TCP_Socket, + file: Handle, + cb: Callback, + offset: int = 0, + nbytes: int = SEND_ENTIRE_FILE, + progress_updates := false, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation { + op := prep_sendfile(socket, file, cb, offset, nbytes, progress_updates, timeout, l) + exec(op) + return op +} + +/* +Sends a file over a TCP socket. + +This uses high-performance zero-copy system calls where available. +Note: This is emulated on NetBSD and OpenBSD (stat -> mmap -> send) as they lack a native sendfile implementation. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- socket: The destination TCP socket +- file: The source file handle +- p: User data, the callback will receive this as it's second argument +- cb: The callback to be called when data is sent (if `progress_updates` is true) or the operation completes +- offset: Byte offset to start reading from the file +- nbytes: Total bytes to send (use SEND_ENTIRE_FILE for the whole file) +- progress_updates: If true, the callback fires multiple times to report progress, `sent == nbytes` means te operation completed +- timeout: Optional timeout for the operation +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the final callback is called +*/ +sendfile_poly :: #force_inline proc( + socket: TCP_Socket, + file: Handle, + p: $T, + cb: $C/proc(op: ^Operation, p: T), + offset: int = 0, + nbytes: int = SEND_ENTIRE_FILE, + progress_updates := false, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_sendfile(socket, file, _poly_cb(C, T), offset, nbytes, progress_updates, timeout, l) + _put_user_data(op, cb, p) + exec(op) + + return op +} + +/* +Sends a file over a TCP socket. + +This uses high-performance zero-copy system calls where available. +Note: This is emulated on NetBSD and OpenBSD (stat -> mmap -> send) as they lack a native sendfile implementation. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- socket: The destination TCP socket +- file: The source file handle +- p: User data, the callback will receive this as it's second argument +- p2: User data, the callback will receive this as it's third argument +- cb: The callback to be called when data is sent (if `progress_updates` is true) or the operation completes +- offset: Byte offset to start reading from the file +- nbytes: Total bytes to send (use SEND_ENTIRE_FILE for the whole file) +- progress_updates: If true, the callback fires multiple times to report progress, `sent == nbytes` means te operation completed +- timeout: Optional timeout for the operation +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the final callback is called +*/ +sendfile_poly2 :: #force_inline proc( + socket: TCP_Socket, + file: Handle, + p: $T, p2: $T2, + cb: $C/proc(op: ^Operation, p: T, p2: T2), + offset: int = 0, + nbytes: int = SEND_ENTIRE_FILE, + progress_updates := false, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) + size_of(T2) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_sendfile(socket, file, _poly_cb2(C, T, T2), offset, nbytes, progress_updates, timeout, l) + _put_user_data2(op, cb, p, p2) + exec(op) + + return op +} + +/* +Sends a file over a TCP socket. + +This uses high-performance zero-copy system calls where available. +Note: This is emulated on NetBSD and OpenBSD (stat -> mmap -> send) as they lack a native sendfile implementation. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- socket: The destination TCP socket +- file: The source file handle +- p: User data, the callback will receive this as it's second argument +- p2: User data, the callback will receive this as it's third argument +- p3: User data, the callback will receive this as it's fourth argument +- cb: The callback to be called when data is sent (if `progress_updates` is true) or the operation completes +- offset: Byte offset to start reading from the file +- nbytes: Total bytes to send (use SEND_ENTIRE_FILE for the whole file) +- progress_updates: If true, the callback fires multiple times to report progress, `sent == nbytes` means te operation completed +- timeout: Optional timeout for the operation +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the final callback is called +*/ +sendfile_poly3 :: #force_inline proc( + socket: TCP_Socket, + file: Handle, + p: $T, p2: $T2, p3: $T3, + cb: $C/proc(op: ^Operation, p: T, p2: T2, p3: T3), + offset: int = 0, + nbytes: int = SEND_ENTIRE_FILE, + progress_updates := false, + timeout: time.Duration = NO_TIMEOUT, + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) + size_of(T2) + size_of(T3) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_sendfile(socket, file, _poly_cb3(C, T, T2, T3), offset, nbytes, progress_updates, timeout, l) + _put_user_data3(op, cb, p, p2, p3) + exec(op) + + return op +} + +/* +File permission bit-set. + +This type represents POSIX-style file permissions, split into user, group, +and other categories, each with read, write, and execute flags. +*/ +Permissions :: distinct bit_set[Permission_Flag; u32] + +Permission_Flag :: enum u32 { + Execute_Other = 0, + Write_Other = 1, + Read_Other = 2, + + Execute_Group = 3, + Write_Group = 4, + Read_Group = 5, + + Execute_User = 6, + Write_User = 7, + Read_User = 8, +} + +// Convenience permission sets. +Permissions_Execute_All :: Permissions{.Execute_User, .Execute_Group, .Execute_Other} +Permissions_Write_All :: Permissions{.Write_User, .Write_Group, .Write_Other} +Permissions_Read_All :: Permissions{.Read_User, .Read_Group, .Read_Other} + +// Read and write permissions for user, group, and others. +Permissions_Read_Write_All :: Permissions_Read_All + Permissions_Write_All + +// Read, write, and execute permissions for user, group, and others. +Permissions_All :: Permissions_Read_All + Permissions_Write_All + Permissions_Execute_All + +// Default permissions used when creating a file (read and write for everyone). +Permissions_Default_File :: Permissions_Read_All + Permissions_Write_All + +// Default permissions used when creating a directory (read, write, and execute for everyone). +Permissions_Default_Directory :: Permissions_Read_All + Permissions_Write_All + Permissions_Execute_All + +File_Flags :: bit_set[File_Flag; int] + +File_Flag :: enum { + // Open for reading. + Read, + // Open for writing. + Write, + // Append writes to the end of the file. + Append, + // Create the file if it does not exist. + Create, + // Fail if the file already exists (used with Create). + Excl, + Sync, + // Truncate the file on open. + Trunc, +} + +Open :: struct { + // Base directory the path is relative to. + dir: Handle, + // Path to the file. + path: string, + // File open mode flags. + mode: File_Flags, + // Permissions used if the file is created. + perm: Permissions, + + // The opened file handle. + handle: Handle, + // An error, if it occurred. + err: FS_Error, + + // Implementation specifics, private. + _impl: _Open `fmt:"-"`, +} + +// Sentinel handle representing the current/present working directory. +CWD :: _CWD + +/* +Retrieves and preps an operation to open a file without executing it. + +Executing can then be done with the `exec` procedure. + +Any user data can be set on the returned operation's `user_data` field. + +Inputs: +- path: Path to the file, if not absolute: relative from `dir` +- cb: The callback to be called when the operation finishes, `Operation.open` will contain results +- mode: File open mode flags, defaults to read-only +- perm: Permissions to use when creating a file, defaults to read+write for everybody +- dir: Directory that `path` is relative from (if it is relative), defaults to the current working directory +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +prep_open :: #force_inline proc( + path: string, + cb: Callback, + mode: File_Flags = {.Read}, + perm: Permissions = Permissions_Default_File, + dir: Handle = CWD, + l: ^Event_Loop = nil, +) -> ^Operation { + op := _prep(l, cb, .Open) + op.open.path = path + op.open.mode = mode + op.open.perm = perm + op.open.dir = dir + return op +} + +/* +Opens a file and associates it with the event loop. + +Any user data can be set on the returned operation's `user_data` field. +Polymorphic variants for type safe user data are available under `open_poly`, `open_poly2`, and `open_poly3`. + +Inputs: +- path: Path to the file, if not absolute: relative from `dir` +- cb: The callback to be called when the operation finishes, `Operation.open` will contain results +- mode: File open mode flags, defaults to read-only +- perm: Permissions to use when creating a file, defaults to read+write for everybody +- dir: Directory that `path` is relative from (if it is relative), defaults to the current working directory +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +open :: #force_inline proc( + path: string, + cb: Callback, + mode: File_Flags = {.Read}, + perm: Permissions = Permissions_Default_File, + dir: Handle = CWD, + l: ^Event_Loop = nil, +) -> ^Operation { + op := prep_open(path, cb, mode, perm, dir, l) + exec(op) + return op +} + +/* +Opens a file and associates it with the event loop. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- path: Path to the file, if not absolute: relative from `dir` +- p: User data, the callback will receive this as its second argument +- cb: The callback to be called when the operation finishes, `Operation.open` will contain results +- mode: File open mode flags, defaults to read-only +- perm: Permissions to use when creating a file, defaults to read+write for everybody +- dir: Directory that `path` is relative from (if it is relative), defaults to the current working directory +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +open_poly :: #force_inline proc( + path: string, + p: $T, + cb: $C/proc(op: ^Operation, p: T), + mode: File_Flags = {.Read}, + perm: Permissions = Permissions_Default_File, + dir: Handle = CWD, + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_open(path, _poly_cb(C, T), mode, perm, dir, l) + _put_user_data(op, cb, p) + exec(op) + + return op +} + +/* +Opens a file and associates it with the event loop. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- path: Path to the file, if not absolute: relative from `dir` +- p: User data, the callback will receive this as its second argument +- p2: User data, the callback will receive this as its third argument +- cb: The callback to be called when the operation finishes, `Operation.open` will contain results +- mode: File open mode flags, defaults to read-only +- perm: Permissions to use when creating a file, defaults to read+write for everybody +- dir: Directory that `path` is relative from (if it is relative), defaults to the current working directory +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +open_poly2 :: #force_inline proc( + path: string, + p: $T, p2: $T2, + cb: $C/proc(op: ^Operation, p: T, p2: T2), + mode: File_Flags = {.Read}, + perm: Permissions = Permissions_Default_File, + dir: Handle = CWD, + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) + size_of(T2) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_open(path, _poly_cb2(C, T, T2), mode, perm, dir, l) + _put_user_data2(op, cb, p, p2) + exec(op) + + return op +} + +/* +Asynchronously opens a file and associates it with the event loop. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- path: Path to the file, if not absolute: relative from `dir` +- p: User data, the callback will receive this as its second argument +- p2: User data, the callback will receive this as its third argument +- p3: User data, the callback will receive this as its fourth argument +- cb: The callback to be called when the operation finishes, `Operation.open` will contain results +- mode: File open mode flags, defaults to read-only +- perm: Permissions to use when creating a file, defaults to read+write for everybody +- dir: Directory that `path` is relative from (if it is relative), defaults to the current working directory +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +open_poly3 :: #force_inline proc( + path: string, + p: $T, p2: $T2, p3: $T3, + cb: $C/proc(op: ^Operation, p: T, p2: T2, p3: T3), + mode: File_Flags = {.Read}, + perm: Permissions = Permissions_Default_File, + dir: Handle = CWD, + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) + size_of(T2) + size_of(T3) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_open(path, _poly_cb3(C, T, T2, T3), mode, perm, dir, l) + _put_user_data3(op, cb, p, p2, p3) + exec(op) + + return op +} + +File_Type :: enum { + // File type could not be determined. + Undetermined, + // Regular file. + Regular, + // Directory. + Directory, + // Symbolic link. + Symlink, + // Pipe or socket. + Pipe_Or_Socket, + // Character or block device. + Device, +} + +Stat :: struct { + // Handle to stat. + handle: Handle, + + // The type of the file. + type: File_Type, + // Size of the file in bytes. + size: i64 `fmt:"M"`, + + // An error, if it occurred. + err: FS_Error, + + // Implementation specifics, private. + _impl: _Stat `fmt:"-"`, +} + +/* +Retrieves and preps an operation to stat a handle without executing it. + +Executing can then be done with the `exec` procedure. + +Any user data can be set on the returned operation's `user_data` field. + +Inputs: +- handle: Handle to retrieve stat +- cb: The callback to be called when the operation finishes, `Operation.stat` will contain results +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +prep_stat :: #force_inline proc( + handle: Handle, + cb: Callback, + l: ^Event_Loop = nil, +) -> ^Operation { + op := _prep(l, cb, .Stat) + op.stat.handle = handle + return op +} + +/* +Stats a handle. + +Any user data can be set on the returned operation's `user_data` field. +Polymorphic variants for type safe user data are available under `stat_poly`, `stat_poly2`, and `stat_poly3`. + +Inputs: +- handle: Handle to retrieve status information for +- cb: The callback to be called when the operation finishes, `Operation.stat` will contain results +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +stat :: #force_inline proc( + handle: Handle, + cb: Callback, + l: ^Event_Loop = nil, +) -> ^Operation { + op := prep_stat(handle, cb, l) + exec(op) + return op +} + +/* +Stats a handle. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- handle: Handle to retrieve status information for +- p: User data, the callback will receive this as its second argument +- cb: The callback to be called when the operation finishes, `Operation.stat` will contain results +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +stat_poly :: #force_inline proc( + handle: Handle, + p: $T, + cb: $C/proc(op: ^Operation, p: T), + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_stat(handle, _poly_cb(C, T), l) + _put_user_data(op, cb, p) + exec(op) + + return op +} + +/* +Stats a handle. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- handle: Handle to retrieve status information for +- p: User data, the callback will receive this as its second argument +- p2: User data, the callback will receive this as its third argument +- cb: The callback to be called when the operation finishes, `Operation.stat` will contain results +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +stat_poly2 :: #force_inline proc( + handle: Handle, + p: $T, p2: $T2, + cb: $C/proc(op: ^Operation, p: T, p2: T2), + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) + size_of(T2) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_stat(handle, _poly_cb2(C, T, T2), l) + _put_user_data2(op, cb, p, p2) + exec(op) + + return op +} + +/* +Stats a handle. + +This procedure uses polymorphism for type safe user data up to a certain size. + +Inputs: +- handle: Handle to retrieve status information for +- p: User data, the callback will receive this as its second argument +- p2: User data, the callback will receive this as its third argument +- p3: User data, the callback will receive this as its fourth argument +- cb: The callback to be called when the operation finishes, `Operation.stat` will contain results +- l: Event loop to associate the operation with, defaults to the current thread's loop + +Returns: A non-nil pointer to the operation, alive until the callback is called +*/ +stat_poly3 :: #force_inline proc( + handle: Handle, + p: $T, p2: $T2, p3: $T3, + cb: $C/proc(op: ^Operation, p: T, p2: T2, p3: T3), + l: ^Event_Loop = nil, +) -> ^Operation where size_of(T) + size_of(T2) + size_of(T3) <= size_of(rawptr) * MAX_USER_ARGUMENTS { + + op := prep_stat(handle, _poly_cb3(C, T, T2, T3), l) + _put_user_data3(op, cb, p, p2, p3) + exec(op) + + return op +} + +_prep :: proc(l: ^Event_Loop, cb: Callback, type: Operation_Type) -> ^Operation { + assert(cb != nil) + assert(type != .None) + l := l + if l == nil { l = _current_thread_event_loop() } + operation := pool.get(&l.operation_pool) + operation.l = l + operation.type = type + operation.cb = cb + return operation +} + +_poly_cb :: #force_inline proc($C: typeid, $T: typeid) -> proc(^Operation) { + return proc(op: ^Operation) { + ptr := uintptr(&op.user_data) + cb := intrinsics.unaligned_load((^C)(rawptr(ptr))) + p := intrinsics.unaligned_load((^T)(rawptr(ptr + size_of(C)))) + cb(op, p) + } +} + +_poly_cb2 :: #force_inline proc($C: typeid, $T: typeid, $T2: typeid) -> proc(^Operation) { + return proc(op: ^Operation) { + ptr := uintptr(&op.user_data) + cb := intrinsics.unaligned_load((^C) (rawptr(ptr))) + p := intrinsics.unaligned_load((^T) (rawptr(ptr + size_of(C)))) + p2 := intrinsics.unaligned_load((^T2)(rawptr(ptr + size_of(C) + size_of(T)))) + cb(op, p, p2) + } +} + +_poly_cb3 :: #force_inline proc($C: typeid, $T: typeid, $T2: typeid, $T3: typeid) -> proc(^Operation) { + return proc(op: ^Operation) { + ptr := uintptr(&op.user_data) + cb := intrinsics.unaligned_load((^C) (rawptr(ptr))) + p := intrinsics.unaligned_load((^T) (rawptr(ptr + size_of(C)))) + p2 := intrinsics.unaligned_load((^T2)(rawptr(ptr + size_of(C) + size_of(T)))) + p3 := intrinsics.unaligned_load((^T3)(rawptr(ptr + size_of(C) + size_of(T) + size_of(T2)))) + cb(op, p, p2, p3) + } +} + +_put_user_data :: #force_inline proc(op: ^Operation, cb: $C, p: $T) { + ptr := uintptr(&op.user_data) + intrinsics.unaligned_store((^C)(rawptr(ptr)), cb) + intrinsics.unaligned_store((^T)(rawptr(ptr + size_of(cb))), p) +} + +_put_user_data2 :: #force_inline proc(op: ^Operation, cb: $C, p: $T, p2: $T2) { + ptr := uintptr(&op.user_data) + intrinsics.unaligned_store((^C) (rawptr(ptr)), cb) + intrinsics.unaligned_store((^T) (rawptr(ptr + size_of(cb))), p) + intrinsics.unaligned_store((^T2)(rawptr(ptr + size_of(cb) + size_of(p))), p2) +} + +_put_user_data3 :: #force_inline proc(op: ^Operation, cb: $C, p: $T, p2: $T2, p3: $T3) { + ptr := uintptr(&op.user_data) + intrinsics.unaligned_store((^C) (rawptr(ptr)), cb) + intrinsics.unaligned_store((^T) (rawptr(ptr + size_of(cb))), p) + intrinsics.unaligned_store((^T2)(rawptr(ptr + size_of(cb) + size_of(p))), p2) + intrinsics.unaligned_store((^T3)(rawptr(ptr + size_of(cb) + size_of(p) + size_of(p2))), p3) +} diff --git a/core/net/addr.odin b/core/net/addr.odin index fad0eddc4..d29b46b65 100644 --- a/core/net/addr.odin +++ b/core/net/addr.odin @@ -1,4 +1,3 @@ -#+build windows, linux, darwin, freebsd package net /* @@ -22,7 +21,6 @@ package net import "core:strconv" import "core:strings" -import "core:fmt" /* Expects an IPv4 address with no leading or trailing whitespace: @@ -473,13 +471,20 @@ join_port :: proc(address_or_host: string, port: int, allocator := context.alloc addr := parse_address(addr_or_host) if addr == nil { // hostname - fmt.sbprintf(&b, "%v:%v", addr_or_host, port) + strings.write_string(&b, addr_or_host) + strings.write_string(&b, ":") + strings.write_int(&b, port) } else { switch _ in addr { case IP4_Address: - fmt.sbprintf(&b, "%v:%v", address_to_string(addr), port) + strings.write_string(&b, address_to_string(addr)) + strings.write_string(&b, ":") + strings.write_int(&b, port) case IP6_Address: - fmt.sbprintf(&b, "[%v]:%v", address_to_string(addr), port) + strings.write_string(&b, "[") + strings.write_string(&b, address_to_string(addr)) + strings.write_string(&b, "]:") + strings.write_int(&b, port) } } return strings.to_string(b) @@ -495,8 +500,8 @@ map_to_ip6 :: proc(addr: Address) -> Address { addr4 := addr.(IP4_Address) addr4_u16 := transmute([2]u16be) addr4 addr6: IP6_Address - addr6[4] = 0xffff - copy(addr6[5:], addr4_u16[:]) + addr6[5] = 0xffff + copy(addr6[6:], addr4_u16[:]) return addr6 } @@ -509,7 +514,13 @@ address_to_string :: proc(addr: Address, allocator := context.temp_allocator) -> b := strings.builder_make(allocator) switch v in addr { case IP4_Address: - fmt.sbprintf(&b, "%v.%v.%v.%v", v[0], v[1], v[2], v[3]) + strings.write_uint(&b, uint(v[0])) + strings.write_byte(&b, '.') + strings.write_uint(&b, uint(v[1])) + strings.write_byte(&b, '.') + strings.write_uint(&b, uint(v[2])) + strings.write_byte(&b, '.') + strings.write_uint(&b, uint(v[3])) case IP6_Address: // First find the longest run of zeroes. Zero_Run :: struct { @@ -563,25 +574,33 @@ address_to_string :: proc(addr: Address, allocator := context.temp_allocator) -> for val, i in v { if best.start == i || best.end == i { // For the left and right side of the best zero run, print a `:`. - fmt.sbprint(&b, ":") + strings.write_string(&b, ":") } else if i < best.start { /* If we haven't made it to the best run yet, print the digit. Make sure we only print a `:` after the digit if it's not immediately followed by the run's own leftmost `:`. */ - fmt.sbprintf(&b, "%x", val) + + buf: [32]byte + str := strconv.write_bits(buf[:], u64(val), 16, false, size_of(val), strconv.digits, {}) + strings.write_string(&b, str) + if i < best.start - 1 { - fmt.sbprintf(&b, ":") + strings.write_string(&b, ":") } } else if i > best.end { /* If there are any digits after the zero run, print them. But don't print the `:` at the end of the IP number. */ - fmt.sbprintf(&b, "%x", val) + + buf: [32]byte + str := strconv.write_bits(buf[:], u64(val), 16, false, size_of(val), strconv.digits, {}) + strings.write_string(&b, str) + if i != 7 { - fmt.sbprintf(&b, ":") + strings.write_string(&b, ":") } } } @@ -598,8 +617,15 @@ endpoint_to_string :: proc(ep: Endpoint, allocator := context.temp_allocator) -> s := address_to_string(ep.address, context.temp_allocator) b := strings.builder_make(allocator) switch a in ep.address { - case IP4_Address: fmt.sbprintf(&b, "%v:%v", s, ep.port) - case IP6_Address: fmt.sbprintf(&b, "[%v]:%v", s, ep.port) + case IP4_Address: + strings.write_string(&b, s) + strings.write_string(&b, ":") + strings.write_int(&b, ep.port) + case IP6_Address: + strings.write_string(&b, "[") + strings.write_string(&b, s) + strings.write_string(&b, "]:") + strings.write_int(&b, ep.port) } return strings.to_string(b) } diff --git a/core/net/common.odin b/core/net/common.odin index 70523050f..2758a7359 100644 --- a/core/net/common.odin +++ b/core/net/common.odin @@ -1,4 +1,3 @@ -#+build windows, linux, darwin, freebsd package net /* @@ -91,6 +90,7 @@ Parse_Endpoint_Error :: enum u32 { Resolve_Error :: enum u32 { None = 0, Unable_To_Resolve = 1, + Allocation_Failure, } DNS_Error :: enum u32 { @@ -144,11 +144,11 @@ Address :: union {IP4_Address, IP6_Address} IP4_Loopback :: IP4_Address{127, 0, 0, 1} IP6_Loopback :: IP6_Address{0, 0, 0, 0, 0, 0, 0, 1} -IP4_Any := IP4_Address{} -IP6_Any := IP6_Address{} +IP4_Any :: IP4_Address{} +IP6_Any :: IP6_Address{} -IP4_mDNS_Broadcast := Endpoint{address=IP4_Address{224, 0, 0, 251}, port=5353} -IP6_mDNS_Broadcast := Endpoint{address=IP6_Address{65282, 0, 0, 0, 0, 0, 0, 251}, port = 5353} +IP4_mDNS_Broadcast :: Endpoint{address=IP4_Address{224, 0, 0, 251}, port=5353} +IP6_mDNS_Broadcast :: Endpoint{address=IP6_Address{65282, 0, 0, 0, 0, 0, 0, 251}, port = 5353} Endpoint :: struct { address: Address, diff --git a/core/net/dns.odin b/core/net/dns.odin index 540991fe7..983f82681 100644 --- a/core/net/dns.odin +++ b/core/net/dns.odin @@ -1,4 +1,3 @@ -#+build windows, linux, darwin, freebsd package net /* @@ -22,13 +21,18 @@ package net Haesbaert: Security fixes */ -@(require) import "base:runtime" +@(require) +import "base:runtime" + +import "core:bufio" +import "core:io" +import "core:math/rand" import "core:mem" import "core:strings" import "core:time" -import "core:os" -import "core:math/rand" -@(require) import "core:sync" + +@(require) +import "core:sync" dns_config_initialized: sync.Once when ODIN_OS == .Windows { @@ -42,20 +46,12 @@ when ODIN_OS == .Windows { hosts_file = "/etc/hosts", } } else { - #panic("Please add a configuration for this OS.") + DEFAULT_DNS_CONFIGURATION :: DNS_Configuration{} } -/* - Replaces environment placeholders in `dns_configuration`. Only necessary on Windows. - Is automatically called, once, by `get_dns_records_*`. -*/ -@(private) init_dns_configuration :: proc() { when ODIN_OS == .Windows { - runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() - val := os.replace_environment_placeholders(dns_configuration.hosts_file, context.temp_allocator) - copy(dns_configuration.hosts_file_buf[:], val) - dns_configuration.hosts_file = string(dns_configuration.hosts_file_buf[:len(val)]) + _init_dns_configuration() } } @@ -178,9 +174,7 @@ resolve_ip6 :: proc(hostname_and_maybe_port: string) -> (ep6: Endpoint, err: Net See `destroy_records`. */ get_dns_records_from_os :: proc(hostname: string, type: DNS_Record_Type, allocator := context.allocator) -> (records: []DNS_Record, err: DNS_Error) { - when ODIN_OS == .Windows { - sync.once_do(&dns_config_initialized, init_dns_configuration) - } + init_dns_configuration() return _get_dns_records_os(hostname, type, allocator) } @@ -196,51 +190,14 @@ get_dns_records_from_os :: proc(hostname: string, type: DNS_Record_Type, allocat See `destroy_records`. */ get_dns_records_from_nameservers :: proc(hostname: string, type: DNS_Record_Type, name_servers: []Endpoint, host_overrides: []DNS_Record, allocator := context.allocator) -> (records: []DNS_Record, err: DNS_Error) { - when ODIN_OS == .Windows { - sync.once_do(&dns_config_initialized, init_dns_configuration) - } + init_dns_configuration() context.allocator = allocator - if type != .SRV { - // NOTE(tetra): 'hostname' can contain underscores when querying SRV records - ok := validate_hostname(hostname) - if !ok { - return nil, .Invalid_Hostname_Error - } - } + id := u16be(rand.uint32()) + dns_packet_buf: [DNS_PACKET_MIN_LEN]byte = --- + dns_packet := make_dns_packet(dns_packet_buf[:], id, hostname, type) or_return - hdr := DNS_Header{ - id = u16be(rand.uint32()), - is_response = false, - opcode = 0, - is_authoritative = false, - is_truncated = false, - is_recursion_desired = true, - is_recursion_available = false, - response_code = DNS_Response_Code.No_Error, - } - - id, bits := pack_dns_header(hdr) - dns_hdr := [6]u16be{} - dns_hdr[0] = id - dns_hdr[1] = bits - dns_hdr[2] = 1 - - dns_query := [2]u16be{ u16be(type), 1 } - - output := [(size_of(u16be) * 6) + NAME_MAX + (size_of(u16be) * 2)]u8{} - b := strings.builder_from_slice(output[:]) - - strings.write_bytes(&b, mem.slice_data_cast([]u8, dns_hdr[:])) - ok := encode_hostname(&b, hostname) - if !ok { - return nil, .Invalid_Hostname_Error - } - strings.write_bytes(&b, mem.slice_data_cast([]u8, dns_query[:])) - - dns_packet := output[:strings.builder_len(b)] - - dns_response_buf := [4096]u8{} + dns_response_buf: [4096]u8 = --- dns_response: []u8 for name_server in name_servers { conn, sock_err := make_unbound_udp_socket(family_from_endpoint(name_server)) @@ -283,6 +240,42 @@ get_dns_records_from_nameservers :: proc(hostname: string, type: DNS_Record_Type return } +DNS_PACKET_MIN_LEN :: (size_of(u16be) * 6) + NAME_MAX + (size_of(u16be) * 2) + +make_dns_packet :: proc(buf: []byte, id: u16be, hostname: string, type: DNS_Record_Type) -> (packet: []byte, err: DNS_Error) { + assert(len(buf) >= DNS_PACKET_MIN_LEN) + + hdr := DNS_Header{ + id = id, + is_response = false, + opcode = 0, + is_authoritative = false, + is_truncated = false, + is_recursion_desired = true, + is_recursion_available = false, + response_code = DNS_Response_Code.No_Error, + } + + _, bits := pack_dns_header(hdr) + dns_hdr := [6]u16be{} + dns_hdr[0] = id + dns_hdr[1] = bits + dns_hdr[2] = 1 + + dns_query := [2]u16be{ u16be(type), 1 } + + b := strings.builder_from_slice(buf[:]) + + strings.write_bytes(&b, mem.slice_data_cast([]u8, dns_hdr[:])) + ok := encode_hostname(&b, hostname) + if !ok { + return nil, .Invalid_Hostname_Error + } + strings.write_bytes(&b, mem.slice_data_cast([]u8, dns_query[:])) + + return buf[:strings.builder_len(b)], nil +} + // `records` slice is also destroyed. destroy_dns_records :: proc(records: []DNS_Record, allocator := context.allocator) { context.allocator = allocator @@ -364,13 +357,8 @@ unpack_dns_header :: proc(id: u16be, bits: u16be) -> (hdr: DNS_Header) { return hdr } -load_resolv_conf :: proc(resolv_conf_path: string, allocator := context.allocator) -> (name_servers: []Endpoint, ok: bool) { - context.allocator = allocator - - res := os.read_entire_file_from_filename(resolv_conf_path) or_return - defer delete(res) - resolv_str := string(res) - +parse_resolv_conf :: proc(resolv_str: string, allocator := context.allocator) -> (name_servers: []Endpoint) { + resolv_str := resolv_str id_str := "nameserver" id_len := len(id_str) @@ -401,41 +389,51 @@ load_resolv_conf :: proc(resolv_conf_path: string, allocator := context.allocato append(&_name_servers, endpoint) } - return _name_servers[:], true + return _name_servers[:] } -load_hosts :: proc(hosts_file_path: string, allocator := context.allocator) -> (hosts: []DNS_Host_Entry, ok: bool) { - context.allocator = allocator +parse_hosts :: proc(stream: io.Stream, allocator := context.allocator) -> (hosts: []DNS_Host_Entry, ok: bool) { + s := bufio.scanner_init(&{}, stream, allocator) + defer bufio.scanner_destroy(s) - res := os.read_entire_file_from_filename(hosts_file_path, allocator) or_return - defer delete(res) + resize(&s.buf, 256) - _hosts := make([dynamic]DNS_Host_Entry, 0, allocator) - hosts_str := string(res) - for line in strings.split_lines_iterator(&hosts_str) { - if len(line) == 0 || line[0] == '#' { - continue + _hosts: [dynamic]DNS_Host_Entry + _hosts.allocator = allocator + defer if !ok { + for host in _hosts { + delete(host.name, allocator) } + delete(_hosts) + } - splits := strings.fields(line) - defer delete(splits) + for bufio.scanner_scan(s) { + line := bufio.scanner_text(s) - (len(splits) >= 2) or_continue + line, _, _ = strings.partition(line, "#") + (len(line) > 0) or_continue + + ip_str := strings.fields_iterator(&line) or_continue - ip_str := splits[0] addr := parse_address(ip_str) - if addr == nil { - continue - } + (addr != nil) or_continue - for hostname in splits[1:] { - if len(hostname) != 0 { - append(&_hosts, DNS_Host_Entry{hostname, addr}) - } + for hostname in strings.fields_iterator(&line) { + (len(hostname) > 0) or_continue + + clone, alloc_err := strings.clone(hostname, allocator) + if alloc_err != nil { return } + + _, alloc_err = append(&_hosts, DNS_Host_Entry{clone, addr}) + if alloc_err != nil { return } } } - return _hosts[:], true + if bufio.scanner_error(s) != nil { return } + + hosts = _hosts[:] + ok = true + return } // www.google.com -> 3www6google3com0 @@ -594,7 +592,7 @@ decode_hostname :: proc(packet: []u8, start_idx: int, allocator := context.alloc // Uses RFC 952 & RFC 1123 validate_hostname :: proc(hostname: string) -> (ok: bool) { - if len(hostname) > 255 || len(hostname) == 0 { + if len(hostname) > NAME_MAX || len(hostname) == 0 { return } @@ -604,7 +602,7 @@ validate_hostname :: proc(hostname: string) -> (ok: bool) { _hostname := hostname for label in strings.split_iterator(&_hostname, ".") { - if len(label) > 63 || len(label) == 0 { + if len(label) > LABEL_MAX || len(label) == 0 { return } @@ -868,4 +866,4 @@ parse_response :: proc(response: []u8, filter: DNS_Record_Type = nil, allocator xid = hdr.id return _records[:], xid, true -} \ No newline at end of file +} diff --git a/core/net/dns_os.odin b/core/net/dns_os.odin new file mode 100644 index 000000000..19db0097a --- /dev/null +++ b/core/net/dns_os.odin @@ -0,0 +1,24 @@ +#+build darwin, freebsd, openbsd, netbsd, linux, windows, wasi +#+private +package net + +import "core:os" + +load_resolv_conf :: proc(resolv_conf_path: string, allocator := context.allocator) -> (name_servers: []Endpoint, ok: bool) { + context.allocator = allocator + + res := os.read_entire_file_from_filename(resolv_conf_path) or_return + defer delete(res) + resolv_str := string(res) + + return parse_resolv_conf(resolv_str), true +} + +load_hosts :: proc(hosts_file_path: string, allocator := context.allocator) -> (hosts: []DNS_Host_Entry, ok: bool) { + hosts_file, err := os.open(hosts_file_path) + if err != nil { return } + defer os.close(hosts_file) + + return parse_hosts(os.stream_from_handle(hosts_file), allocator) +} + diff --git a/core/net/dns_others.odin b/core/net/dns_others.odin new file mode 100644 index 000000000..842e833aa --- /dev/null +++ b/core/net/dns_others.odin @@ -0,0 +1,12 @@ +#+build !windows +#+build !linux +#+build !darwin +#+build !freebsd +#+build !netbsd +#+build !openbsd +package net + +@(private) +_get_dns_records_os :: proc(hostname: string, type: DNS_Record_Type, allocator := context.allocator) -> (records: []DNS_Record, err: DNS_Error) { + return +} diff --git a/core/net/dns_unix.odin b/core/net/dns_unix.odin index fbc1909cd..be95b8341 100644 --- a/core/net/dns_unix.odin +++ b/core/net/dns_unix.odin @@ -1,4 +1,4 @@ -#+build linux, darwin, freebsd +#+build linux, darwin, freebsd, openbsd, netbsd package net /* Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures. @@ -42,14 +42,19 @@ _get_dns_records_os :: proc(hostname: string, type: DNS_Record_Type, allocator : } hosts, hosts_ok := load_hosts(dns_configuration.hosts_file) - defer delete(hosts) if !hosts_ok { return nil, .Invalid_Hosts_Config_Error } + defer { + for h in hosts { + delete(h.name) + } + delete(hosts) + } host_overrides := make([dynamic]DNS_Record) for host in hosts { - if strings.compare(host.name, hostname) != 0 { + if host.name != hostname { continue } @@ -79,4 +84,4 @@ _get_dns_records_os :: proc(hostname: string, type: DNS_Record_Type, allocator : } return get_dns_records_from_nameservers(hostname, type, name_servers, host_overrides[:]) -} \ No newline at end of file +} diff --git a/core/net/dns_windows.odin b/core/net/dns_windows.odin index b1e7da97d..393df5fa7 100644 --- a/core/net/dns_windows.odin +++ b/core/net/dns_windows.odin @@ -20,11 +20,29 @@ package net Feoramund: FreeBSD platform code */ -import "core:strings" +import "base:runtime" + import "core:mem" +import "core:os" +import "core:strings" +import "core:sync" import win "core:sys/windows" +/* + Replaces environment placeholders in `dns_configuration`. Only necessary on Windows. + Is automatically called, once, by `get_dns_records_*`. +*/ +@(private) +_init_dns_configuration :: proc() { + sync.once_do(&dns_config_initialized, proc() { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() + val := os.replace_environment_placeholders(dns_configuration.hosts_file, context.temp_allocator) + copy(dns_configuration.hosts_file_buf[:], val) + dns_configuration.hosts_file = string(dns_configuration.hosts_file_buf[:len(val)]) + }) +} + @(private) _get_dns_records_os :: proc(hostname: string, type: DNS_Record_Type, allocator := context.allocator) -> (records: []DNS_Record, err: DNS_Error) { context.allocator = allocator @@ -171,4 +189,4 @@ _get_dns_records_os :: proc(hostname: string, type: DNS_Record_Type, allocator : records = recs[:] return -} \ No newline at end of file +} diff --git a/core/net/errors.odin b/core/net/errors.odin index 4853327b0..28153375c 100644 --- a/core/net/errors.odin +++ b/core/net/errors.odin @@ -139,6 +139,11 @@ Accept_Error :: enum i32 { Unknown, } +Recv_Error :: union #shared_nil { + TCP_Recv_Error, + UDP_Recv_Error, +} + TCP_Recv_Error :: enum i32 { None, // No network connection, or the network stack is not initialized. @@ -149,7 +154,8 @@ TCP_Recv_Error :: enum i32 { Invalid_Argument, // The socket is not connected. Not_Connected, - // Connection was closed/broken/shutdown while receiving data. + // Connection was closed due to an error or shutdown. + // NOTE: a graceful close is indicated by a `0, nil` (0 bytes received and no error) return. Connection_Closed, // Timed out before being able to receive any data. Timeout, @@ -170,7 +176,8 @@ UDP_Recv_Error :: enum i32 { Insufficient_Resources, // Invalid socket or buffer given. Invalid_Argument, - // "Connection" was refused by remote, or closed/broken/shutdown while receiving data. + // "Connection" was refused, or closed due to an error. + // NOTE: a graceful close is indicated by a `0, nil` (0 bytes received and no error) return. Connection_Refused, // Timed out before being able to receive any data. Timeout, @@ -185,6 +192,11 @@ UDP_Recv_Error :: enum i32 { Unknown, } +Send_Error :: union #shared_nil { + TCP_Send_Error, + UDP_Send_Error, +} + TCP_Send_Error :: enum i32 { None, // No network connection, or the network stack is not initialized. @@ -193,7 +205,7 @@ TCP_Send_Error :: enum i32 { Insufficient_Resources, // Invalid socket or buffer given. Invalid_Argument, - // Connection was closed/broken/shutdown while receiving data. + // Connection was closed/broken/shutdown while sending data. Connection_Closed, // The socket is not connected. Not_Connected, diff --git a/core/net/errors_others.odin b/core/net/errors_others.odin index b80ead79c..3a752d58e 100644 --- a/core/net/errors_others.odin +++ b/core/net/errors_others.odin @@ -2,6 +2,8 @@ #+build !linux #+build !freebsd #+build !windows +#+build !netbsd +#+build !openbsd package net @(private="file", thread_local) @@ -18,10 +20,3 @@ _last_platform_error_string :: proc() -> string { _set_last_platform_error :: proc(err: i32) { _last_error = err } - -Parse_Endpoint_Error :: enum u32 { - None = 0, - Bad_Port = 1, - Bad_Address, - Bad_Hostname, -} \ No newline at end of file diff --git a/core/net/errors_darwin.odin b/core/net/errors_posix.odin similarity index 99% rename from core/net/errors_darwin.odin rename to core/net/errors_posix.odin index a35e96bc0..b59cbc30b 100644 --- a/core/net/errors_darwin.odin +++ b/core/net/errors_posix.odin @@ -1,4 +1,4 @@ -#+build darwin +#+build darwin, netbsd, openbsd package net /* diff --git a/core/net/errors_windows.odin b/core/net/errors_windows.odin index 83c45ee7f..6d3724c82 100644 --- a/core/net/errors_windows.odin +++ b/core/net/errors_windows.odin @@ -63,7 +63,7 @@ _dial_error :: proc() -> Dial_Error { return .Already_Connecting case .WSAEADDRNOTAVAIL, .WSAEAFNOSUPPORT, .WSAEFAULT, .WSAENOTSOCK, .WSAEINPROGRESS, .WSAEINVAL: return .Invalid_Argument - case .WSAECONNREFUSED: + case .WSAECONNREFUSED, .CONNECTION_REFUSED: return .Refused case .WSAEISCONN: return .Already_Connected @@ -122,7 +122,7 @@ _accept_error :: proc() -> Accept_Error { return .Aborted case .WSAEFAULT, .WSAEINPROGRESS, .WSAENOTSOCK: return .Invalid_Argument - case .WSAEINTR: + case .WSAEINTR, .OPERATION_ABORTED: return .Interrupted case .WSAEINVAL: return .Not_Listening diff --git a/core/net/interface_others.odin b/core/net/interface_others.odin new file mode 100644 index 000000000..9a8a141df --- /dev/null +++ b/core/net/interface_others.odin @@ -0,0 +1,11 @@ +#+build !darwin +#+build !linux +#+build !freebsd +#+build !windows +#+build !netbsd +#+build !openbsd +package net + +_enumerate_interfaces :: proc(allocator := context.allocator) -> (interfaces: []Network_Interface, err: Interfaces_Error) { + return +} diff --git a/core/net/interface_darwin.odin b/core/net/interface_posix.odin similarity index 79% rename from core/net/interface_darwin.odin rename to core/net/interface_posix.odin index f18cff995..202951b29 100644 --- a/core/net/interface_darwin.odin +++ b/core/net/interface_posix.odin @@ -1,4 +1,4 @@ -#+build darwin +#+build darwin, openbsd, netbsd package net /* @@ -117,32 +117,47 @@ IF_Flag :: enum u32 { BROADCAST, DEBUG, LOOPBACK, - POINTTOPOINT, - NOTRAILERS, - RUNNING, - NOARP, - PROMISC, - ALLMULTI, - OACTIVE, - SIMPLEX, - LINK0, - LINK1, - LINK2, - MULTICAST, + // NOTE: different order on other BSDs but we don't even need these. + // POINTTOPOINT, + // NOTRAILERS, + // RUNNING, + // NOARP, + // PROMISC, + // ALLMULTI, + // OACTIVE, + // SIMPLEX, + // LINK0, + // LINK1, + // LINK2, + // MULTICAST, } @(private) IF_Flags :: bit_set[IF_Flag; u32] -@(private) -ifaddrs :: struct { - next: ^ifaddrs, - name: cstring, - flags: IF_Flags, - addr: ^posix.sockaddr, - netmask: ^posix.sockaddr, - dstaddr: ^posix.sockaddr, - data: rawptr, +when ODIN_OS == .Darwin || ODIN_OS == .OpenBSD { + @(private) + ifaddrs :: struct { + next: ^ifaddrs, + name: cstring, + flags: IF_Flags, + addr: ^posix.sockaddr, + netmask: ^posix.sockaddr, + dstaddr: ^posix.sockaddr, + data: rawptr, + } +} else when ODIN_OS == .NetBSD { + @(private) + ifaddrs :: struct { + next: ^ifaddrs, + name: cstring, + flags: IF_Flags, + addr: ^posix.sockaddr, + netmask: ^posix.sockaddr, + dstaddr: ^posix.sockaddr, + data: rawptr, + addrflags: u32, + } } @(private) diff --git a/core/net/socket.odin b/core/net/socket.odin index 7e96ba2b2..e2f96e2f3 100644 --- a/core/net/socket.odin +++ b/core/net/socket.odin @@ -1,4 +1,3 @@ -#+build windows, linux, darwin, freebsd package net /* @@ -20,6 +19,35 @@ package net Feoramund: FreeBSD platform code */ +Socket_Option :: enum i32 { + Broadcast = i32(_SOCKET_OPTION_BROADCAST), + Reuse_Address = i32(_SOCKET_OPTION_REUSE_ADDRESS), + Keep_Alive = i32(_SOCKET_OPTION_KEEP_ALIVE), + Out_Of_Bounds_Data_Inline = i32(_SOCKET_OPTION_OUT_OF_BOUNDS_DATA_INLINE), + Linger = i32(_SOCKET_OPTION_LINGER), + Receive_Buffer_Size = i32(_SOCKET_OPTION_RECEIVE_BUFFER_SIZE), + Send_Buffer_Size = i32(_SOCKET_OPTION_SEND_BUFFER_SIZE), + Receive_Timeout = i32(_SOCKET_OPTION_RECEIVE_TIMEOUT), + Send_Timeout = i32(_SOCKET_OPTION_SEND_TIMEOUT), + + TCP_Nodelay = i32(_SOCKET_OPTION_TCP_NODELAY), + + Use_Loopback = i32(_SOCKET_OPTION_USE_LOOPBACK), + Reuse_Port = i32(_SOCKET_OPTION_REUSE_PORT), + No_SIGPIPE_From_EPIPE = i32(_SOCKET_OPTION_NO_SIGPIPE_FROM_EPIPE), + Reuse_Port_Load_Balancing = i32(_SOCKET_OPTION_REUSE_PORT_LOAD_BALANCING), + + Exclusive_Addr_Use = i32(_SOCKET_OPTION_EXCLUSIVE_ADDR_USE), + Conditional_Accept = i32(_SOCKET_OPTION_CONDITIONAL_ACCEPT), + Dont_Linger = i32(_SOCKET_OPTION_DONT_LINGER), +} + +Shutdown_Manner :: enum i32 { + Receive = i32(_SHUTDOWN_MANNER_RECEIVE), + Send = i32(_SHUTDOWN_MANNER_SEND), + Both = i32(_SHUTDOWN_MANNER_BOTH), +} + any_socket_to_socket :: proc "contextless" (socket: Any_Socket) -> Socket { switch s in socket { case TCP_Socket: return Socket(s) @@ -193,21 +221,36 @@ close :: proc(socket: Any_Socket) { _close(socket) } +/* + Receive data into a buffer from a TCP socket. + + If no error occurs, `recv_tcp` returns the number of bytes received and `buf` will contain this data received. + If the connection has been gracefully closed, the return value is `0, nil` (0 bytes read and no error). +*/ recv_tcp :: proc(socket: TCP_Socket, buf: []byte) -> (bytes_read: int, err: TCP_Recv_Error) { return _recv_tcp(socket, buf) } +/* + Receive data into a buffer from a UDP socket. + + If no error occurs, `recv_udp` returns the number of bytes received and `buf` will contain this data received. + If the "connection" has been gracefully closed, the return value is `0, nil` (0 bytes read and no error). +*/ recv_udp :: proc(socket: UDP_Socket, buf: []byte) -> (bytes_read: int, remote_endpoint: Endpoint, err: UDP_Recv_Error) { return _recv_udp(socket, buf) } /* - Receive data from into a buffer from any socket. + Receive data into a buffer from any socket. Note: `remote_endpoint` parameter is non-nil only if the socket type is UDP. On TCP sockets it will always return `nil`. - Errors that can be returned: `TCP_Recv_Error`, or `UDP_Recv_Error` + Errors that can be returned: `TCP_Recv_Error`, or `UDP_Recv_Error`. + + If no error occurs, `recv_any` returns the number of bytes received and `buf` will contain this data received. + If the connection has been gracefully closed, the return value is `0, nil, nil` (0 bytes read and no error). */ recv_any :: proc(socket: Any_Socket, buf: []byte) -> ( bytes_read: int, diff --git a/core/net/socket_freebsd.odin b/core/net/socket_freebsd.odin index 504229e73..bd600fd99 100644 --- a/core/net/socket_freebsd.odin +++ b/core/net/socket_freebsd.odin @@ -20,45 +20,35 @@ package net Feoramund: FreeBSD platform code */ -import "core:c" import "core:sys/freebsd" import "core:time" Fd :: freebsd.Fd -Socket_Option :: enum c.int { - // TODO: Test and implement more socket options. - // DEBUG - Reuse_Address = cast(c.int)freebsd.Socket_Option.REUSEADDR, - Keep_Alive = cast(c.int)freebsd.Socket_Option.KEEPALIVE, - // DONTROUTE - Broadcast = cast(c.int)freebsd.Socket_Option.BROADCAST, - Use_Loopback = cast(c.int)freebsd.Socket_Option.USELOOPBACK, - Linger = cast(c.int)freebsd.Socket_Option.LINGER, - Out_Of_Bounds_Data_Inline = cast(c.int)freebsd.Socket_Option.OOBINLINE, - Reuse_Port = cast(c.int)freebsd.Socket_Option.REUSEPORT, - // TIMESTAMP - No_SIGPIPE_From_EPIPE = cast(c.int)freebsd.Socket_Option.NOSIGPIPE, - // ACCEPTFILTER - // BINTIME - // NO_OFFLOAD - // NO_DDP - Reuse_Port_Load_Balancing = cast(c.int)freebsd.Socket_Option.REUSEPORT_LB, - // RERROR +_SOCKET_OPTION_BROADCAST :: freebsd.Socket_Option.BROADCAST +_SOCKET_OPTION_REUSE_ADDRESS :: freebsd.Socket_Option.REUSEADDR +_SOCKET_OPTION_KEEP_ALIVE :: freebsd.Socket_Option.KEEPALIVE +_SOCKET_OPTION_OUT_OF_BOUNDS_DATA_INLINE :: freebsd.Socket_Option.OOBINLINE +_SOCKET_OPTION_LINGER :: freebsd.Socket_Option.LINGER +_SOCKET_OPTION_RECEIVE_BUFFER_SIZE :: freebsd.Socket_Option.RCVBUF +_SOCKET_OPTION_SEND_BUFFER_SIZE :: freebsd.Socket_Option.SNDBUF +_SOCKET_OPTION_RECEIVE_TIMEOUT :: freebsd.Socket_Option.RCVTIMEO +_SOCKET_OPTION_SEND_TIMEOUT :: freebsd.Socket_Option.SNDTIMEO - Send_Buffer_Size = cast(c.int)freebsd.Socket_Option.SNDBUF, - Receive_Buffer_Size = cast(c.int)freebsd.Socket_Option.RCVBUF, - // SNDLOWAT - // RCVLOWAT - Send_Timeout = cast(c.int)freebsd.Socket_Option.SNDTIMEO, - Receive_Timeout = cast(c.int)freebsd.Socket_Option.RCVTIMEO, -} +_SOCKET_OPTION_TCP_NODELAY :: -1 -Shutdown_Manner :: enum c.int { - Receive = cast(c.int)freebsd.Shutdown_Method.RD, - Send = cast(c.int)freebsd.Shutdown_Method.WR, - Both = cast(c.int)freebsd.Shutdown_Method.RDWR, -} +_SOCKET_OPTION_USE_LOOPBACK :: freebsd.Socket_Option.USELOOPBACK +_SOCKET_OPTION_REUSE_PORT :: freebsd.Socket_Option.REUSEPORT +_SOCKET_OPTION_NO_SIGPIPE_FROM_EPIPE :: freebsd.Socket_Option.NOSIGPIPE +_SOCKET_OPTION_REUSE_PORT_LOAD_BALANCING :: freebsd.Socket_Option.REUSEPORT_LB + +_SOCKET_OPTION_EXCLUSIVE_ADDR_USE :: -1 +_SOCKET_OPTION_CONDITIONAL_ACCEPT :: -1 +_SOCKET_OPTION_DONT_LINGER :: -1 + +_SHUTDOWN_MANNER_RECEIVE :: freebsd.Shutdown_Method.RD +_SHUTDOWN_MANNER_SEND :: freebsd.Shutdown_Method.WR +_SHUTDOWN_MANNER_BOTH :: freebsd.Shutdown_Method.RDWR @(private) _create_socket :: proc(family: Address_Family, protocol: Socket_Protocol) -> (socket: Any_Socket, err: Create_Socket_Error) { @@ -272,7 +262,7 @@ _set_option :: proc(socket: Any_Socket, option: Socket_Option, value: any, loc : ptr: rawptr len: freebsd.socklen_t - switch option { + #partial switch option { case .Reuse_Address, .Keep_Alive, @@ -344,7 +334,7 @@ _set_option :: proc(socket: Any_Socket, option: Socket_Option, value: any, loc : ptr = &int_value len = size_of(int_value) case: - unimplemented("set_option() option not yet implemented", loc) + return .Invalid_Option } real_socket := any_socket_to_socket(socket) @@ -391,7 +381,7 @@ _endpoint_to_sockaddr :: proc(ep: Endpoint) -> (sockaddr: freebsd.Socket_Address } case IP6_Address: (cast(^freebsd.Socket_Address_Internet6)(&sockaddr))^ = { - len = size_of(freebsd.Socket_Address_Internet), + len = size_of(freebsd.Socket_Address_Internet6), family = .INET6, port = cast(freebsd.in_port_t)ep.port, addr = transmute(freebsd.IP6_Address)addr, diff --git a/core/net/socket_linux.odin b/core/net/socket_linux.odin index 9719ff61b..8348ce114 100644 --- a/core/net/socket_linux.odin +++ b/core/net/socket_linux.odin @@ -21,28 +21,33 @@ package net Feoramund: FreeBSD platform code */ -import "core:c" import "core:time" import "core:sys/linux" -Socket_Option :: enum c.int { - Reuse_Address = c.int(linux.Socket_Option.REUSEADDR), - Keep_Alive = c.int(linux.Socket_Option.KEEPALIVE), - Out_Of_Bounds_Data_Inline = c.int(linux.Socket_Option.OOBINLINE), - TCP_Nodelay = c.int(linux.Socket_TCP_Option.NODELAY), - Linger = c.int(linux.Socket_Option.LINGER), - Receive_Buffer_Size = c.int(linux.Socket_Option.RCVBUF), - Send_Buffer_Size = c.int(linux.Socket_Option.SNDBUF), - Receive_Timeout = c.int(linux.Socket_Option.RCVTIMEO), - Send_Timeout = c.int(linux.Socket_Option.SNDTIMEO), - Broadcast = c.int(linux.Socket_Option.BROADCAST), -} +_SOCKET_OPTION_BROADCAST :: linux.Socket_Option.BROADCAST +_SOCKET_OPTION_REUSE_ADDRESS :: linux.Socket_Option.REUSEADDR +_SOCKET_OPTION_KEEP_ALIVE :: linux.Socket_Option.KEEPALIVE +_SOCKET_OPTION_OUT_OF_BOUNDS_DATA_INLINE :: linux.Socket_Option.OOBINLINE +_SOCKET_OPTION_LINGER :: linux.Socket_Option.LINGER +_SOCKET_OPTION_RECEIVE_BUFFER_SIZE :: linux.Socket_Option.RCVBUF +_SOCKET_OPTION_SEND_BUFFER_SIZE :: linux.Socket_Option.SNDBUF +_SOCKET_OPTION_RECEIVE_TIMEOUT :: linux.Socket_Option.RCVTIMEO +_SOCKET_OPTION_SEND_TIMEOUT :: linux.Socket_Option.SNDTIMEO -Shutdown_Manner :: enum c.int { - Receive = c.int(linux.Shutdown_How.RD), - Send = c.int(linux.Shutdown_How.WR), - Both = c.int(linux.Shutdown_How.RDWR), -} +_SOCKET_OPTION_TCP_NODELAY :: linux.Socket_TCP_Option.NODELAY + +_SOCKET_OPTION_USE_LOOPBACK :: -1 +_SOCKET_OPTION_REUSE_PORT :: -1 +_SOCKET_OPTION_NO_SIGPIPE_FROM_EPIPE :: -1 +_SOCKET_OPTION_REUSE_PORT_LOAD_BALANCING :: -1 + +_SOCKET_OPTION_EXCLUSIVE_ADDR_USE :: -1 +_SOCKET_OPTION_CONDITIONAL_ACCEPT :: -1 +_SOCKET_OPTION_DONT_LINGER :: -1 + +_SHUTDOWN_MANNER_RECEIVE :: linux.Shutdown_How.RD +_SHUTDOWN_MANNER_SEND :: linux.Shutdown_How.WR +_SHUTDOWN_MANNER_BOTH :: linux.Shutdown_How.RDWR // Wrappers and unwrappers for system-native types @@ -347,7 +352,7 @@ _set_option :: proc(sock: Any_Socket, option: Socket_Option, value: any, loc := int_value: i32 timeval_value: linux.Time_Val errno: linux.Errno - switch option { + #partial switch option { case .Reuse_Address, .Keep_Alive, @@ -400,10 +405,14 @@ _set_option :: proc(sock: Any_Socket, option: Socket_Option, value: any, loc := panic("set_option() value must be an integer here", loc) } errno = linux.setsockopt(os_sock, level, int(option), &int_value) + case: + return .Invalid_Socket } + if errno != .NONE { return _socket_option_error(errno) } + return nil } diff --git a/core/net/socket_others.odin b/core/net/socket_others.odin new file mode 100644 index 000000000..61cf7240e --- /dev/null +++ b/core/net/socket_others.odin @@ -0,0 +1,105 @@ +#+build !darwin +#+build !linux +#+build !freebsd +#+build !windows +#+build !netbsd +#+build !openbsd +#+private +package net + +_SOCKET_OPTION_BROADCAST :: -1 +_SOCKET_OPTION_REUSE_ADDRESS :: -1 +_SOCKET_OPTION_KEEP_ALIVE :: -1 +_SOCKET_OPTION_OUT_OF_BOUNDS_DATA_INLINE :: -1 +_SOCKET_OPTION_LINGER :: -1 +_SOCKET_OPTION_RECEIVE_BUFFER_SIZE :: -1 +_SOCKET_OPTION_SEND_BUFFER_SIZE :: -1 +_SOCKET_OPTION_RECEIVE_TIMEOUT :: -1 +_SOCKET_OPTION_SEND_TIMEOUT :: -1 + +_SOCKET_OPTION_TCP_NODELAY :: -1 + +_SOCKET_OPTION_USE_LOOPBACK :: -1 +_SOCKET_OPTION_REUSE_PORT :: -1 +_SOCKET_OPTION_NO_SIGPIPE_FROM_EPIPE :: -1 +_SOCKET_OPTION_REUSE_PORT_LOAD_BALANCING :: -1 + +_SOCKET_OPTION_EXCLUSIVE_ADDR_USE :: -1 +_SOCKET_OPTION_CONDITIONAL_ACCEPT :: -1 +_SOCKET_OPTION_DONT_LINGER :: -1 + +_SHUTDOWN_MANNER_RECEIVE :: -1 +_SHUTDOWN_MANNER_SEND :: -1 +_SHUTDOWN_MANNER_BOTH :: -1 + +_dial_tcp_from_endpoint :: proc(endpoint: Endpoint, options := DEFAULT_TCP_OPTIONS) -> (sock: TCP_Socket, err: Network_Error) { + err = Create_Socket_Error.Network_Unreachable + return +} + +_create_socket :: proc(family: Address_Family, protocol: Socket_Protocol) -> (sock: Any_Socket, err: Create_Socket_Error) { + err = .Network_Unreachable + return +} + +_bind :: proc(skt: Any_Socket, ep: Endpoint) -> (err: Bind_Error) { + err = .Network_Unreachable + return +} + +_listen_tcp :: proc(interface_endpoint: Endpoint, backlog := 1000) -> (skt: TCP_Socket, err: Network_Error) { + err = Create_Socket_Error.Network_Unreachable + return +} + +_bound_endpoint :: proc(sock: Any_Socket) -> (ep: Endpoint, err: Socket_Info_Error) { + err = .Network_Unreachable + return +} + +_peer_endpoint :: proc(sock: Any_Socket) -> (ep: Endpoint, err: Socket_Info_Error) { + err = .Network_Unreachable + return +} + +_accept_tcp :: proc(sock: TCP_Socket, options := DEFAULT_TCP_OPTIONS) -> (client: TCP_Socket, source: Endpoint, err: Accept_Error) { + err = .Network_Unreachable + return +} + +_close :: proc(skt: Any_Socket) { +} + +_recv_tcp :: proc(skt: TCP_Socket, buf: []byte) -> (bytes_read: int, err: TCP_Recv_Error) { + err = .Network_Unreachable + return +} + +_recv_udp :: proc(skt: UDP_Socket, buf: []byte) -> (bytes_read: int, remote_endpoint: Endpoint, err: UDP_Recv_Error) { + err = .Network_Unreachable + return +} + +_send_tcp :: proc(skt: TCP_Socket, buf: []byte) -> (bytes_written: int, err: TCP_Send_Error) { + err = .Network_Unreachable + return +} + +_send_udp :: proc(skt: UDP_Socket, buf: []byte, to: Endpoint) -> (bytes_written: int, err: UDP_Send_Error) { + err = .Network_Unreachable + return +} + +_shutdown :: proc(skt: Any_Socket, manner: Shutdown_Manner) -> (err: Shutdown_Error) { + err = .Network_Unreachable + return +} + +_set_option :: proc(s: Any_Socket, option: Socket_Option, value: any, loc := #caller_location) -> Socket_Option_Error { + return .Network_Unreachable +} + +_set_blocking :: proc(socket: Any_Socket, should_block: bool) -> (err: Set_Blocking_Error) { + err = .Network_Unreachable + return +} diff --git a/core/net/socket_darwin.odin b/core/net/socket_posix.odin similarity index 90% rename from core/net/socket_darwin.odin rename to core/net/socket_posix.odin index 8e01eb4a8..243b2e06f 100644 --- a/core/net/socket_darwin.odin +++ b/core/net/socket_posix.odin @@ -1,4 +1,4 @@ -#+build darwin +#+build darwin, netbsd, openbsd package net /* @@ -20,28 +20,33 @@ package net Feoramund: FreeBSD platform code */ -import "core:c" import "core:sys/posix" import "core:time" -Socket_Option :: enum c.int { - Broadcast = c.int(posix.Sock_Option.BROADCAST), - Reuse_Address = c.int(posix.Sock_Option.REUSEADDR), - Keep_Alive = c.int(posix.Sock_Option.KEEPALIVE), - Out_Of_Bounds_Data_Inline = c.int(posix.Sock_Option.OOBINLINE), - TCP_Nodelay = c.int(posix.TCP_NODELAY), - Linger = c.int(posix.Sock_Option.LINGER), - Receive_Buffer_Size = c.int(posix.Sock_Option.RCVBUF), - Send_Buffer_Size = c.int(posix.Sock_Option.SNDBUF), - Receive_Timeout = c.int(posix.Sock_Option.RCVTIMEO), - Send_Timeout = c.int(posix.Sock_Option.SNDTIMEO), -} +_SOCKET_OPTION_BROADCAST :: posix.Sock_Option.BROADCAST +_SOCKET_OPTION_REUSE_ADDRESS :: posix.Sock_Option.REUSEADDR +_SOCKET_OPTION_KEEP_ALIVE :: posix.Sock_Option.KEEPALIVE +_SOCKET_OPTION_OUT_OF_BOUNDS_DATA_INLINE :: posix.Sock_Option.OOBINLINE +_SOCKET_OPTION_LINGER :: posix.Sock_Option.LINGER +_SOCKET_OPTION_RECEIVE_BUFFER_SIZE :: posix.Sock_Option.RCVBUF +_SOCKET_OPTION_SEND_BUFFER_SIZE :: posix.Sock_Option.SNDBUF +_SOCKET_OPTION_RECEIVE_TIMEOUT :: posix.Sock_Option.RCVTIMEO +_SOCKET_OPTION_SEND_TIMEOUT :: posix.Sock_Option.SNDTIMEO -Shutdown_Manner :: enum c.int { - Receive = c.int(posix.SHUT_RD), - Send = c.int(posix.SHUT_WR), - Both = c.int(posix.SHUT_RDWR), -} +_SOCKET_OPTION_TCP_NODELAY :: posix.TCP_NODELAY + +_SOCKET_OPTION_USE_LOOPBACK :: -1 +_SOCKET_OPTION_REUSE_PORT :: -1 +_SOCKET_OPTION_NO_SIGPIPE_FROM_EPIPE :: -1 +_SOCKET_OPTION_REUSE_PORT_LOAD_BALANCING :: -1 + +_SOCKET_OPTION_EXCLUSIVE_ADDR_USE :: -1 +_SOCKET_OPTION_CONDITIONAL_ACCEPT :: -1 +_SOCKET_OPTION_DONT_LINGER :: -1 + +_SHUTDOWN_MANNER_RECEIVE :: posix.SHUT_RD +_SHUTDOWN_MANNER_SEND :: posix.SHUT_WR +_SHUTDOWN_MANNER_BOTH :: posix.SHUT_RDWR @(private) _create_socket :: proc(family: Address_Family, protocol: Socket_Protocol) -> (socket: Any_Socket, err: Create_Socket_Error) { @@ -273,7 +278,7 @@ _set_option :: proc(s: Any_Socket, option: Socket_Option, value: any, loc := #ca ptr: rawptr len: posix.socklen_t - switch option { + #partial switch option { case .Broadcast, .Reuse_Address, @@ -327,6 +332,8 @@ _set_option :: proc(s: Any_Socket, option: Socket_Option, value: any, loc := #ca } ptr = &int_value len = size_of(int_value) + case: + return .Invalid_Option } skt := any_socket_to_socket(s) diff --git a/core/net/socket_windows.odin b/core/net/socket_windows.odin index 6dd2f0458..4eea0ea65 100644 --- a/core/net/socket_windows.odin +++ b/core/net/socket_windows.odin @@ -24,59 +24,30 @@ import "core:c" import win "core:sys/windows" import "core:time" -Socket_Option :: enum c.int { - // bool: Whether the address that this socket is bound to can be reused by other sockets. - // This allows you to bypass the cooldown period if a program dies while the socket is bound. - Reuse_Address = win.SO_REUSEADDR, +_SOCKET_OPTION_BROADCAST :: win.SO_BROADCAST +_SOCKET_OPTION_REUSE_ADDRESS :: win.SO_REUSEADDR +_SOCKET_OPTION_KEEP_ALIVE :: win.SO_KEEPALIVE +_SOCKET_OPTION_OUT_OF_BOUNDS_DATA_INLINE :: win.SO_OOBINLINE +_SOCKET_OPTION_LINGER :: win.SO_LINGER +_SOCKET_OPTION_RECEIVE_BUFFER_SIZE :: win.SO_RCVBUF +_SOCKET_OPTION_SEND_BUFFER_SIZE :: win.SO_SNDBUF +_SOCKET_OPTION_RECEIVE_TIMEOUT :: win.SO_RCVTIMEO +_SOCKET_OPTION_SEND_TIMEOUT :: win.SO_SNDTIMEO - // bool: Whether other programs will be inhibited from binding the same endpoint as this socket. - Exclusive_Addr_Use = win.SO_EXCLUSIVEADDRUSE, +_SOCKET_OPTION_TCP_NODELAY :: win.TCP_NODELAY - // bool: When true, keepalive packets will be automatically be sent for this connection. TODO: verify this understanding - Keep_Alive = win.SO_KEEPALIVE, +_SOCKET_OPTION_USE_LOOPBACK :: -1 +_SOCKET_OPTION_REUSE_PORT :: -1 +_SOCKET_OPTION_NO_SIGPIPE_FROM_EPIPE :: -1 +_SOCKET_OPTION_REUSE_PORT_LOAD_BALANCING :: -1 - // bool: When true, client connections will immediately be sent a TCP/IP RST response, rather than being accepted. - Conditional_Accept = win.SO_CONDITIONAL_ACCEPT, +_SOCKET_OPTION_EXCLUSIVE_ADDR_USE :: win.SO_EXCLUSIVEADDRUSE +_SOCKET_OPTION_CONDITIONAL_ACCEPT :: win.SO_CONDITIONAL_ACCEPT +_SOCKET_OPTION_DONT_LINGER :: win.SO_DONTLINGER - // bool: If true, when the socket is closed, but data is still waiting to be sent, discard that data. - Dont_Linger = win.SO_DONTLINGER, - - // bool: When true, 'out-of-band' data sent over the socket will be read by a normal net.recv() call, the same as normal 'in-band' data. - Out_Of_Bounds_Data_Inline = win.SO_OOBINLINE, - - // bool: When true, disables send-coalescing, therefore reducing latency. - TCP_Nodelay = win.TCP_NODELAY, - - // win.LINGER: Customizes how long (if at all) the socket will remain open when there - // is some remaining data waiting to be sent, and net.close() is called. - Linger = win.SO_LINGER, - - // win.DWORD: The size, in bytes, of the OS-managed receive-buffer for this socket. - Receive_Buffer_Size = win.SO_RCVBUF, - - // win.DWORD: The size, in bytes, of the OS-managed send-buffer for this socket. - Send_Buffer_Size = win.SO_SNDBUF, - - // win.DWORD: For blocking sockets, the time in milliseconds to wait for incoming data to be received, before giving up and returning .Timeout. - // For non-blocking sockets, ignored. - // Use a value of zero to potentially wait forever. - Receive_Timeout = win.SO_RCVTIMEO, - - // win.DWORD: For blocking sockets, the time in milliseconds to wait for outgoing data to be sent, before giving up and returning .Timeout. - // For non-blocking sockets, ignored. - // Use a value of zero to potentially wait forever. - Send_Timeout = win.SO_SNDTIMEO, - - // bool: Allow sending to, receiving from, and binding to, a broadcast address. - Broadcast = win.SO_BROADCAST, -} - - -Shutdown_Manner :: enum c.int { - Receive = win.SD_RECEIVE, - Send = win.SD_SEND, - Both = win.SD_BOTH, -} +_SHUTDOWN_MANNER_RECEIVE :: win.SD_RECEIVE +_SHUTDOWN_MANNER_SEND :: win.SD_SEND +_SHUTDOWN_MANNER_BOTH :: win.SD_BOTH @(init, private) ensure_winsock_initialized :: proc "contextless" () { @@ -322,7 +293,7 @@ _set_option :: proc(s: Any_Socket, option: Socket_Option, value: any, loc := #ca ptr: rawptr len: c.int - switch option { + #partial switch option { case .Reuse_Address, .Exclusive_Addr_Use, @@ -383,6 +354,8 @@ _set_option :: proc(s: Any_Socket, option: Socket_Option, value: any, loc := #ca } ptr = &int_value len = size_of(int_value) + case: + return .Invalid_Option } socket := any_socket_to_socket(s) diff --git a/core/odin/ast/ast.odin b/core/odin/ast/ast.odin index a8c198476..ec22db434 100644 --- a/core/odin/ast/ast.odin +++ b/core/odin/ast/ast.odin @@ -17,6 +17,11 @@ Proc_Inlining :: enum u32 { No_Inline = 2, } +Proc_Tailing :: enum u32 { + None = 0, + Must_Tail = 1, +} + Proc_Calling_Convention_Extra :: enum i32 { Foreign_Block_Default, } @@ -147,6 +152,7 @@ Proc_Lit :: struct { body: ^Stmt, // nil when it represents a foreign procedure tags: Proc_Tags, inlining: Proc_Inlining, + tailing: Proc_Tailing, where_token: tokenizer.Token, where_clauses: []^Expr, } @@ -243,6 +249,7 @@ Matrix_Index_Expr :: struct { Call_Expr :: struct { using node: Expr, inlining: Proc_Inlining, + tailing: Proc_Tailing, expr: ^Expr, open: tokenizer.Pos, args: []^Expr, @@ -791,6 +798,7 @@ Struct_Type :: struct { is_raw_union: bool, is_no_copy: bool, is_all_or_none: bool, + is_simple: bool, fields: ^Field_List, name_count: int, } diff --git a/core/odin/parser/parser.odin b/core/odin/parser/parser.odin index f4beddcbb..a18942e6b 100644 --- a/core/odin/parser/parser.odin +++ b/core/odin/parser/parser.odin @@ -1528,8 +1528,8 @@ parse_stmt :: proc(p: ^Parser) -> ^ast.Stmt { es.expr = ce return es - case "force_inline", "force_no_inline": - expr := parse_inlining_operand(p, true, tag) + case "force_inline", "force_no_inline", "must_tail": + expr := parse_inlining_or_tailing_operand(p, true, tag) es := ast.new(ast.Expr_Stmt, expr.pos, expr) es.expr = expr return es @@ -2235,10 +2235,11 @@ parse_proc_type :: proc(p: ^Parser, tok: tokenizer.Token) -> ^ast.Proc_Type { return pt } -parse_inlining_operand :: proc(p: ^Parser, lhs: bool, tok: tokenizer.Token) -> ^ast.Expr { +parse_inlining_or_tailing_operand :: proc(p: ^Parser, lhs: bool, tok: tokenizer.Token) -> ^ast.Expr { expr := parse_unary_expr(p, lhs) pi := ast.Proc_Inlining.None + pt := ast.Proc_Tailing.None #partial switch tok.kind { case .Inline: pi = .Inline @@ -2250,6 +2251,8 @@ parse_inlining_operand :: proc(p: ^Parser, lhs: bool, tok: tokenizer.Token) -> ^ pi = .Inline case "force_no_inline": pi = .No_Inline + case "must_tail": + pt = .Must_Tail } } @@ -2259,13 +2262,19 @@ parse_inlining_operand :: proc(p: ^Parser, lhs: bool, tok: tokenizer.Token) -> ^ if e.inlining != .None && e.inlining != pi { error(p, expr.pos, "both 'inline' and 'no_inline' cannot be applied to a procedure literal") } + if pt != .None { + error(p, expr.pos, "'#must_tail' can only be applied to a procedure call, not the procedure literal") + } + e.inlining = pi + e.tailing = pt return expr case ^ast.Call_Expr: if e.inlining != .None && e.inlining != pi { error(p, expr.pos, "both 'inline' and 'no_inline' cannot be applied to a procedure call") } e.inlining = pi + e.tailing = pt return expr } } @@ -2451,7 +2460,7 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr { return rt case "force_inline", "force_no_inline": - return parse_inlining_operand(p, lhs, name) + return parse_inlining_or_tailing_operand(p, lhs, name) case: expr := parse_expr(p, lhs) end := expr.pos if expr != nil else end_pos(tok) @@ -2464,7 +2473,7 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr { case .Inline, .No_Inline: tok := advance_token(p) - return parse_inlining_operand(p, lhs, tok) + return parse_inlining_or_tailing_operand(p, lhs, tok) case .Proc: tok := expect_token(p, .Proc) @@ -2658,6 +2667,7 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr { is_raw_union: bool is_no_copy: bool is_all_or_none: bool + is_simple: bool fields: ^ast.Field_List name_count: int @@ -2686,6 +2696,11 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr { error(p, tag.pos, "duplicate struct tag '#%s'", tag.text) } is_all_or_none = true + case "simple": + if is_simple { + error(p, tag.pos, "duplicate struct tag '#%s'", tag.text) + } + is_simple = true case "align": if align != nil { error(p, tag.pos, "duplicate struct tag '#%s'", tag.text) @@ -2760,6 +2775,7 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr { st.is_raw_union = is_raw_union st.is_no_copy = is_no_copy st.is_all_or_none = is_all_or_none + st.is_simple = is_simple st.fields = fields st.name_count = name_count st.where_token = where_token diff --git a/core/os/os2/file.odin b/core/os/os2/file.odin index 9e7788c31..33446726e 100644 --- a/core/os/os2/file.odin +++ b/core/os/os2/file.odin @@ -67,7 +67,7 @@ File_Flag :: enum { Trunc, Sparse, Inheritable, - + Non_Blocking, Unbuffered_IO, } diff --git a/core/os/os2/file_linux.odin b/core/os/os2/file_linux.odin index fb25ca411..924251dfc 100644 --- a/core/os/os2/file_linux.odin +++ b/core/os/os2/file_linux.odin @@ -82,6 +82,7 @@ _open :: proc(name: string, flags: File_Flags, perm: Permissions) -> (f: ^File, if .Excl in flags { sys_flags += {.EXCL} } if .Sync in flags { sys_flags += {.DSYNC} } if .Trunc in flags { sys_flags += {.TRUNC} } + if .Non_Blocking in flags { sys_flags += {.NONBLOCK} } if .Inheritable in flags { sys_flags -= {.CLOEXEC} } fd, errno := linux.open(name_cstr, sys_flags, transmute(linux.Mode)transmute(u32)perm) diff --git a/core/os/os2/file_posix.odin b/core/os/os2/file_posix.odin index 874ec7c7d..cdc8e491a 100644 --- a/core/os/os2/file_posix.odin +++ b/core/os/os2/file_posix.odin @@ -61,12 +61,13 @@ _open :: proc(name: string, flags: File_Flags, perm: Permissions) -> (f: ^File, } } - if .Append in flags { sys_flags += {.APPEND} } - if .Create in flags { sys_flags += {.CREAT} } - if .Excl in flags { sys_flags += {.EXCL} } - if .Sync in flags { sys_flags += {.DSYNC} } - if .Trunc in flags { sys_flags += {.TRUNC} } - if .Inheritable in flags { sys_flags -= {.CLOEXEC} } + if .Append in flags { sys_flags += {.APPEND} } + if .Create in flags { sys_flags += {.CREAT} } + if .Excl in flags { sys_flags += {.EXCL} } + if .Sync in flags { sys_flags += {.DSYNC} } + if .Trunc in flags { sys_flags += {.TRUNC} } + if .Non_Blocking in flags { sys_flags += {.NONBLOCK} } + if .Inheritable in flags { sys_flags -= {.CLOEXEC} } temp_allocator := TEMP_ALLOCATOR_GUARD({}) cname := clone_to_cstring(name, temp_allocator) or_return diff --git a/core/os/os2/file_wasi.odin b/core/os/os2/file_wasi.odin index b60cce4be..fc37ef9f2 100644 --- a/core/os/os2/file_wasi.odin +++ b/core/os/os2/file_wasi.odin @@ -185,8 +185,9 @@ _open :: proc(name: string, flags: File_Flags, perm: Permissions) -> (f: ^File, if .Trunc in flags { oflags += {.TRUNC} } fdflags: wasi.fdflags_t - if .Append in flags { fdflags += {.APPEND} } - if .Sync in flags { fdflags += {.SYNC} } + if .Append in flags { fdflags += {.APPEND} } + if .Sync in flags { fdflags += {.SYNC} } + if .Non_Blocking in flags { fdflags += {.NONBLOCK} } // NOTE: rights are adjusted to what this package's functions might want to call. rights: wasi.rights_t diff --git a/core/os/os2/file_windows.odin b/core/os/os2/file_windows.odin index 9a969f07e..4df9398cc 100644 --- a/core/os/os2/file_windows.odin +++ b/core/os/os2/file_windows.odin @@ -126,7 +126,11 @@ _open_internal :: proc(name: string, flags: File_Flags, perm: Permissions) -> (h // NOTE(bill): Open has just asked to create a file in read-only mode. // If the file already exists, to make it akin to a *nix open call, // the call preserves the existing permissions. - h := win32.CreateFileW(path, access, share_mode, &sa, win32.TRUNCATE_EXISTING, win32.FILE_ATTRIBUTE_NORMAL, nil) + nix_attrs := win32.FILE_ATTRIBUTE_NORMAL + if .Non_Blocking in flags { + nix_attrs |= win32.FILE_FLAG_OVERLAPPED + } + h := win32.CreateFileW(path, access, share_mode, &sa, win32.TRUNCATE_EXISTING, nix_attrs, nil) if h == win32.INVALID_HANDLE { switch e := win32.GetLastError(); e { case win32.ERROR_FILE_NOT_FOUND, _ERROR_BAD_NETPATH, win32.ERROR_PATH_NOT_FOUND: @@ -140,6 +144,10 @@ _open_internal :: proc(name: string, flags: File_Flags, perm: Permissions) -> (h } } + if .Non_Blocking in flags { + attrs |= win32.FILE_FLAG_OVERLAPPED + } + h := win32.CreateFileW(path, access, share_mode, &sa, create_mode, attrs, nil) if h == win32.INVALID_HANDLE { return 0, _get_platform_error() diff --git a/core/os/os2/path_windows.odin b/core/os/os2/path_windows.odin index 1225ab2ce..ce3828755 100644 --- a/core/os/os2/path_windows.odin +++ b/core/os/os2/path_windows.odin @@ -283,6 +283,10 @@ _is_absolute_path :: proc(path: string) -> bool { if _is_reserved_name(path) { return true } + if len(path) > 0 && _is_path_separator(path[0]) { + return true + } + l := _volume_name_len(path) if l == 0 { return false diff --git a/core/os/os2/temp_file.odin b/core/os/os2/temp_file.odin index f0bc3788e..2c0236428 100644 --- a/core/os/os2/temp_file.odin +++ b/core/os/os2/temp_file.odin @@ -14,7 +14,7 @@ MAX_ATTEMPTS :: 1<<13 // Should be enough for everyone, right? // // The caller must `close` the file once finished with. @(require_results) -create_temp_file :: proc(dir, pattern: string) -> (f: ^File, err: Error) { +create_temp_file :: proc(dir, pattern: string, additional_flags: File_Flags = {}) -> (f: ^File, err: Error) { temp_allocator := TEMP_ALLOCATOR_GUARD({}) dir := dir if dir != "" else temp_directory(temp_allocator) or_return prefix, suffix := _prefix_and_suffix(pattern) or_return @@ -26,7 +26,7 @@ create_temp_file :: proc(dir, pattern: string) -> (f: ^File, err: Error) { attempts := 0 for { name := concatenate_strings_from_buffer(name_buf[:], prefix, random_string(rand_buf[:]), suffix) - f, err = open(name, {.Read, .Write, .Create, .Excl}, Permissions_Read_Write_All) + f, err = open(name, {.Read, .Write, .Create, .Excl} + additional_flags, Permissions_Read_Write_All) if err == .Exist { close(f) attempts += 1 diff --git a/core/os/os_windows.odin b/core/os/os_windows.odin index 03c194596..cb7e42f67 100644 --- a/core/os/os_windows.odin +++ b/core/os/os_windows.odin @@ -333,8 +333,14 @@ open :: proc(path: string, mode: int = O_RDONLY, perm: int = 0) -> (Handle, Erro case: create_mode = win32.OPEN_EXISTING } + + attrs := win32.FILE_ATTRIBUTE_NORMAL|win32.FILE_FLAG_BACKUP_SEMANTICS + if mode & (O_NONBLOCK) == O_NONBLOCK { + attrs |= win32.FILE_FLAG_OVERLAPPED + } + wide_path := win32.utf8_to_wstring(path) - handle := Handle(win32.CreateFileW(wide_path, access, share_mode, sa, create_mode, win32.FILE_ATTRIBUTE_NORMAL|win32.FILE_FLAG_BACKUP_SEMANTICS, nil)) + handle := Handle(win32.CreateFileW(wide_path, access, share_mode, sa, create_mode, attrs, nil)) if handle != INVALID_HANDLE { return handle, nil } @@ -862,4 +868,4 @@ pipe :: proc() -> (r, w: Handle, err: Error) { err = get_last_error() } return -} \ No newline at end of file +} diff --git a/core/path/filepath/path.odin b/core/path/filepath/path.odin index 14a9181c3..dbad98fa1 100644 --- a/core/path/filepath/path.odin +++ b/core/path/filepath/path.odin @@ -49,35 +49,66 @@ volume_name_len :: proc(path: string) -> int { if len(path) < 2 { return 0 } - c := path[0] + if path[1] == ':' { - switch c { + switch path[0] { case 'a'..='z', 'A'..='Z': return 2 } } - // URL: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx - if l := len(path); l >= 5 && is_slash(path[0]) && is_slash(path[1]) && - !is_slash(path[2]) && path[2] != '.' { - for n := 3; n < l-1; n += 1 { - if is_slash(path[n]) { - n += 1 - if !is_slash(path[n]) { - if path[n] == '.' { - break - } - } - for ; n < l; n += 1 { - if is_slash(path[n]) { - break - } - } - return n + /* + See: URL: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx + Further allowed paths can be of the form of: + - \\server\share or \\server\share\more\path + - \\?\C:\... + - \\.\PhysicalDriveX + */ + // Any remaining kind of path has to start with two slashes. + if !is_separator(path[0]) || !is_separator(path[1]) { + return 0 + } + + // Device path. The volume name is the whole string + if len(path) >= 5 && path[2] == '.' && is_separator(path[3]) { + return len(path) + } + + // We're a UNC share `\\host\share`, file namespace `\\?\C:` or UNC in file namespace `\\?\\host\share` + prefix := 2 + + // File namespace. + if len(path) >= 5 && path[2] == '?' && is_separator(path[3]) { + if is_separator(path[4]) { + // `\\?\\` UNC path in file namespace + prefix = 5 + } + + if len(path) >= 6 && path[5] == ':' { + switch path[4] { + case 'a'..='z', 'A'..='Z': + return 6 + case: + return 0 } - break } } + + // UNC path, minimum version of the volume is `\\h\s` for host, share. + // Can also contain an IP address in the host position. + slash_count := 0 + for i in prefix.. 0 { + slash_count += 1 + + if slash_count == 2 { + return i + } + } + } + + return len(path) } return 0 } @@ -368,8 +399,8 @@ rel :: proc(base_path, target_path: string, allocator := context.allocator) -> ( return strings.clone(".", allocator), .None } - base_vol := volume_name(base_path) - target_vol := volume_name(target_path) + base_vol := volume_name(base_clean) + target_vol := volume_name(target_clean) base := base_clean [len(base_vol):] target := target_clean[len(target_vol):] if base == "." { diff --git a/core/path/filepath/path_windows.odin b/core/path/filepath/path_windows.odin index b3f4eee9e..d7549a42c 100644 --- a/core/path/filepath/path_windows.odin +++ b/core/path/filepath/path_windows.odin @@ -36,6 +36,9 @@ is_abs :: proc(path: string) -> bool { if is_reserved_name(path) { return true } + if len(path) > 0 && is_slash(path[0]) { + return true + } l := volume_name_len(path) if l == 0 { return false diff --git a/core/reflect/reflect.odin b/core/reflect/reflect.odin index 5fbff08c2..b39c6ac6b 100644 --- a/core/reflect/reflect.odin +++ b/core/reflect/reflect.odin @@ -2003,4 +2003,16 @@ equal :: proc(a, b: any, including_indirect_array_recursion := false, recursion_ runtime.print_typeid(a.id) runtime.print_string("\n") return true +} + + +@(require_results) +default_map_hash_by_ptr :: proc(ptr: ^$T, seed: uintptr = 0) -> uintptr where intrinsics.type_is_comparable(T) { + assert(ptr != nil) + info := intrinsics.type_map_info(map[T]struct{}) + + h := u64(seed) + runtime.INITIAL_HASH_SEED + actual_seed := uintptr(h) | uintptr(uintptr(h) == 0) + + return info.key_hasher(ptr, actual_seed) } \ No newline at end of file diff --git a/core/reflect/types.odin b/core/reflect/types.odin index d6d7011d1..385edb19b 100644 --- a/core/reflect/types.odin +++ b/core/reflect/types.odin @@ -696,9 +696,10 @@ write_type_writer :: #force_no_inline proc(w: io.Writer, ti: ^Type_Info, n_writt } io.write_string(w, "struct ", &n) or_return - if .packed in info.flags { io.write_string(w, "#packed ", &n) or_return } - if .raw_union in info.flags { io.write_string(w, "#raw_union ", &n) or_return } + if .packed in info.flags { io.write_string(w, "#packed ", &n) or_return } + if .raw_union in info.flags { io.write_string(w, "#raw_union ", &n) or_return } if .all_or_none in info.flags { io.write_string(w, "#all_or_none ", &n) or_return } + if .simple in info.flags { io.write_string(w, "#simple ", &n) or_return } if .align in info.flags { io.write_string(w, "#align(", &n) or_return io.write_i64(w, i64(ti.align), 10, &n) or_return diff --git a/core/simd/simd.odin b/core/simd/simd.odin index 14bf03f43..e2373d3e2 100644 --- a/core/simd/simd.odin +++ b/core/simd/simd.odin @@ -2207,7 +2207,7 @@ swizzle :: builtin.swizzle /* Extract the set of most-significant bits of a SIMD vector. -This procedure checks the the most-significant bit (MSB) for each lane of vector +This procedure checks the most-significant bit (MSB) for each lane of vector and returns the numbers of lanes with the most-significant bit set. This procedure can be used in conjuction with `lanes_eq` (and other similar procedures) to count the number of matched lanes by computing the cardinality of the resulting @@ -2253,7 +2253,7 @@ extract_msbs :: intrinsics.simd_extract_msbs /* Extract the set of least-significant bits of a SIMD vector. -This procedure checks the the least-significant bit (LSB) for each lane of vector +This procedure checks the least-significant bit (LSB) for each lane of vector and returns the numbers of lanes with the least-significant bit set. This procedure can be used in conjuction with `lanes_eq` (and other similar procedures) to count the number of matched lanes by computing the cardinality of the resulting diff --git a/core/slice/map.odin b/core/slice/map.odin index c68488d26..fafbb55ee 100644 --- a/core/slice/map.odin +++ b/core/slice/map.odin @@ -6,8 +6,8 @@ import "base:runtime" _ :: intrinsics _ :: runtime -map_keys :: proc(m: $M/map[$K]$V, allocator := context.allocator) -> (keys: []K, err: runtime.Allocator_Error) { - keys = make(type_of(keys), len(m), allocator) or_return +map_keys :: proc(m: $M/map[$K]$V, allocator := context.allocator, loc := #caller_location) -> (keys: []K, err: runtime.Allocator_Error) { + keys = make(type_of(keys), len(m), allocator, loc) or_return i := 0 for key in m { keys[i] = key @@ -15,8 +15,8 @@ map_keys :: proc(m: $M/map[$K]$V, allocator := context.allocator) -> (keys: []K, } return } -map_values :: proc(m: $M/map[$K]$V, allocator := context.allocator) -> (values: []V, err: runtime.Allocator_Error) { - values = make(type_of(values), len(m), allocator) or_return +map_values :: proc(m: $M/map[$K]$V, allocator := context.allocator, loc := #caller_location) -> (values: []V, err: runtime.Allocator_Error) { + values = make(type_of(values), len(m), allocator, loc) or_return i := 0 for _, value in m { values[i] = value @@ -37,8 +37,8 @@ Map_Entry_Info :: struct($Key, $Value: typeid) { } -map_entries :: proc(m: $M/map[$K]$V, allocator := context.allocator) -> (entries: []Map_Entry(K, V), err: runtime.Allocator_Error) { - entries = make(type_of(entries), len(m), allocator) or_return +map_entries :: proc(m: $M/map[$K]$V, allocator := context.allocator, loc := #caller_location) -> (entries: []Map_Entry(K, V), err: runtime.Allocator_Error) { + entries = make(type_of(entries), len(m), allocator, loc) or_return i := 0 for key, value in m { entries[i].key = key @@ -48,13 +48,13 @@ map_entries :: proc(m: $M/map[$K]$V, allocator := context.allocator) -> (entries return } -map_entry_infos :: proc(m: $M/map[$K]$V, allocator := context.allocator) -> (entries: []Map_Entry_Info(K, V), err: runtime.Allocator_Error) #no_bounds_check { +map_entry_infos :: proc(m: $M/map[$K]$V, allocator := context.allocator, loc := #caller_location) -> (entries: []Map_Entry_Info(K, V), err: runtime.Allocator_Error) #no_bounds_check { m := m rm := (^runtime.Raw_Map)(&m) info := runtime.type_info_base(type_info_of(M)).variant.(runtime.Type_Info_Map) if info.map_info != nil { - entries = make(type_of(entries), len(m), allocator) or_return + entries = make(type_of(entries), len(m), allocator, loc) or_return map_cap := uintptr(cap(m)) ks, vs, hs, _, _ := runtime.map_kvh_data_dynamic(rm^, info.map_info) diff --git a/core/slice/permute.odin b/core/slice/permute.odin index 42b6d4129..280989e47 100644 --- a/core/slice/permute.odin +++ b/core/slice/permute.odin @@ -29,12 +29,13 @@ Returns: make_permutation_iterator :: proc( slice: []$T, allocator := context.allocator, + loc := #caller_location, ) -> ( iter: Permutation_Iterator(T), error: runtime.Allocator_Error, ) #optional_allocator_error { iter.slice = slice - iter.counters = make([]int, len(iter.slice), allocator) or_return + iter.counters = make([]int, len(iter.slice), allocator, loc) or_return return } diff --git a/core/slice/slice.odin b/core/slice/slice.odin index 4e3289321..12ebfce3b 100644 --- a/core/slice/slice.odin +++ b/core/slice/slice.odin @@ -454,7 +454,7 @@ swap_with_slice :: proc(a, b: $T/[]$E, loc := #caller_location) { } @(require_results) -concatenate :: proc(a: []$T/[]$E, allocator := context.allocator) -> (res: T, err: runtime.Allocator_Error) #optional_allocator_error { +concatenate :: proc(a: []$T/[]$E, allocator := context.allocator, loc := #caller_location) -> (res: T, err: runtime.Allocator_Error) #optional_allocator_error { if len(a) == 0 { return } @@ -462,7 +462,7 @@ concatenate :: proc(a: []$T/[]$E, allocator := context.allocator) -> (res: T, er for s in a { n += len(s) } - res = make(T, n, allocator) or_return + res = make(T, n, allocator, loc) or_return i := 0 for s in a { i += copy(res[i:], s) @@ -584,8 +584,8 @@ as_ptr :: proc "contextless" (array: $T/[]$E) -> [^]E { @(require_results) -mapper :: proc(s: $S/[]$U, f: proc(U) -> $V, allocator := context.allocator) -> (r: []V, err: runtime.Allocator_Error) #optional_allocator_error { - r = make([]V, len(s), allocator) or_return +mapper :: proc(s: $S/[]$U, f: proc(U) -> $V, allocator := context.allocator, loc := #caller_location) -> (r: []V, err: runtime.Allocator_Error) #optional_allocator_error { + r = make([]V, len(s), allocator, loc) or_return for v, i in s { r[i] = f(v) } @@ -611,33 +611,33 @@ reduce_reverse :: proc(s: $S/[]$U, initializer: $V, f: proc(V, U) -> V) -> V { } @(require_results) -filter :: proc(s: $S/[]$U, f: proc(U) -> bool, allocator := context.allocator) -> (res: S, err: runtime.Allocator_Error) #optional_allocator_error { - r := make([dynamic]U, 0, 0, allocator) or_return +filter :: proc(s: $S/[]$U, f: proc(U) -> bool, allocator := context.allocator, loc := #caller_location) -> (res: S, err: runtime.Allocator_Error) #optional_allocator_error { + r := make([dynamic]U, 0, 0, allocator, loc) or_return for v in s { if f(v) { - append(&r, v) + append(&r, v, loc) } } return r[:], nil } @(require_results) -filter_reverse :: proc(s: $S/[]$U, f: proc(U) -> bool, allocator := context.allocator) -> (res: S, err: runtime.Allocator_Error) #optional_allocator_error { - r := make([dynamic]U, 0, 0, allocator) or_return +filter_reverse :: proc(s: $S/[]$U, f: proc(U) -> bool, allocator := context.allocator, loc := #caller_location) -> (res: S, err: runtime.Allocator_Error) #optional_allocator_error { + r := make([dynamic]U, 0, 0, allocator, loc) or_return for i := len(s)-1; i >= 0; i -= 1 { #no_bounds_check v := s[i] if f(v) { - append(&r, v) + append(&r, v, loc) } } return r[:], nil } @(require_results) -scanner :: proc (s: $S/[]$U, initializer: $V, f: proc(V, U) -> V, allocator := context.allocator) -> (res: []V, err: runtime.Allocator_Error) #optional_allocator_error { +scanner :: proc (s: $S/[]$U, initializer: $V, f: proc(V, U) -> V, allocator := context.allocator, loc := #caller_location) -> (res: []V, err: runtime.Allocator_Error) #optional_allocator_error { if len(s) == 0 { return } - res = make([]V, len(s), allocator) or_return + res = make([]V, len(s), allocator, loc) or_return p := as_ptr(s) q := as_ptr(res) r := initializer @@ -654,14 +654,14 @@ scanner :: proc (s: $S/[]$U, initializer: $V, f: proc(V, U) -> V, allocator := c @(require_results) -repeat :: proc(s: $S/[]$U, count: int, allocator := context.allocator) -> (b: S, err: runtime.Allocator_Error) #optional_allocator_error { +repeat :: proc(s: $S/[]$U, count: int, allocator := context.allocator, loc := #caller_location) -> (b: S, err: runtime.Allocator_Error) #optional_allocator_error { if count < 0 { panic("slice: negative repeat count") } else if count > 0 && (len(s)*count)/count != len(s) { panic("slice: repeat count will cause an overflow") } - b = make(S, len(s)*count, allocator) or_return + b = make(S, len(s)*count, allocator, loc) or_return i := copy(b, s) for i < len(b) { // 2^N trick to reduce the need to copy copy(b[i:], b[:i]) @@ -918,9 +918,45 @@ bitset_to_enum_slice_with_buffer :: proc(buf: []$E, bs: $T) -> (slice: []E) wher // e.g.: // sl := slice.bitset_to_enum_slice(bs) @(require_results) -bitset_to_enum_slice_with_make :: proc(bs: $T, $E: typeid, allocator := context.allocator) -> (slice: []E) where intrinsics.type_is_enum(E), intrinsics.type_bit_set_elem_type(T) == E { - buf := make([]E, card(bs), allocator) +bitset_to_enum_slice_with_make :: proc(bs: $T, $E: typeid, allocator := context.allocator, loc := #caller_location) -> (slice: []E) where intrinsics.type_is_enum(E), intrinsics.type_bit_set_elem_type(T) == E { + buf := make([]E, card(bs), allocator, loc) return bitset_to_enum_slice(buf, bs) } bitset_to_enum_slice :: proc{bitset_to_enum_slice_with_make, bitset_to_enum_slice_with_buffer} + +/* +Removes the first n elements (`elems`) from a slice of slices, spanning inner slices and dropping empty ones. + +If `elems` is out of bounds (more than the total) this will trigger a bounds check. + +Example: + import "core:fmt" + import "core:slice" + + advance_slices_example :: proc() { + slices := [][]byte { + {1, 2, 3, 4}, + {5, 6, 7}, + } + + fmt.println(slice.advance_slices(slices, 4)) + } + +Output: + [[5, 6, 7]] +*/ +advance_slices :: proc(slices: $S/[][]$T, elems: int) -> S { + slices, elems := slices, elems + for elems > 0 { + slice := &slices[0] + take := builtin.min(elems, len(slice)) + slice^ = slice[take:] + if len(slice) == 0 { + slices = slices[1:] + } + elems -= take + } + + return slices +} diff --git a/core/slice/sort.odin b/core/slice/sort.odin index a9f8c1067..ed9d1f315 100644 --- a/core/slice/sort.odin +++ b/core/slice/sort.odin @@ -54,9 +54,9 @@ sort :: proc(data: $T/[]$E) where ORD(E) { sort_by_indices :: proc{ sort_by_indices_allocate, _sort_by_indices} -sort_by_indices_allocate :: proc(data: $T/[]$E, indices: []int, allocator := context.allocator) -> (sorted: T) { +sort_by_indices_allocate :: proc(data: $T/[]$E, indices: []int, allocator := context.allocator, loc := #caller_location) -> (sorted: T) { assert(len(data) == len(indices)) - sorted = make(T, len(data), allocator) + sorted = make(T, len(data), allocator, loc) for v, i in indices { sorted[i] = data[v] } @@ -100,8 +100,8 @@ sort_from_permutation_indices :: proc(data: $T/[]$E, indices: []int) { // sort sorts a slice and returns a slice of the original indices // This sort is not guaranteed to be stable -sort_with_indices :: proc(data: $T/[]$E, allocator := context.allocator) -> (indices: []int) where ORD(E) { - indices = make([]int, len(data), allocator) +sort_with_indices :: proc(data: $T/[]$E, allocator := context.allocator, loc := #caller_location) -> (indices: []int) where ORD(E) { + indices = make([]int, len(data), allocator, loc) when size_of(E) != 0 { if n := len(data); n > 1 { for _, idx in indices { @@ -173,8 +173,8 @@ sort_by_with_data :: proc(data: $T/[]$E, less: proc(i, j: E, user_data: rawptr) // sort_by sorts a slice with a given procedure to test whether two values are ordered "i < j" // This sort is not guaranteed to be stable -sort_by_with_indices :: proc(data: $T/[]$E, less: proc(i, j: E) -> bool, allocator := context.allocator) -> (indices : []int) { - indices = make([]int, len(data), allocator) +sort_by_with_indices :: proc(data: $T/[]$E, less: proc(i, j: E) -> bool, allocator := context.allocator, loc := #caller_location) -> (indices : []int) { + indices = make([]int, len(data), allocator, loc) when size_of(E) != 0 { if n := len(data); n > 1 { for _, idx in indices { @@ -205,8 +205,8 @@ sort_by_with_indices :: proc(data: $T/[]$E, less: proc(i, j: E) -> bool, allocat return indices } -sort_by_with_indices_with_data :: proc(data: $T/[]$E, less: proc(i, j: E, user_data: rawptr) -> bool, user_data: rawptr, allocator := context.allocator) -> (indices : []int) { - indices = make([]int, len(data), allocator) +sort_by_with_indices_with_data :: proc(data: $T/[]$E, less: proc(i, j: E, user_data: rawptr) -> bool, user_data: rawptr, allocator := context.allocator, loc := #caller_location) -> (indices : []int) { + indices = make([]int, len(data), allocator, loc) when size_of(E) != 0 { if n := len(data); n > 1 { for _, idx in indices { @@ -300,7 +300,9 @@ Example: import "core:slice" import "core:fmt" - main :: proc() { + stable_sort_by_example :: proc() { + Example :: struct { n: int, s: string } + arr := []Example { {2, "name"}, {3, "Bill"}, @@ -312,10 +314,9 @@ Example: }) for e in arr do fmt.printf("%s ", e.s) + fmt.println() } - Example :: struct { n: int, s: string } - Output: My name is Bill */ @@ -335,7 +336,9 @@ Example: import "core:slice" import "core:fmt" - main :: proc() { + stable_sort_by_cmp_example :: proc() { + Example :: struct { n: int, s: string } + arr := []Example { {2, "name"}, {3, "Bill"}, @@ -347,9 +350,9 @@ Example: }) for e in arr do fmt.printf("%s ", e.s) + fmt.println() } - Example :: struct { n: int, s: string } Output: My name is Bill */ @@ -413,7 +416,7 @@ reverse_sort_by_cmp :: proc(data: $T/[]$E, cmp: proc(i, j: E) -> Ordering) { sort_by_cmp_with_data(data, proc(i, j: E, user_data: rawptr) -> Ordering { k := (proc(i, j: E) -> Ordering)(user_data) return k(j, i) - }, rawptr(data)) + }, rawptr(cmp)) } diff --git a/core/strings/builder.odin b/core/strings/builder.odin index da9b6df27..ce636a2a1 100644 --- a/core/strings/builder.odin +++ b/core/strings/builder.odin @@ -880,6 +880,20 @@ builder_replace :: proc(b: ^Builder, old, new: string, n: int, loc := #caller_lo } if len(old) == 0 { + // NOTE(bill): reserve the necessary memory + found := 0 + for i := 0; i <= len(b.buf); i += len(new)+1 { + if n > 0 && found == n { + break + } + found += 1 + } + if found == 0 { + return + } + reserve(&b.buf, len(b.buf) + len(new)*found) or_return + + for i := 0; i <= len(b.buf); i += len(new)+1 { if n > 0 && replaced == n { break @@ -891,6 +905,27 @@ builder_replace :: proc(b: ^Builder, old, new: string, n: int, loc := #caller_lo replaced += 1 } } else { + if len(new) > len(old) { + // NOTE(bill): reserve the necessary memory + found := 0 + for i := 0; i < len(b.buf); /**/ { + if n > 0 && found == n { + break + } + + j := index(string(b.buf[i:]), old) + if j < 0 { + break + } + i += j+len(old) + found += 1 + } + if found == 0 { + return + } + reserve(&b.buf, len(b.buf) + (len(new)-len(old))*found) or_return + } + for i := 0; i < len(b.buf); /**/ { if n > 0 && replaced == n { break @@ -901,7 +936,7 @@ builder_replace :: proc(b: ^Builder, old, new: string, n: int, loc := #caller_lo break } - if len(new) >= len(old) { + if len(new) > len(old) { resize(&b.buf, len(b.buf) + len(new)-len(old)) or_return } diff --git a/core/strings/strings.odin b/core/strings/strings.odin index beaa8bda1..bad0ac26a 100644 --- a/core/strings/strings.odin +++ b/core/strings/strings.odin @@ -438,7 +438,7 @@ equal_fold :: proc(u, v: string) -> (res: bool) { r := unicode.simple_fold(sr) for r != sr && r < tr { - r = unicode.simple_fold(sr) + r = unicode.simple_fold(r) } if r == tr { continue loop diff --git a/core/sync/chan/chan.odin b/core/sync/chan/chan.odin index 05312e5a2..17618763f 100644 --- a/core/sync/chan/chan.odin +++ b/core/sync/chan/chan.odin @@ -1166,7 +1166,7 @@ Example: import "core:sync/chan" import "core:fmt" - select_raw_example :: proc() { + try_select_raw_example :: proc() { c, err := chan.create(chan.Chan(int), 1, context.allocator) assert(err == .None) defer chan.destroy(c) @@ -1198,11 +1198,11 @@ Example: Output: - SELECT: 0 true + SELECT: 0 Send RECEIVED VALUE 0 - SELECT: 0 true + SELECT: 0 Recv RECEIVED VALUE 1 - SELECT: 0 false + SELECT: -1 None */ @(require_results) @@ -1219,7 +1219,7 @@ try_select_raw :: proc "odin" (recvs: []^Raw_Chan, sends: []^Raw_Chan, send_msgs count := 0 for c, i in recvs { - if can_recv(c) { + if !c.closed && can_recv(c) { candidates[count] = { is_recv = true, idx = i, @@ -1232,7 +1232,7 @@ try_select_raw :: proc "odin" (recvs: []^Raw_Chan, sends: []^Raw_Chan, send_msgs if i > builtin.len(send_msgs)-1 || send_msgs[i] == nil { continue } - if can_send(c) { + if !c.closed && can_send(c) { candidates[count] = { is_recv = false, idx = i, diff --git a/core/sys/darwin/CoreFoundation/CFCGTypes.odin b/core/sys/darwin/CoreFoundation/CFCGTypes.odin new file mode 100644 index 000000000..ccfdf177a --- /dev/null +++ b/core/sys/darwin/CoreFoundation/CFCGTypes.odin @@ -0,0 +1,18 @@ +package CoreFoundation + +CGFloat :: distinct (f32 when size_of(uint) == 4 else f64) + +CGPoint :: struct { + x: CGFloat, + y: CGFloat, +} + +CGRect :: struct { + using origin: CGPoint, + using size: CGSize, +} + +CGSize :: struct { + width: CGFloat, + height: CGFloat, +} diff --git a/core/sys/darwin/CoreGraphics/CoreGraphics.odin b/core/sys/darwin/CoreGraphics/CoreGraphics.odin new file mode 100644 index 000000000..e2ba5fe3c --- /dev/null +++ b/core/sys/darwin/CoreGraphics/CoreGraphics.odin @@ -0,0 +1,57 @@ +package CoreGraphics + +import "core:c" +import CF "core:sys/darwin/CoreFoundation" + +@(require) +foreign import "system:CoreGraphics.framework" + +@(link_prefix="CG", default_calling_convention="c") +foreign CoreGraphics { + AssociateMouseAndMouseCursorPosition :: proc(connected: b32) -> Error --- + DisplayIDToOpenGLDisplayMask :: proc(display: DirectDisplayID) -> OpenGLDisplayMask --- + DisplayMoveCursorToPoint :: proc(display: DirectDisplayID, point: Point) -> Error --- + EventSourceKeyState :: proc(stateID: EventSourceStateID, key: KeyCode) -> bool --- + GetActiveDisplayList :: proc(maxDisplays: c.uint32_t, activeDisplays: [^]DirectDisplayID, displayCount: ^c.uint32_t) -> Error --- + GetDisplaysWithOpenGLDisplayMask :: proc(mask: OpenGLDisplayMask, maxDisplays: c.uint32_t, displays: [^]DirectDisplayID, matchingDisplayCount: ^c.uint32_t) -> Error --- + GetDisplaysWithPoint :: proc(point: Point, maxDisplays: c.uint32_t, displays: [^]DirectDisplayID, matchingDisplayCount: ^c.uint32_t) -> Error --- + GetDisplaysWithRect :: proc(rect: Rect, maxDisplays: c.uint32_t, displays: [^]DirectDisplayID, matchingDisplayCount: ^c.uint32_t) -> Error --- + GetOnlineDisplayList :: proc(maxDisplays: c.uint32_t, onlineDisplays: [^]DirectDisplayID, displayCount: ^c.uint32_t) -> Error --- + MainDisplayID :: proc() -> DirectDisplayID --- + OpenGLDisplayMaskToDisplayID :: proc(mask: OpenGLDisplayMask) -> DirectDisplayID --- + WarpMouseCursorPosition :: proc(newCursorPosition: Point) -> Error --- +} + +DirectDisplayID :: c.uint32_t + +Error :: enum c.int32_t { + Success = 0, + Failure = 1000, + IllegalArgument = 1001, + InvalidConnection = 1002, + InvalidContext = 1003, + CannotComplete = 1004, + NotImplemented = 1006, + RangeCheck = 1007, + TypeCheck = 1008, + InvalidOperation = 1010, + NoneAvailable = 1011, +} + +EventSourceStateID :: enum c.int32_t { + Private = -1, + CombinedSessionState = 0, + HIDSystemState = 1, +} + +Float :: CF.CGFloat + +KeyCode :: c.uint16_t + +OpenGLDisplayMask :: c.uint32_t + +Point :: CF.CGPoint + +Rect :: CF.CGRect + +Size :: CF.CGSize diff --git a/core/sys/darwin/Foundation/NSCursor.odin b/core/sys/darwin/Foundation/NSCursor.odin index ad2decdca..2bebf5362 100644 --- a/core/sys/darwin/Foundation/NSCursor.odin +++ b/core/sys/darwin/Foundation/NSCursor.odin @@ -3,6 +3,19 @@ package objc_Foundation @(objc_class="NSCursor") Cursor :: struct {using _: Object} +@(objc_type=Cursor, objc_name="hide", objc_is_class_method=true) +Cursor_hide :: proc() { + msgSend(nil, Cursor, "hide") +} +@(objc_type=Cursor, objc_name="unhide", objc_is_class_method=true) +Cursor_unhide :: proc() { + msgSend(nil, Cursor, "unhide") +} +@(objc_type=Cursor, objc_name="setHiddenUntilMouseMoves", objc_is_class_method=true) +Cursor_setHiddenUntilMouseMoves :: proc(flag: BOOL) { + msgSend(nil, Cursor, "setHiddenUntilMouseMoves:", flag) +} + @(objc_type=Cursor, objc_name="set") Cursor_set :: proc(self: ^Cursor) { msgSend(EventType, self, "set") diff --git a/core/sys/darwin/Foundation/NSScreen.odin b/core/sys/darwin/Foundation/NSScreen.odin index 79ab00fbe..8d52b9e1c 100644 --- a/core/sys/darwin/Foundation/NSScreen.odin +++ b/core/sys/darwin/Foundation/NSScreen.odin @@ -3,18 +3,22 @@ package objc_Foundation @(objc_class="NSScreen") Screen :: struct {using _: Object} -@(objc_type=Screen, objc_name="mainScreen") +@(objc_type=Screen, objc_name="mainScreen", objc_is_class_method=true) Screen_mainScreen :: proc "c" () -> ^Screen { return msgSend(^Screen, Screen, "mainScreen") } -@(objc_type=Screen, objc_name="deepestScreen") +@(objc_type=Screen, objc_name="deepestScreen", objc_is_class_method=true) Screen_deepestScreen :: proc "c" () -> ^Screen { return msgSend(^Screen, Screen, "deepestScreen") } -@(objc_type=Screen, objc_name="screens") +@(objc_type=Screen, objc_name="screens", objc_is_class_method=true) Screen_screens :: proc "c" () -> ^Array { return msgSend(^Array, Screen, "screens") } +@(objc_type=Screen, objc_name="screensHaveSeparateSpaces", objc_is_class_method=true) +Screen_screensHaveSeparateSpaces :: proc "c" () -> BOOL { + return msgSend(BOOL, Screen, "screensHaveSeparateSpaces") +} @(objc_type=Screen, objc_name="frame") Screen_frame :: proc "c" (self: ^Screen) -> Rect { return msgSend(Rect, self, "frame") diff --git a/core/sys/darwin/Foundation/NSTypes.odin b/core/sys/darwin/Foundation/NSTypes.odin index 822a07ab1..7c379cf99 100644 --- a/core/sys/darwin/Foundation/NSTypes.odin +++ b/core/sys/darwin/Foundation/NSTypes.odin @@ -1,6 +1,7 @@ package objc_Foundation import "base:intrinsics" +import CF "core:sys/darwin/CoreFoundation" @(private) msgSend :: intrinsics.objc_send @@ -34,17 +35,11 @@ ComparisonResult :: enum Integer { NotFound :: IntegerMax -Float :: distinct (f32 when size_of(uint) == 4 else f64) +Float :: CF.CGFloat -Point :: struct { - x: Float, - y: Float, -} +Point :: CF.CGPoint -Size :: struct { - width: Float, - height: Float, -} +Size :: CF.CGSize when size_of(UInteger) == 8 { _UINTEGER_ENCODING :: "Q" diff --git a/core/sys/darwin/Foundation/NSWindow.odin b/core/sys/darwin/Foundation/NSWindow.odin index f39faca0a..fcf35546e 100644 --- a/core/sys/darwin/Foundation/NSWindow.odin +++ b/core/sys/darwin/Foundation/NSWindow.odin @@ -1,12 +1,28 @@ package objc_Foundation import "core:strings" +import CF "core:sys/darwin/CoreFoundation" import "base:runtime" import "base:intrinsics" -Rect :: struct { - using origin: Point, - using size: Size, +Rect :: CF.CGRect +MaxX :: proc(aRect: Rect) -> Float { + return aRect.origin.x + aRect.size.width +} +MaxY :: proc(aRect: Rect) -> Float { + return aRect.origin.y + aRect.size.height +} +MidX :: proc(aRect: Rect) -> Float { + return aRect.origin.x + aRect.size.width*0.5 +} +MidY :: proc(aRect: Rect) -> Float { + return aRect.origin.y + aRect.size.height*0.5 +} +MinX :: proc(aRect: Rect) -> Float { + return aRect.origin.x +} +MinY :: proc(aRect: Rect) -> Float { + return aRect.origin.y } Depth :: enum UInteger { @@ -968,3 +984,27 @@ Window_setTabbingMode :: proc "c" (self: ^Window, mode: WindowTabbingMode) { Window_toggleFullScreen :: proc "c" (self: ^Window, sender: id) { msgSend(nil, self, "toggleFullScreen:", sender) } +@(objc_type = Window, objc_name = "contentRectForFrameRect", objc_is_class_method=true) +Window_contentRectForFrameRectType :: proc "c" (frameRect: Rect, styleMask: WindowStyleMask) -> Rect { + return msgSend(Rect, Window, "contentRectForFrameRect:styleMask:", frameRect, styleMask) +} +@(objc_type = Window, objc_name = "frameRectForContentRect", objc_is_class_method=true) +Window_frameRectForContentRectType :: proc "c" (contentRect: Rect, styleMask: WindowStyleMask) -> Rect { + return msgSend(Rect, Window, "frameRectForContentRect:styleMask:", contentRect, styleMask) +} +@(objc_type = Window, objc_name = "minFrameWidthWithTitle", objc_is_class_method=true) +Window_minFrameWidthWithTitle :: proc "c" (title: ^String, styleMask: WindowStyleMask) -> Float { + return msgSend(Float, Window, "minFrameWidthWithTitle:styleMask:", title, styleMask) +} +@(objc_type = Window, objc_name = "contentRectForFrameRect") +Window_contentRectForFrameRectInstance :: proc "c" (self: ^Window, frameRect: Rect) -> Rect { + return msgSend(Rect, self, "contentRectForFrameRect:", frameRect) +} +@(objc_type = Window, objc_name = "frameRectForContentRect") +Window_frameRectForContentRectInstance :: proc "c" (self: ^Window, contentRect: Rect) -> Rect { + return msgSend(Rect, self, "frameRectForContentRect:", contentRect) +} +@(objc_type = Window, objc_name = "screen") +Window_screen :: proc "c" (self: ^Window) -> ^Screen { + return msgSend(^Screen, self, "screen") +} diff --git a/core/sys/kqueue/kqueue.odin b/core/sys/kqueue/kqueue.odin index 25ee9bdce..b51f3426f 100644 --- a/core/sys/kqueue/kqueue.odin +++ b/core/sys/kqueue/kqueue.odin @@ -32,6 +32,7 @@ kevent :: proc(kq: KQ, change_list: []KEvent, event_list: []KEvent, timeout: ^po timeout, ) if n_events == -1 { + n_events = 0 err = posix.errno() } return @@ -60,6 +61,7 @@ Filter :: enum _Filter_Backing { Proc = _FILTER_PROC, // Check for changes to the subject process. Signal = _FILTER_SIGNAL, // Check for signals delivered to the process. Timer = _FILTER_TIMER, // Timers. + User = _FILTER_USER, // User events. } RW_Flag :: enum u32 { @@ -82,18 +84,30 @@ Proc_Flag :: enum u32 { Exit = log2(0x80000000), // Process exited. Fork = log2(0x40000000), // Process forked. Exec = log2(0x20000000), // Process exec'd. - Signal = log2(0x08000000), // Shared with `Filter.Signal`. } Proc_Flags :: bit_set[Proc_Flag; u32] Timer_Flag :: enum u32 { Seconds = log2(0x00000001), // Data is seconds. - USeconds = log2(0x00000002), // Data is microseconds. - NSeconds = log2(_NOTE_NSECONDS), // Data is nanoseconds. + USeconds = log2(_NOTE_USECONDS), // Data is microseconds. Absolute = log2(_NOTE_ABSOLUTE), // Absolute timeout. } Timer_Flags :: bit_set[Timer_Flag; u32] +User_Flag :: enum u32 { + Trigger = log2(0x01000000), + FFAnd = log2(0x40000000), + FFOr = log2(0x80000000), +} +User_Flags :: bit_set[User_Flag; u32] + +USER_FLAGS_COPY :: User_Flags{.FFOr, .FFAnd} +USER_FLAGS_CONTROL_MASK :: transmute(User_Flags)u32(0xc0000000) +USER_FLAGS_MASK :: transmute(User_Flags)u32(0x00FFFFFF) + +// Data is nanoseconds. +TIMER_FLAGS_NSECONDS :: _TIMER_FLAGS_NSECONDS + when ODIN_OS == .Darwin { _Filter_Backing :: distinct i16 @@ -106,10 +120,14 @@ when ODIN_OS == .Darwin { _FILTER_PROC :: -5 _FILTER_SIGNAL :: -6 _FILTER_TIMER :: -7 + _FILTER_USER :: -10 + _NOTE_USECONDS :: 0x00000002 _NOTE_NSECONDS :: 0x00000004 _NOTE_ABSOLUTE :: 0x00000008 + _TIMER_FLAGS_NSECONDS :: Timer_Flags{Timer_Flag(log2(_NOTE_NSECONDS))} + KEvent :: struct #align(4) { // Value used to identify this event. The exact interpretation is determined by the attached filter. ident: uintptr, @@ -119,11 +137,12 @@ when ODIN_OS == .Darwin { flags: Flags, // Filter specific flags. fflags: struct #raw_union { - rw: RW_Flags, - vnode: VNode_Flags, - fproc: Proc_Flags, + rw: RW_Flags `raw_union_tag:"filter=.Read, filter=.Write"`, + vnode: VNode_Flags `raw_union_tag:"filter=.VNode"`, + fproc: Proc_Flags `raw_union_tag:"filter=.Proc"`, // vm: VM_Flags, - timer: Timer_Flags, + timer: Timer_Flags `raw_union_tag:"filter=.Timer"`, + user: User_Flags `raw_union_tag:"filter=.User"`, }, // Filter specific data. data: c.long /* intptr_t */, @@ -143,9 +162,13 @@ when ODIN_OS == .Darwin { _FILTER_PROC :: -5 _FILTER_SIGNAL :: -6 _FILTER_TIMER :: -7 + _FILTER_USER :: -11 - _NOTE_NSECONDS :: 0x00000004 - _NOTE_ABSOLUTE :: 0x00000008 + _NOTE_USECONDS :: 0x00000004 + _NOTE_NSECONDS :: 0x00000008 + _NOTE_ABSOLUTE :: 0x00000010 + + _TIMER_FLAGS_NSECONDS :: Timer_Flags{Timer_Flag(log2(_NOTE_NSECONDS))} KEvent :: struct { // Value used to identify this event. The exact interpretation is determined by the attached filter. @@ -156,11 +179,12 @@ when ODIN_OS == .Darwin { flags: Flags, // Filter specific flags. fflags: struct #raw_union { - rw: RW_Flags, - vnode: VNode_Flags, - fproc: Proc_Flags, + rw: RW_Flags `raw_union_tag:"filter=.Read, filter=.Write"`, + vnode: VNode_Flags `raw_union_tag:"filter=.VNode"`, + fproc: Proc_Flags `raw_union_tag:"filter=.Proc"`, // vm: VM_Flags, - timer: Timer_Flags, + timer: Timer_Flags `raw_union_tag:"filter=.Timer"`, + user: User_Flags `raw_union_tag:"filter=.User"`, }, // Filter specific data. data: i64, @@ -181,11 +205,14 @@ when ODIN_OS == .Darwin { _FILTER_PROC :: 4 _FILTER_SIGNAL :: 5 _FILTER_TIMER :: 6 + _FILTER_USER :: 8 - _NOTE_NSECONDS :: 0x00000003 + _NOTE_USECONDS :: 0x00000002 _NOTE_ABSOLUTE :: 0x00000010 - KEvent :: struct #align(4) { + _TIMER_FLAGS_NSECONDS :: Timer_Flags{.Seconds, .USeconds} + + KEvent :: struct { // Value used to identify this event. The exact interpretation is determined by the attached filter. ident: uintptr, // Filter for event. @@ -194,18 +221,17 @@ when ODIN_OS == .Darwin { flags: Flags, // Filter specific flags. fflags: struct #raw_union { - rw: RW_Flags, - vnode: VNode_Flags, - fproc: Proc_Flags, + rw: RW_Flags `raw_union_tag:"filter=.Read, filter=.Write"`, + vnode: VNode_Flags `raw_union_tag:"filter=.VNode"`, + fproc: Proc_Flags `raw_union_tag:"filter=.Proc"`, // vm: VM_Flags, - timer: Timer_Flags, + timer: Timer_Flags `raw_union_tag:"filter=.Timer"`, + user: User_Flags `raw_union_tag:"filter=.User"`, }, // Filter specific data. data: i64, // Opaque user data passed through the kernel unchanged. udata: rawptr, - // Extensions. - ext: [4]u64, } } else when ODIN_OS == .OpenBSD { @@ -219,10 +245,14 @@ when ODIN_OS == .Darwin { _FILTER_PROC :: -5 _FILTER_SIGNAL :: -6 _FILTER_TIMER :: -7 + _FILTER_USER :: -10 - _NOTE_NSECONDS :: 0x00000003 + _NOTE_USECONDS :: 0x00000002 + _NOTE_NSECONDS :: 0x00000004 _NOTE_ABSOLUTE :: 0x00000010 + _TIMER_FLAGS_NSECONDS :: Timer_Flags{Timer_Flag(log2(_NOTE_NSECONDS))} + KEvent :: struct #align(4) { // Value used to identify this event. The exact interpretation is determined by the attached filter. ident: uintptr, @@ -232,11 +262,12 @@ when ODIN_OS == .Darwin { flags: Flags, // Filter specific flags. fflags: struct #raw_union { - rw: RW_Flags, - vnode: VNode_Flags, - fproc: Proc_Flags, + rw: RW_Flags `raw_union_tag:"filter=.Read, filter=.Write"`, + vnode: VNode_Flags `raw_union_tag:"filter=.VNode"`, + fproc: Proc_Flags `raw_union_tag:"filter=.Proc"`, // vm: VM_Flags, - timer: Timer_Flags, + timer: Timer_Flags `raw_union_tag:"filter=.Timer"`, + user: User_Flags `raw_union_tag:"filter=.User"`, }, // Filter specific data. data: i64, @@ -245,12 +276,20 @@ when ODIN_OS == .Darwin { } } +when ODIN_OS == .NetBSD { + @(private) + LKEVENT :: "__kevent50" +} else { + @(private) + LKEVENT :: "kevent" +} + @(private) log2 :: intrinsics.constant_log2 foreign lib { @(link_name="kqueue") _kqueue :: proc() -> KQ --- - @(link_name="kevent") + @(link_name=LKEVENT) _kevent :: proc(kq: KQ, change_list: [^]KEvent, n_changes: c.int, event_list: [^]KEvent, n_events: c.int, timeout: ^posix.timespec) -> c.int --- } diff --git a/core/sys/linux/bits.odin b/core/sys/linux/bits.odin index 213d6c26f..9ce352bf6 100644 --- a/core/sys/linux/bits.odin +++ b/core/sys/linux/bits.odin @@ -449,7 +449,7 @@ FLock_Type :: enum i16 { /* Bits for FD_Notifications */ -FD_Notifications_Bits :: enum { +FD_Notifications_Bits :: enum i32 { ACCESS = 0, MODIFY = 1, CREATE = 2, @@ -1690,17 +1690,17 @@ IPC_Cmd :: enum i16 { /* File locking operation bits */ -FLock_Op_Bits :: enum { - SH = 1, - EX = 2, - NB = 4, - UN = 8, +FLock_Op_Bits :: enum i32 { + SH = 0, + EX = 1, + NB = 2, + UN = 3, } /* ptrace requests */ -PTrace_Request :: enum { +PTrace_Request :: enum i32 { TRACEME = 0, PEEKTEXT = 1, PEEKDATA = 2, @@ -1747,7 +1747,7 @@ PTrace_Request :: enum { /* ptrace options */ -PTrace_Options_Bits :: enum { +PTrace_Options_Bits :: enum i32 { TRACESYSGOOD = 0, TRACEFORK = 1, TRACEVFORK = 2, @@ -2269,3 +2269,40 @@ Swap_Flags_Bits :: enum { PREFER = log2(0x8000), DISCARD = log2(0x10000), } + +Eventfd_Flags_Bits :: enum { + SEMAPHORE, + CLOEXEC = auto_cast Open_Flags_Bits.CLOEXEC, + NONBLOCK = auto_cast Open_Flags_Bits.NONBLOCK, +} + +Sched_Policy :: enum u32 { + OTHER = 0, + BATCH = 3, + IDLE = 5, + FIFO = 1, + RR = 2, + DEADLINE = 6, +} + +Sched_Flag_Bits :: enum { + RESET_ON_FORK = log2(0x01), + RECLAIM = log2(0x02), + DL_OVERRUN = log2(0x04), + KEEP_POLICY = log2(0x08), + KEEP_PARAMS = log2(0x10), + UTIL_CLAMP_MIN = log2(0x20), + UTIL_CLAMP_MAX = log2(0x40), +} + +Sched_Attr_Flag_Bits :: enum {} + +/* + See `constants.odin` for `MFD_HUGE_16KB`, et al. +*/ +Memfd_Create_Flag_Bits :: enum { + CLOEXEC = log2(0x1), + ALLOW_SEALING = log2(0x2), + HUGETLB = log2(0x4), +} + diff --git a/core/sys/linux/constants.odin b/core/sys/linux/constants.odin index 71a16312e..4de57f40b 100644 --- a/core/sys/linux/constants.odin +++ b/core/sys/linux/constants.odin @@ -395,6 +395,20 @@ MAP_HUGE_1GB :: transmute(Map_Flags)(u32(30) << MAP_HUGE_SHIFT) MAP_HUGE_2GB :: transmute(Map_Flags)(u32(31) << MAP_HUGE_SHIFT) MAP_HUGE_16GB :: transmute(Map_Flags)(u32(34) << MAP_HUGE_SHIFT) +MFD_HUGE_16KB :: transmute(Memfd_Create_Flags)(u32(14) << MAP_HUGE_SHIFT) +MFD_HUGE_64KB :: transmute(Memfd_Create_Flags)(u32(16) << MAP_HUGE_SHIFT) +MFD_HUGE_512KB :: transmute(Memfd_Create_Flags)(u32(19) << MAP_HUGE_SHIFT) +MFD_HUGE_1MB :: transmute(Memfd_Create_Flags)(u32(20) << MAP_HUGE_SHIFT) +MFD_HUGE_2MB :: transmute(Memfd_Create_Flags)(u32(21) << MAP_HUGE_SHIFT) +MFD_HUGE_8MB :: transmute(Memfd_Create_Flags)(u32(23) << MAP_HUGE_SHIFT) +MFD_HUGE_16MB :: transmute(Memfd_Create_Flags)(u32(24) << MAP_HUGE_SHIFT) +MFD_HUGE_32MB :: transmute(Memfd_Create_Flags)(u32(25) << MAP_HUGE_SHIFT) +MFD_HUGE_256MB :: transmute(Memfd_Create_Flags)(u32(28) << MAP_HUGE_SHIFT) +MFD_HUGE_512MB :: transmute(Memfd_Create_Flags)(u32(29) << MAP_HUGE_SHIFT) +MFD_HUGE_1GB :: transmute(Memfd_Create_Flags)(u32(30) << MAP_HUGE_SHIFT) +MFD_HUGE_2GB :: transmute(Memfd_Create_Flags)(u32(31) << MAP_HUGE_SHIFT) +MFD_HUGE_16GB :: transmute(Memfd_Create_Flags)(u32(34) << MAP_HUGE_SHIFT) + /* Get window size */ TIOCGWINSZ :: 0x5413 diff --git a/core/sys/linux/sys.odin b/core/sys/linux/sys.odin index faeda6f43..392761e1d 100644 --- a/core/sys/linux/sys.odin +++ b/core/sys/linux/sys.odin @@ -2043,22 +2043,71 @@ setpriority :: proc "contextless" (which: Priority_Which, who: i32, prio: i32) - return Errno(-ret) } -// TODO(flysand): sched_setparam - -// TODO(flysand): sched_getparam - -// TODO(flysand): sched_setscheduler - -// TODO(flysand): sched_getscheduler - -// TODO(flysand): sched_get_priority_max - -// TODO(flysand): sched_get_priority_min - -// TODO(flysand): sched_rr_get_interval +/* + Set scheduling parameters. + Available since Linux 2.0. +*/ +sched_setparam :: proc "contextless" (pid: Pid, param: ^Sched_Param) -> (Errno) { + ret := syscall(SYS_sched_setparam, pid, param) + return Errno(-ret) +} /* - Lock and memory. + Get scheduling parameters. + Available since Linux 2.0. +*/ +sched_getparam :: proc "contextless" (pid: Pid, param: ^Sched_Param) -> (Errno) { + ret := syscall(SYS_sched_getparam, pid, param) + return Errno(-ret) +} + +/* + Set scheduling policy/parameters. + Available since Linux 2.0. +*/ +sched_setscheduler :: proc "contextless" (pid: Pid, policy: i32, param: ^Sched_Param) -> (Errno) { + ret := syscall(SYS_sched_setscheduler, pid, policy, param) + return Errno(-ret) +} + +/* + Get scheduling policy/parameters. + Available since Linux 2.0. +*/ +sched_getscheduler :: proc "contextless" (pid: Pid, policy: i32, param: ^Sched_Param) -> (i32, Errno) { + ret := syscall(SYS_sched_getscheduler, pid) + return errno_unwrap(ret, i32) +} + +/* + Get static priority range. + Available since Linux 2.0. +*/ +sched_get_priority_max :: proc "contextless" (policy: i32) -> (i32, Errno) { + ret := syscall(SYS_sched_get_priority_max, policy) + return errno_unwrap(ret, i32) +} + +/* + Get static priority range. + Available since Linux 2.0. +*/ +sched_get_priority_min :: proc "contextless" (policy: i32) -> (i32, Errno) { + ret := syscall(SYS_sched_get_priority_min, policy) + return errno_unwrap(ret, i32) +} + +/* + get the SCHED_RR interval for the named process. + Available since Linux 2.0. +*/ +sched_rr_get_interval :: proc "contextless" (pid: Pid, tp: ^Time_Spec) -> (Errno) { + ret := syscall(SYS_sched_rr_get_interval, pid, tp) + return Errno(-ret) +} + +/* + Lock memory. Available since Linux 2.0. If flags specified, available since Linux 4.4. */ @@ -2560,9 +2609,29 @@ futex :: proc{ futex_wake_bitset, } -// TODO(flysand): sched_setaffinity +/* + Set a thread's CPU affinity mask. + Available since Linux 2.6. + + If you are running on a system with less than 128 cores you can use `linux.Cpu_Set` as the type for the mask argument. + Otherwise use an array of integers. +*/ +sched_setaffinity :: proc "contextless" (pid: Pid, cpusetsize: uint, mask: rawptr) -> (Errno) { + ret := syscall(SYS_sched_setaffinity, pid, cpusetsize, mask) + return Errno(-ret) +} -// TODO(flysand): sched_getaffinity +/* + Get a thread's CPU affinity mask. + Available since Linux 2.6. + + If you are running on a system with less than 128 cores you can use `linux.Cpu_Set` as the type for the mask argument. + Otherwise use an array of integers. +*/ +sched_getaffinity :: proc "contextless" (pid: Pid, cpusetsize: uint, mask: rawptr) -> (Errno) { + ret := syscall(SYS_sched_getaffinity, pid, cpusetsize, mask) + return Errno(-ret) +} // TODO(flysand): set_thread_area @@ -3001,7 +3070,10 @@ timerfd_create :: proc "contextless" (clock_id: Clock_Id, flags: Open_Flags) -> return errno_unwrap2(ret, Fd) } -// TODO(flysand): eventfd +eventfd :: proc "contextless" (initval: u32, flags: Eventfd_Flags) -> (Fd, Errno) { + ret := syscall(SYS_eventfd2, initval, transmute(i32)flags) + return errno_unwrap2(ret, Fd) +} // TODO(flysand): fallocate @@ -3100,7 +3172,14 @@ sendmmsg :: proc "contextless" (sock: Fd, msg_vec: []MMsg_Hdr, flags: Socket_Msg // TODO(flysand): setns -// TODO(flysand): getcpu +/* + Determine CPU and NUMA node on which the calling thread is running. + Available since Linux 2.6.19. +*/ +getcpu :: proc "contextless" (cpu, node: ^u32) -> (Errno) { + ret := syscall(SYS_getcpu, cpu, node) + return Errno(-ret) +} // TODO(flysand): process_vm_readv @@ -3110,9 +3189,23 @@ sendmmsg :: proc "contextless" (sock: Fd, msg_vec: []MMsg_Hdr, flags: Socket_Msg // TODO(flysand): finit_module -// TODO(flysand): sched_setattr +/* + Set scheduling policy and attributes. + Available since Linux 3.14. +*/ +sched_setattr :: proc "contextless" (pid: Pid, attr: ^Sched_Attr, flags: Sched_Attr_Flags) -> (Errno) { + ret := syscall(SYS_sched_setattr, pid, attr, transmute(u32)flags) + return Errno(-ret) +} -// TODO(flysand): sched_getattr +/* + Get scheduling policy and attributes. + Available since Linux 3.14. +*/ +sched_getattr :: proc "contextless" (pid: Pid, attr: ^Sched_Attr, size: u32, flags: Sched_Attr_Flags) -> (Errno) { + ret := syscall(SYS_sched_getattr, pid, attr, transmute(u32)flags) + return Errno(-ret) +} /* Rename the file with names relative to the specified dirfd's with other options. @@ -3130,7 +3223,14 @@ getrandom :: proc "contextless" (buf: []u8, flags: Get_Random_Flags) -> (int, Er return errno_unwrap(ret, int) } -// TODO(flysand): memfd_create +/* + Create an anonymous file. + Available since Linux 3.17. +*/ +memfd_create :: proc "contextless" (name: cstring, flags: Memfd_Create_Flags) -> (Fd, Errno) { + ret := syscall(SYS_memfd_create, cast(rawptr)name, transmute(u32)flags) + return errno_unwrap(ret, Fd) +} // TODO(flysand): kexec_file_load diff --git a/core/sys/linux/types.odin b/core/sys/linux/types.odin index 0910f11ec..c2334e5b6 100644 --- a/core/sys/linux/types.odin +++ b/core/sys/linux/types.odin @@ -1589,23 +1589,23 @@ IO_Uring_SQE :: struct { using __ioprio: struct #raw_union { ioprio: u16, sq_accept_flags: IO_Uring_Accept_Flags, - sq_send_recv_flags: IO_Uring_Send_Recv_Flags, + sq_send_recv_flags: IO_Uring_Send_Recv_Flags `raw_union_tag:"opcode=.SENDMSG, opcode=.RECVMSG, opcode=.SEND, opcode=.RECV"`, }, fd: Fd, using __offset: struct #raw_union { // Offset into file. - off: u64, - addr2: u64, + off: u64 `raw_union_tag:"opcode=.READV, opcode=.WRITEV, opcode=.SPLICE, opcode=.POLL_REMOVE, opcode=.EPOLL_CTL, opcode=.TIMEOUT, opcode=.ACCEPT, opcode=.CONNECT, opcode=.READ, opcode=.WRITE, opcode=.FILES_UPDATE, opcode=.SOCKET"`, + addr2: u64 `raw_union_tag:"opcode=.SEND, opcode=.BIND"`, using _: struct { cmd_op: u32, __pad1: u32, }, - statx: ^Statx, + statx: ^Statx `raw_union_tag:"opcode=.STATX"`, }, using __iovecs: struct #raw_union { // Pointer to buffer or iovecs. - addr: u64, - splice_off_in: u64, + addr: u64 `raw_union_tag:"opcode=.READV, opcode=.WRITEV, opcode=.POLL_REMOVE, opcode=.EPOLL_CTL, opcode=.SENDMSG, opcode=.RECVMSG, opcode=.SEND, opcode=.RECV, opcode=.TIMEOUT, opcode=.TIMEOUT_REMOVE, opcode=.ACCEPT, opcode=.ASYNC_CANCEL, opcode=.LINK_TIMEOUT, opcode=.CONNECT, opcode=.MADVISE, opcode=.OPENAT, opcode=.STATX, opcode=.READ, opcode=.WRITE, opcode=.FILES_UPDATE, opcode=.BIND, opcode=.LISTEN"`, + splice_off_in: u64 `raw_union_tag:"opcode=.SPLICE"`, using _: struct { level: u32, optname: u32, @@ -1613,28 +1613,28 @@ IO_Uring_SQE :: struct { }, using __len: struct #raw_union { // Buffer size or number of iovecs. - len: u32, - poll_flags: IO_Uring_Poll_Add_Flags, - statx_mask: Statx_Mask, - epoll_ctl_op: EPoll_Ctl_Opcode, - shutdown_how: Shutdown_How, + len: u32 `raw_union_tag:"opcode=.READV, opcode=.WRITEV, opcode=.SPLICE, opcode=.SEND, opcode=.RECV, opcode=.TIMEOUT, opcode=.LINK_TIMEOUT, opcode=.MADVISE, opcode=.OPENAT, opcode=.READ, opcode=.WRITE, opcode=.TEE, opcode=.FILES_UPDATE, opcode=.SOCKET"`, + poll_flags: IO_Uring_Poll_Add_Flags `raw_union_tag:"opcode=.POLL_ADD, opcode=.POLL_REMOVE"`, + statx_mask: Statx_Mask `raw_union_tag:"opcode=.STATX"`, + epoll_ctl_op: EPoll_Ctl_Opcode `raw_union_tag:"opcode=.EPOLL_CTL"`, + shutdown_how: Shutdown_How `raw_union_tag:"opcode=.SHUTDOWN"`, }, using __contents: struct #raw_union { - rw_flags: i32, - fsync_flags: IO_Uring_Fsync_Flags, + rw_flags: i32 `raw_union_tag:"opcode=.READV, opcode=.WRITEV, opcode=.SOCKET"`, + fsync_flags: IO_Uring_Fsync_Flags `raw_union_tag:"opcode=.FSYNC"`, // compatibility. - poll_events: Fd_Poll_Events, + poll_events: Fd_Poll_Events `raw_union_tag:"opcode=.POLL_ADD, opcode=.POLL_REMOVE"`, // word-reversed for BE. poll32_events: u32, sync_range_flags: u32, - msg_flags: Socket_Msg, - timeout_flags: IO_Uring_Timeout_Flags, - accept_flags: Socket_FD_Flags, + msg_flags: Socket_Msg `raw_union_tag:"opcode=.SENDMSG, opcode=.RECVMSG, opcode=.SEND, opcode=.RECV"`, + timeout_flags: IO_Uring_Timeout_Flags `raw_union_tag:"opcode=.TIMEOUT, opcode=.TIMEOUT_REMOVE, opcode=.LINK_TIMEOUT"`, + accept_flags: Socket_FD_Flags `raw_union_tag:"opcode=.ACCEPT"`, cancel_flags: u32, - open_flags: Open_Flags, - statx_flags: FD_Flags, - fadvise_advice: u32, - splice_flags: IO_Uring_Splice_Flags, + open_flags: Open_Flags `raw_union_tag:"opcode=.OPENAT"`, + statx_flags: FD_Flags `raw_union_tag:"opcode=.STATX"`, + fadvise_advice: u32 `raw_union_tag:"opcode=.MADVISE"`, + splice_flags: IO_Uring_Splice_Flags `raw_union_tag:"opcode=.SPLICE, opcode=.TEE"`, rename_flags: u32, unlink_flags: u32, hardlink_flags: u32, @@ -1653,10 +1653,10 @@ IO_Uring_SQE :: struct { // Personality to use, if used. personality: u16, using _: struct #raw_union { - splice_fd_in: Fd, - file_index: u32, + splice_fd_in: Fd `raw_union_tag:"opcode=.SPLICE, opcode=.TEE"`, + file_index: u32 `raw_union_tag:"opcode=.ACCEPT, opcode=.OPENAT, opcode=.CLOSE, opcode=.SOCKET"`, using _: struct { - addr_len: u16, + addr_len: u16 `raw_union_tag:"opcode=.SEND"`, __pad3: [1]u16, }, }, @@ -1748,3 +1748,35 @@ Mount_Flags :: bit_set[Mount_Flags_Bits; uint] Umount2_Flags :: bit_set[Umount2_Flags_Bits; u32] Swap_Flags :: bit_set[Swap_Flags_Bits; u32] + +Eventfd_Flags :: bit_set[Eventfd_Flags_Bits; i32] + +Cpu_Set :: bit_set[0 ..< 128] + +Sched_Param :: struct { + sched_priority: i32, +} + +Sched_Flags :: bit_set[Sched_Flag_Bits; u32] + +Sched_Attr :: struct { + size: u32, + + sched_policy: Sched_Policy, + sched_flags: Sched_Flags, + sched_nice: i32, + sched_priority: u32, + + /* For the DEADLINE policy */ + sched_runtime: u64, + sched_deadline: u64, + sched_period: u64, + + /* Utilization hints */ + sched_util_min: u32, + sched_util_max: u32, +} + +Sched_Attr_Flags :: bit_set[Sched_Attr_Flag_Bits; u32] + +Memfd_Create_Flags :: bit_set[Memfd_Create_Flag_Bits; u32] diff --git a/core/sys/linux/uring/doc.odin b/core/sys/linux/uring/doc.odin new file mode 100644 index 000000000..8b9ae5ee8 --- /dev/null +++ b/core/sys/linux/uring/doc.odin @@ -0,0 +1,88 @@ +/* +Wrapper/convenience package over the raw io_uring syscalls, providing help with setup, creation, and operating the ring. + +The following example shows a simple `cat` program implementation using the package. + +Example: + package main + + import "base:runtime" + + import "core:fmt" + import "core:os" + import "core:sys/linux" + import "core:sys/linux/uring" + + Request :: struct { + path: cstring, + buffer: []byte, + completion: linux.IO_Uring_CQE, + } + + main :: proc() { + if len(os.args) < 2 { + fmt.eprintfln("Usage: %s [file name] <[file name] ...>", os.args[0]) + os.exit(1) + } + + requests := make_soa(#soa []Request, len(os.args)-1) + defer delete(requests) + + ring: uring.Ring + params := uring.DEFAULT_PARAMS + err := uring.init(&ring, ¶ms) + fmt.assertf(err == nil, "uring.init: %v", err) + defer uring.destroy(&ring) + + for &request, i in requests { + request.path = runtime.args__[i+1] + // sets up a read requests and adds it to the ring buffer. + submit_read_request(request.path, &request.buffer, &ring) + } + + ulen := u32(len(requests)) + + // submit the requests and wait for them to complete right away. + n, serr := uring.submit(&ring, ulen) + fmt.assertf(serr == nil, "uring.submit: %v", serr) + assert(n == ulen) + + // copy the completed requests out of the ring buffer. + cn := uring.copy_cqes_ready(&ring, requests.completion[:ulen]) + assert(cn == ulen) + + for request in requests { + // check result of the requests. + fmt.assertf(request.completion.res >= 0, "read %q failed: %v", request.path, linux.Errno(-request.completion.res)) + // print out. + fmt.print(string(request.buffer)) + + delete(request.buffer) + } + } + + submit_read_request :: proc(path: cstring, buffer: ^[]byte, ring: ^uring.Ring) { + fd, err := linux.open(path, {}) + fmt.assertf(err == nil, "open(%q): %v", path, err) + + file_sz := get_file_size(fd) + + buffer^ = make([]byte, file_sz) + + _, ok := uring.read(ring, 0, fd, buffer^, 0) + assert(ok, "could not get read sqe") + } + + get_file_size :: proc(fd: linux.Fd) -> uint { + st: linux.Stat + err := linux.fstat(fd, &st) + fmt.assertf(err == nil, "fstat: %v", err) + + if linux.S_ISREG(st.mode) { + return uint(st.size) + } + + panic("not a regular file") + } +*/ +package uring diff --git a/core/sys/linux/uring/ops.odin b/core/sys/linux/uring/ops.odin new file mode 100644 index 000000000..7b3392e98 --- /dev/null +++ b/core/sys/linux/uring/ops.odin @@ -0,0 +1,847 @@ +package uring + +import "core:sys/linux" + +// Do not perform any I/O. This is useful for testing the performance of the uring implementation itself. +nop :: proc(ring: ^Ring, user_data: u64) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .NOP + sqe.user_data = user_data + + ok = true + return +} + +// Vectored read operation, see also readv(2). +readv :: proc(ring: ^Ring, user_data: u64, fd: linux.Fd, iovs: []linux.IO_Vec, off: u64) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .READV + sqe.fd = fd + sqe.addr = cast(u64)uintptr(raw_data(iovs)) + sqe.len = u32(len(iovs)) + sqe.off = off + sqe.user_data = user_data + + ok = true + return +} + +// Vectored write operation, see also writev(2). +writev :: proc(ring: ^Ring, user_data: u64, fd: linux.Fd, iovs: []linux.IO_Vec, off: u64) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .WRITEV + sqe.fd = fd + sqe.addr = cast(u64)uintptr(raw_data(iovs)) + sqe.len = u32(len(iovs)) + sqe.off = off + sqe.user_data = user_data + + ok = true + return +} + +read_fixed :: proc() { + unimplemented() +} + +write_fixed :: proc() { + unimplemented() +} + +/* +File sync. See also fsync(2). + +Optionally off and len can be used to specify a range within the file to be synced rather than syncing the entire file, which is the default behavior. + +Note that, while I/O is initiated in the order in which it appears in the submission queue, completions are unordered. +For example, an application which places a write I/O followed by an fsync in the submission queue cannot expect the fsync to apply to the write. +The two operations execute in parallel, so the fsync may complete before the write is issued to the storage. +The same is also true for previously issued writes that have not completed prior to the fsync. +To enforce ordering one may utilize linked SQEs, +IOSQE_IO_DRAIN or wait for the arrival of CQEs of requests which have to be ordered before a given request before submitting its SQE. +*/ +fsync :: proc(ring: ^Ring, user_data: u64, fd: linux.Fd, flags: linux.IO_Uring_Fsync_Flags) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .FSYNC + sqe.fsync_flags = flags + sqe.fd = fd + sqe.user_data = user_data + + ok = true + return +} + +/* +Poll the fd specified in the submission queue entry for the events specified in the poll_events field. + +Unlike poll or epoll without EPOLLONESHOT, by default this interface always works in one shot mode. +That is, once the poll operation is completed, it will have to be resubmitted. + +If IORING_POLL_ADD_MULTI is set in the SQE len field, then the poll will work in multi shot mode instead. +That means it'll repatedly trigger when the requested event becomes true, and hence multiple CQEs can be generated from this single SQE. +The CQE flags field will have IORING_CQE_F_MORE set on completion if the application should expect further CQE entries from the original request. +If this flag isn't set on completion, then the poll request has been terminated and no further events will be generated. +This mode is available since 5.13. + +This command works like an async poll(2) and the completion event result is the returned mask of events. + +Without IORING_POLL_ADD_MULTI and the initial poll operation with IORING_POLL_ADD_MULTI the operation is level triggered, +i.e. if there is data ready or events pending etc. +at the time of submission a corresponding CQE will be posted. +Potential further completions beyond the first caused by a IORING_POLL_ADD_MULTI are edge triggered. +*/ +poll_add :: proc(ring: ^Ring, user_data: u64, fd: linux.Fd, events: linux.Fd_Poll_Events, flags: linux.IO_Uring_Poll_Add_Flags) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .POLL_ADD + sqe.fd = fd + sqe.poll_events = events + sqe.poll_flags = flags + sqe.user_data = user_data + + ok = true + return +} + +/* +Remove an existing poll request. + +If found, the res field of the struct io_uring_cqe will contain 0. +If not found, res will contain -ENOENT, or -EALREADY if the poll request was in the process of completing already. +*/ +poll_remove :: proc(ring: ^Ring, user_data: u64, fd: linux.Fd, events: linux.Fd_Poll_Events) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .POLL_REMOVE + sqe.fd = fd + sqe.poll_events = events + sqe.user_data = user_data + + ok = true + return +} + +/* +Update the events of an existing poll request. + +The request will update an existing poll request with the mask of events passed in with this request. +The lookup is based on the user_data field of the original SQE submitted. + +Updating an existing poll is available since 5.13. +*/ +poll_update_events :: proc(ring: ^Ring, user_data: u64, orig_user_data: u64, fd: linux.Fd, events: linux.Fd_Poll_Events) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .POLL_REMOVE + sqe.fd = fd + sqe.addr = orig_user_data + sqe.poll_events = events + sqe.user_data = user_data + sqe.poll_flags = {.UPDATE_EVENTS} + + ok = true + return +} + +/* +Update the user data of an existing poll request. + +The request will update the user_data of an existing poll request based on the value passed. + +Updating an existing poll is available since 5.13. +*/ +poll_update_user_data :: proc(ring: ^Ring, user_data: u64, orig_user_data: u64, new_user_data: u64, fd: linux.Fd) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .POLL_REMOVE + sqe.fd = fd + sqe.off = orig_user_data + sqe.addr = new_user_data + sqe.user_data = user_data + sqe.poll_flags = {.UPDATE_USER_DATA} + + ok = true + return +} + +/* +Add, remove or modify entries in the interest list of epoll(7). + +See epoll_ctl(2) for details of the system call. + +Available since 5.6. +*/ +epoll_ctl :: proc(ring: ^Ring, user_data: u64, epfd: linux.Fd, op: linux.EPoll_Ctl_Opcode, fd: linux.Fd, event: ^linux.EPoll_Event) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .EPOLL_CTL + sqe.fd = epfd + sqe.off = u64(fd) + sqe.epoll_ctl_op = op + sqe.addr = cast(u64)uintptr(event) + sqe.user_data = user_data + + ok = true + return +} + +sync_file_range :: proc() { + unimplemented() +} + +/* +Issue the equivalent of a sendmsg(2) system call. + +See also sendmsg(2) for the general description of the related system call. + +poll_first: if set, uring will assume the socket is currently full and attempting to send data will be unsuccessful. +For this case, uring will arm internal poll and trigger a send of the data when there is enough space available. +This initial send attempt can be wasteful for the case where the socket is expected to be full, setting this flag will +bypass the initial send attempt and go straight to arming poll. +If poll does indicate that data can be sent, the operation will proceed. + +Available since 5.3. +*/ +sendmsg :: proc(ring: ^Ring, user_data: u64, fd: linux.Fd, msghdr: ^linux.Msg_Hdr, flags: linux.Socket_Msg, poll_first := false) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .SENDMSG + sqe.fd = fd + sqe.addr = cast(u64)uintptr(msghdr) + sqe.msg_flags = flags + sqe.user_data = user_data + sqe.sq_send_recv_flags = {.RECVSEND_POLL_FIRST} if poll_first else {} + + ok = true + return +} + +/* +Works just like sendmsg, but receives instead of sends. + +poll_first: If set, uring will assume the socket is currently empty and attempting to receive data will be unsuccessful. +For this case, uring will arm internal poll and trigger a receive of the data when the socket has data to be read. +This initial receive attempt can be wasteful for the case where the socket is expected to be empty, setting this flag will bypass the initial receive attempt and go straight to arming poll. +If poll does indicate that data is ready to be received, the operation will proceed. + +Available since 5.3. +*/ +recvmsg :: proc(ring: ^Ring, user_data: u64, fd: linux.Fd, msghdr: ^linux.Msg_Hdr, flags: linux.Socket_Msg, poll_first := false) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .RECVMSG + sqe.fd = fd + sqe.addr = cast(u64)uintptr(msghdr) + sqe.msg_flags = flags + sqe.user_data = user_data + sqe.sq_send_recv_flags = {.RECVSEND_POLL_FIRST} if poll_first else {} + + ok = true + return +} + +/* +Issue the equivalent of a send(2) system call. + +See also send(2) for the general description of the related system call. + +poll_first: If set, uring will assume the socket is currently full and attempting to send data will be unsuccessful. +For this case, uring will arm internal poll and trigger a send of the data when there is enough space available. +This initial send attempt can be wasteful for the case where the socket is expected to be full, setting this flag will bypass the initial send attempt and go straight to arming poll. +If poll does indicate that data can be sent, the operation will proceed. + +Available since 5.6. +*/ +send :: proc(ring: ^Ring, user_data: u64, sockfd: linux.Fd, buf: []byte, flags: linux.Socket_Msg, poll_first := false) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .SEND + sqe.fd = sockfd + sqe.addr = cast(u64)uintptr(raw_data(buf)) + sqe.len = u32(len(buf)) + sqe.msg_flags = flags + sqe.user_data = user_data + sqe.sq_send_recv_flags = {.RECVSEND_POLL_FIRST} if poll_first else {} + + ok = true + return +} + +sendto :: proc(ring: ^Ring, user_data: u64, sockfd: linux.Fd, buf: []byte, flags: linux.Socket_Msg, dest: ^$T, poll_first := false) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) + where T == linux.Sock_Addr_In || T == linux.Sock_Addr_In6 || T == linux.Sock_Addr_Un || T == linux.Sock_Addr_Any { + + sqe = send(ring, user_data, sockfd, buf, flags, poll_first) or_return + sqe.addr2 = u64(uintptr(dest)) + sqe.addr_len = u16(size_of(T)) + + ok = true + return +} + +/* +Works just like send, but receives instead of sends. + +poll_first: If set, uring will assume the socket is currently empty and attempting to receive data will be unsuccessful. +For this case, uring will arm internal poll and trigger a receive of the data when the socket has data to be read. +This initial receive attempt can be wasteful for the case where the socket is expected to be empty, setting this flag will bypass the initial receive attempt and go straight to arming poll. +If poll does indicate that data is ready to be received, the operation will proceed. + +Available since 5.6. +*/ +recv :: proc(ring: ^Ring, user_data: u64, sockfd: linux.Fd, buf: []byte, flags: linux.Socket_Msg, poll_first := false) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .RECV + sqe.fd = sockfd + sqe.addr = cast(u64)uintptr(raw_data(buf)) + sqe.len = cast(u32)uintptr(len(buf)) + sqe.msg_flags = flags + sqe.user_data = user_data + sqe.sq_send_recv_flags = {.RECVSEND_POLL_FIRST} if poll_first else {} + + ok = true + return +} + +/* +Register a timeout operation. + +The timeout will complete when either the timeout expires, or after the specified number of +events complete (if `count` is greater than `0`). + +`flags` may be `0` for a relative timeout, or `IORING_TIMEOUT_ABS` for an absolute timeout. + +The completion event result will be `-ETIME` if the timeout completed through expiration, +`0` if the timeout completed after the specified number of events, or `-ECANCELED` if the +timeout was removed before it expired. + +uring timeouts use the `CLOCK.MONOTONIC` clock source. +*/ +timeout :: proc(ring: ^Ring, user_data: u64, ts: ^linux.Time_Spec, count: u32, flags: linux.IO_Uring_Timeout_Flags) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .TIMEOUT + sqe.fd = -1 + sqe.addr = cast(u64)uintptr(ts) + sqe.len = 1 + sqe.off = u64(count) + sqe.timeout_flags = flags + sqe.user_data = user_data + + ok = true + return +} + +/* +Rmove an existing timeout operation. + +The timeout is identified by it's `user_data`. + +The completion event result will be `0` if the timeout was found and cancelled successfully, +`-EBUSY` if the timeout was found but expiration was already in progress, or +`-ENOENT` if the timeout was not found. +*/ +timeout_remove :: proc(ring: ^Ring, user_data: u64, timeout_user_data: u64, flags: linux.IO_Uring_Timeout_Flags) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .TIMEOUT_REMOVE + sqe.fd = -1 + sqe.addr = timeout_user_data + sqe.timeout_flags = flags + sqe.user_data = user_data + + ok = true + return +} + +/* +Issue the equivalent of an accept4(2) system call. + +See also accept4(2) for the general description of the related system call. + +If the file_index field is set to a positive number, the file won't be installed into the normal file table as usual +but will be placed into the fixed file table at index file_index - 1. +In this case, instead of returning a file descriptor, the result will contain either 0 on success or an error. +If the index points to a valid empty slot, the installation is guaranteed to not fail. +If there is already a file in the slot, it will be replaced, similar to IORING_OP_FILES_UPDATE. +Please note that only uring has access to such files and no other syscall can use them. See IOSQE_FIXED_FILE and IORING_REGISTER_FILES. + +Available since 5.5. +*/ +accept :: proc(ring: ^Ring, user_data: u64, sockfd: linux.Fd, addr: ^$T, addr_len: ^i32, flags: linux.Socket_FD_Flags, file_index: u32 = 0) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) +where T == linux.Sock_Addr_In || T == linux.Sock_Addr_In6 || T == linux.Sock_Addr_Un || T == linux.Sock_Addr_Any { + + sqe = get_sqe(ring) or_return + sqe.opcode = .ACCEPT + sqe.fd = sockfd + sqe.addr = cast(u64)uintptr(addr) + sqe.off = cast(u64)uintptr(addr_len) + sqe.accept_flags = flags + sqe.user_data = user_data + sqe.file_index = file_index + + ok = true + return +} + +/* +Attempt to cancel an already issued request. + +The request is identified by it's user data. + +The cancelation request will complete with one of the following results codes. + +If found, the res field of the cqe will contain 0. +If not found, res will contain -ENOENT. + +If found and attempted canceled, the res field will contain -EALREADY. +In this case, the request may or may not terminate. +In general, requests that are interruptible (like socket IO) will get canceled, while disk IO requests cannot be canceled if already started. + +Available since 5.5. +*/ +async_cancel :: proc(ring: ^Ring, orig_user_data: u64, user_data: u64) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .ASYNC_CANCEL + sqe.addr = orig_user_data + sqe.user_data = user_data + + ok = true + return +} + +/* +Adds a link timeout operation. + +You need to set linux.IOSQE_IO_LINK to flags of the target operation +and then call this method right after the target operation. +See https://lwn.net/Articles/803932/ for detail. + +If the dependent request finishes before the linked timeout, the timeout +is canceled. If the timeout finishes before the dependent request, the +dependent request will be canceled. + +The completion event result of the link_timeout will be +`-ETIME` if the timeout finishes before the dependent request +(in this case, the completion event result of the dependent request will +be `-ECANCELED`), or +`-EALREADY` if the dependent request finishes before the linked timeout. + +Available since 5.5. +*/ +link_timeout :: proc(ring: ^Ring, user_data: u64, ts: ^linux.Time_Spec, flags: linux.IO_Uring_Timeout_Flags) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring, 0) or_return + sqe.opcode = .LINK_TIMEOUT + sqe.fd = -1 + sqe.addr = cast(u64)uintptr(ts) + sqe.len = 1 + sqe.timeout_flags = flags + sqe.user_data = user_data + + ok = true + return +} + +/* +Issue the equivalent of a connect(2) system call. + +See also connect(2) for the general description of the related system call. + +Available since 5.5. +*/ +connect :: proc(ring: ^Ring, user_data: u64, sockfd: linux.Fd, addr: ^$T) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) +where T == linux.Sock_Addr_In || T == linux.Sock_Addr_In6 || T == linux.Sock_Addr_Un || T == linux.Sock_Addr_Any { + + sqe = get_sqe(ring) or_return + sqe.opcode = .CONNECT + sqe.fd = sockfd + sqe.addr = cast(u64)uintptr(addr) + sqe.off = size_of(T) + sqe.user_data = user_data + + ok = true + return +} + +fallocate :: proc() { + unimplemented() +} + +fadvise :: proc() { + unimplemented() +} + +/* +Issue the equivalent of a madvise(2) system call. + +See also madvise(2) for the general description of the related system call. + +Available since 5.6. +*/ +madvise :: proc(ring: ^Ring, user_data: u64, addr: rawptr, size: u32, advise: linux.MAdvice) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .MADVISE + sqe.addr = u64(uintptr(addr)) + sqe.len = size + sqe.fadvise_advice = cast(u32)transmute(int)advise + sqe.user_data = user_data + + ok = true + return +} + +/* +Issue the equivalent of a openat(2) system call. + +See also openat(2) for the general description of the related system call. + +Available since 5.6. + +If the file_index is set to a positive number, +the file won't be installed into the normal file table as usual but will be placed into the fixed file table at index file_index - 1. +In this case, instead of returning a file descriptor, the result will contain either 0 on success or an error. +If the index points to a valid empty slot, the installation is guaranteed to not fail. +If there is already a file in the slot, it will be replaced, similar to IORING_OP_FILES_UPDATE. +Please note that only uring has access to such files and no other syscall can use them. +See IOSQE_FIXED_FILE and IORING_REGISTER_FILES. + +Available since 5.15. +*/ +openat :: proc(ring: ^Ring, user_data: u64, dirfd: linux.Fd, path: cstring, mode: linux.Mode, flags: linux.Open_Flags, file_index: u32 = 0) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .OPENAT + sqe.fd = dirfd + sqe.addr = cast(u64)transmute(uintptr)path + sqe.len = transmute(u32)mode + sqe.open_flags = flags + sqe.user_data = user_data + sqe.file_index = file_index + + ok = true + return +} + +openat2 :: proc() { + unimplemented() +} + +/* +Issue the equivalent of a close(2) system call. + +See also close(2) for the general description of the related system call. + +Available since 5.6. + +If the file_index field is set to a positive number, this command can be used to close files that were +direct opened through IORING_OP_OPENAT, IORING_OP_OPENAT2, or IORING_OP_ACCEPT using the uring specific direct descriptors. +Note that only one of the descriptor fields may be set. +The direct close feature is available since the 5.15 kernel, where direct descriptors were introduced. +*/ +close :: proc(ring: ^Ring, user_data: u64, fd: linux.Fd, file_index: u32 = 0) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .CLOSE + sqe.fd = fd + sqe.user_data = user_data + sqe.file_index = file_index + + ok = true + return +} + +/* +Issue the equivalent of a statx(2) system call. + +See also statx(2) for the general description of the related system call. + +Available since 5.6. +*/ +statx :: proc(ring: ^Ring, user_data: u64, dirfd: linux.Fd, pathname: cstring, flags: linux.FD_Flags, mask: linux.Statx_Mask, buf: ^linux.Statx) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .STATX + sqe.fd = dirfd + sqe.addr = cast(u64)transmute(uintptr)pathname + sqe.statx_flags = flags + sqe.statx_mask = mask + sqe.statx = buf + sqe.user_data = user_data + + ok = true + return +} + +/* +Issue the equivalent of a pread(2) system call. + +If offset is set to -1 , the offset will use (and advance) the file position, like the read(2) system calls. +These are non-vectored versions of the IORING_OP_READV and IORING_OP_WRITEV opcodes. +See also read(2) for the general description of the related system call. + +Available since 5.6. +*/ +read :: proc(ring: ^Ring, user_data: u64, fd: linux.Fd, buf: []u8, offset: u64) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .READ + sqe.fd = fd + sqe.addr = cast(u64)uintptr(raw_data(buf)) + sqe.len = u32(len(buf)) + sqe.off = offset + sqe.user_data = user_data + + ok = true + return +} + +/* +Issue the equivalent of a pwrite(2) system call. + +If offset is set to -1 , the offset will use (and advance) the file position, like the read(2) system calls. +These are non-vectored versions of the IORING_OP_READV and IORING_OP_WRITEV opcodes. +See also write(2) for the general description of the related system call. + +Available since 5.6. +*/ +write :: proc(ring: ^Ring, user_data: u64, fd: linux.Fd, buf: []u8, offset: u64) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .WRITE + sqe.fd = fd + sqe.addr = cast(u64)uintptr(raw_data(buf)) + sqe.len = u32(len(buf)) + sqe.off = offset + sqe.user_data = user_data + + ok = true + return +} + +/* +Issue the equivalent of a splice(2) system call. + +A sentinel value of -1 is used to pass the equivalent of a NULL for the offsets to splice(2). + +Please note that one of the file descriptors must refer to a pipe. +See also splice(2) for the general description of the related system call. + +Available since 5.7. + +*/ +splice :: proc(ring: ^Ring, user_data: u64, fd_in: linux.Fd, off_in: i64, fd_out: linux.Fd, off_out: i64, len: u32, flags: linux.IO_Uring_Splice_Flags) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .SPLICE + sqe.splice_fd_in = fd_in + sqe.splice_off_in = cast(u64)off_in + sqe.fd = fd_out + sqe.off = cast(u64)off_out + sqe.len = len + sqe.splice_flags = flags + sqe.user_data = user_data + + ok = true + return +} + +/* +Issue the equivalent of a tee(2) system call. + +Please note that both of the file descriptors must refer to a pipe. +See also tee(2) for the general description of the related system call. + +Available since 5.8. +*/ +tee :: proc(ring: ^Ring, user_data: u64, fd_in: linux.Fd, fd_out: linux.Fd, len: u32, flags: linux.IO_Uring_Splice_Flags) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .TEE + sqe.splice_fd_in = fd_in + sqe.fd = fd_out + sqe.len = len + sqe.splice_flags = flags + sqe.user_data = user_data + + ok = true + return +} + +/* +This command is an alternative to using IORING_REGISTER_FILES_UPDATE which then works in an async fashion, like the rest of the uring commands. + +Note that the array of file descriptors pointed to in addr must remain valid until this operation has completed. + +Available since 5.6. +*/ +files_update :: proc(ring: ^Ring, user_data: u64, fds: []linux.Fd, off: u64) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .FILES_UPDATE + sqe.addr = cast(u64)uintptr(raw_data(fds)) + sqe.len = cast(u32)len(fds) + sqe.off = off + sqe.user_data = user_data + + ok = true + return +} + +provide_buffers :: proc() { + unimplemented() +} + +remove_buffers :: proc() { + unimplemented() +} + +/* +Issue the equivalent of a shutdown(2) system call. + +Available since 5.11. +*/ +shutdown :: proc(ring: ^Ring, user_data: u64, fd: linux.Fd, how: linux.Shutdown_How) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .SHUTDOWN + sqe.fd = fd + sqe.shutdown_how = how + sqe.user_data = user_data + + ok = true + return +} + +renameat :: proc() { + unimplemented() +} + +unlinkat :: proc() { + unimplemented() +} + +mkdirat :: proc() { + unimplemented() +} + +symlinkat :: proc() { + unimplemented() +} + +linkat :: proc() { + unimplemented() +} + +msg_ring :: proc() { + unimplemented() +} + +/* +Issue the equivalent of a socket(2) system call. + +See also socket(2) for the general description of the related system call. + +Available since 5.19. + +If the file_index field is set to a positive number, the file won't be installed into the normal file +table as usual but will be placed into the fixed file table at index file_index - 1. +In this case, instead of returning a file descriptor, the result will contain either 0 on success or an error. +If the index points to a valid empty slot, the installation is guaranteed to not fail. +If there is already a file in the slot, it will be replaced, similar to IORING_OP_FILES_UPDATE. +Please note that only uring has access to such files and no other syscall can use them. +See IOSQE_FIXED_FILE and IORING_REGISTER_FILES. +*/ +socket :: proc(ring: ^Ring, user_data: u64, domain: linux.Address_Family, socktype: linux.Socket_Type, protocol: linux.Protocol, file_index: u32 = 0) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .SOCKET + sqe.user_data = user_data + sqe.fd = cast(linux.Fd)domain + sqe.off = cast(u64)socktype + sqe.len = cast(u32)protocol + sqe.rw_flags = {} + sqe.file_index = file_index + + ok = true + return +} + +uring_cmd :: proc() { + unimplemented() +} + +send_zc :: proc() { + unimplemented() +} + +sendmsg_zc :: proc() { + unimplemented() +} + +waitid :: proc() { + unimplemented() +} + +setxattr :: proc() { + unimplemented() +} + +getxattr :: proc() { + unimplemented() +} + +fsetxattr :: proc() { + unimplemented() +} + +fgetxattr :: proc() { + unimplemented() +} + +/* +Issues the equivalent of the bind(2) system call. + +Available since 6.11. +*/ +bind :: proc(ring: ^Ring, user_data: u64, sock: linux.Fd, addr: ^$T) -> (sqe: linux.IO_Uring_SQE, ok: bool) + where + T == linux.Sock_Addr_In || + T == linux.Sock_Addr_In6 || + T == linux.Sock_Addr_Un || + T == linux.Sock_Addr_Any +{ + sqe = get_sqe(ring) or_return + sqe.opcode = .BIND + sqe.user_data = user_data + sqe.fd = sock + sqe.addr = cast(u64)uintptr(addr) + sqe.addr2 = size_of(T) + + ok = true + return +} + +/* +Issues the equivalent of the listen(2) system call. + +fd must contain the file descriptor of the socket and addr must contain the backlog parameter, i.e. the maximum amount of pending queued connections. + +Available since 6.11. +*/ +listen :: proc(ring: ^Ring, user_data: u64, fd: linux.Fd, backlog: u64) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sqe = get_sqe(ring) or_return + sqe.opcode = .LISTEN + sqe.user_data = user_data + sqe.fd = fd + sqe.addr = backlog + + ok = true + return +} + +ftruncate :: proc() { + unimplemented() +} + +read_multishot :: proc() { + unimplemented() +} + +futex_wait :: proc() { + unimplemented() +} + +futex_wake :: proc() { + unimplemented() +} + +futex_waitv :: proc() { + unimplemented() +} + +fixed_fd_install :: proc() { + unimplemented() +} + +fixed_file :: proc() { + unimplemented() +} diff --git a/core/sys/linux/uring/uring.odin b/core/sys/linux/uring/uring.odin new file mode 100644 index 000000000..8e4315e6a --- /dev/null +++ b/core/sys/linux/uring/uring.odin @@ -0,0 +1,294 @@ +package uring + +import "core:math" +import "core:sync" +import "core:sys/linux" + +DEFAULT_THREAD_IDLE_MS :: 1000 +DEFAULT_ENTRIES :: 32 +MAX_ENTRIES :: 4096 + +Ring :: struct { + fd: linux.Fd, + sq: Submission_Queue, + cq: Completion_Queue, + flags: linux.IO_Uring_Setup_Flags, + features: linux.IO_Uring_Features, +} + +DEFAULT_PARAMS :: linux.IO_Uring_Params { + sq_thread_idle = DEFAULT_THREAD_IDLE_MS, +} + +// Initialize and setup an uring, `entries` must be a power of 2 between 1 and 4096. +init :: proc(ring: ^Ring, params: ^linux.IO_Uring_Params, entries: u32 = DEFAULT_ENTRIES) -> (err: linux.Errno) { + assert(entries <= MAX_ENTRIES, "too many entries") + assert(entries != 0, "entries must be positive") + assert(math.is_power_of_two(int(entries)), "entries must be a power of two") + + fd := linux.io_uring_setup(entries, params) or_return + defer if err != nil { linux.close(fd) } + + if .SINGLE_MMAP not_in params.features { + // NOTE: Could support this, but currently isn't. + err = .ENOSYS + return + } + + assert(.CQE32 not_in params.flags, "unsupported flag") // NOTE: Could support this by making IO_Uring generic. + assert(.SQE128 not_in params.flags, "unsupported flag") // NOTE: Could support this by making IO_Uring generic. + + sq := submission_queue_make(fd, params) or_return + + ring.fd = fd + ring.sq = sq + ring.cq = completion_queue_make(fd, params, &sq) + ring.flags = params.flags + ring.features = params.features + + return +} + +destroy :: proc(ring: ^Ring) { + assert(ring.fd >= 0) + submission_queue_destroy(&ring.sq) + linux.close(ring.fd) + ring.fd = -1 +} + +// Returns a pointer to a vacant submission queue entry, or nil if the submission queue is full. +// NOTE: extra is so you can make sure there is space for related entries, defaults to 1 so +// a link timeout op can always be added after another. +get_sqe :: proc(ring: ^Ring, extra: int = 1) -> (sqe: ^linux.IO_Uring_SQE, ok: bool) { + sq := &ring.sq + head: u32 = sync.atomic_load_explicit(sq.head, .Acquire) + next := sq.sqe_tail + 1 + + if int(next - head) > len(sq.sqes)-extra { + sqe = nil + ok = false + return + } + + sqe = &sq.sqes[sq.sqe_tail & sq.mask] + sqe^ = {} + + sq.sqe_tail = next + ok = true + return +} + +free_space :: proc(ring: ^Ring) -> int { + sq := &ring.sq + head := sync.atomic_load_explicit(sq.head, .Acquire) + next := sq.sqe_tail + 1 + free := len(sq.sqes) - int(next - head) + assert(free >= 0) + return free +} + +// Sync internal state with kernel ring state on the submission queue side. +// Returns the number of all pending events in the submission queue. +// Rationale is to determine that an enter call is needed. +flush_sq :: proc(ring: ^Ring) -> (n_pending: u32) { + sq := &ring.sq + to_submit := sq.sqe_tail - sq.sqe_head + if to_submit != 0 { + tail := sq.tail^ + i: u32 = 0 + for ; i < to_submit; i += 1 { + sq.array[tail & sq.mask] = sq.sqe_head & sq.mask + tail += 1 + sq.sqe_head += 1 + } + sync.atomic_store_explicit(sq.tail, tail, .Release) + } + n_pending = sq_ready(ring) + return +} + +// Returns true if we are not using an SQ thread (thus nobody submits but us), +// or if IORING_SQ_NEED_WAKEUP is set and the SQ thread must be explicitly awakened. +// For the latter case, we set the SQ thread wakeup flag. +// Matches the implementation of sq_ring_needs_enter() in liburing. +sq_ring_needs_enter :: proc(ring: ^Ring, flags: ^linux.IO_Uring_Enter_Flags) -> bool { + assert(flags^ == {}) + if .SQPOLL not_in ring.flags { return true } + if .NEED_WAKEUP in sync.atomic_load_explicit(ring.sq.flags, .Relaxed) { + flags^ += {.SQ_WAKEUP} + return true + } + return false +} + + +// Submits the submission queue entries acquired via get_sqe(). +// Returns the number of entries submitted. +// Optionally wait for a number of events by setting `wait_nr`, and/or set a maximum wait time by setting `timeout`. +submit :: proc(ring: ^Ring, wait_nr: u32 = 0, timeout: ^linux.Time_Spec = nil) -> (n_submitted: u32, err: linux.Errno) { + n_submitted = flush_sq(ring) + flags: linux.IO_Uring_Enter_Flags + if sq_ring_needs_enter(ring, &flags) || wait_nr > 0 { + if wait_nr > 0 || .IOPOLL in ring.flags { + flags += {.GETEVENTS} + } + + flags += {.EXT_ARG} + ext: linux.IO_Uring_Getevents_Arg + ext.ts = timeout + + n_submitted_: int + n_submitted_, err = linux.io_uring_enter2(ring.fd, n_submitted, wait_nr, flags, &ext) + assert(n_submitted_ >= 0) + n_submitted = u32(n_submitted_) + } + return +} + +// Returns the number of submission queue entries in the submission queue. +sq_ready :: proc(ring: ^Ring) -> u32 { + // Always use the shared ring state (i.e. head and not sqe_head) to avoid going out of sync, + // see https://github.com/axboe/liburing/issues/92. + return ring.sq.sqe_tail - sync.atomic_load_explicit(ring.sq.head, .Acquire) +} + +// Returns the number of completion queue entries in the completion queue (yet to consume). +cq_ready :: proc(ring: ^Ring) -> (n_ready: u32) { + return sync.atomic_load_explicit(ring.cq.tail, .Acquire) - ring.cq.head^ +} + +// Copies as many CQEs as are ready, and that can fit into the destination `cqes` slice. +// If none are available, enters into the kernel to wait for at most `wait_nr` CQEs. +// Returns the number of CQEs copied, advancing the CQ ring. +// Provides all the wait/peek methods found in liburing, but with batching and a single method. +// TODO: allow for timeout. +copy_cqes :: proc(ring: ^Ring, cqes: []linux.IO_Uring_CQE, wait_nr: u32) -> (n_copied: u32, err: linux.Errno) { + n_copied = copy_cqes_ready(ring, cqes) + if n_copied > 0 { return } + if wait_nr > 0 || cq_ring_needs_flush(ring) { + _ = linux.io_uring_enter(ring.fd, 0, wait_nr, {.GETEVENTS}, nil) or_return + n_copied = copy_cqes_ready(ring, cqes) + } + return +} + +copy_cqes_ready :: proc(ring: ^Ring, cqes: []linux.IO_Uring_CQE) -> (n_copied: u32) { + n_ready := cq_ready(ring) + n_copied = min(u32(len(cqes)), n_ready) + head := ring.cq.head^ + tail := head + n_copied + shift := u32(.CQE32 in ring.flags) + + i := 0 + for head != tail { + cqes[i] = ring.cq.cqes[(head & ring.cq.mask) << shift] + head += 1 + i += 1 + } + cq_advance(ring, n_copied) + return +} + +cq_ring_needs_flush :: proc(ring: ^Ring) -> bool { + return .CQ_OVERFLOW in sync.atomic_load_explicit(ring.sq.flags, .Relaxed) +} + +// For advanced use cases only that implement custom completion queue methods. +// If you use copy_cqes() or copy_cqe() you must not call cqe_seen() or cq_advance(). +// Must be called exactly once after a zero-copy CQE has been processed by your application. +// Not idempotent, calling more than once will result in other CQEs being lost. +// Matches the implementation of cqe_seen() in liburing. +cqe_seen :: proc(ring: ^Ring) { + cq_advance(ring, 1) +} + +// For advanced use cases only that implement custom completion queue methods. +// Matches the implementation of cq_advance() in liburing. +cq_advance :: proc(ring: ^Ring, count: u32) { + if count == 0 { return } + sync.atomic_store_explicit(ring.cq.head, ring.cq.head^ + count, .Release) +} + +Submission_Queue :: struct { + head: ^u32, + tail: ^u32, + mask: u32, + flags: ^linux.IO_Uring_Submission_Queue_Flags, + dropped: ^u32, + array: []u32, + sqes: []linux.IO_Uring_SQE, + mmap: []u8, + mmap_sqes: []u8, + + // We use `sqe_head` and `sqe_tail` in the same way as liburing: + // We increment `sqe_tail` (but not `tail`) for each call to `get_sqe()`. + // We then set `tail` to `sqe_tail` once, only when these events are actually submitted. + // This allows us to amortize the cost of the @atomicStore to `tail` across multiple SQEs. + sqe_head: u32, + sqe_tail: u32, +} + +submission_queue_make :: proc(fd: linux.Fd, params: ^linux.IO_Uring_Params) -> (sq: Submission_Queue, err: linux.Errno) { + assert(fd >= 0, "uninitialized queue fd") + assert(.SINGLE_MMAP in params.features, "unsupported feature") // NOTE: Could support this, but currently isn't. + + sq_size := params.sq_off.array + params.sq_entries * size_of(u32) + cq_size := params.cq_off.cqes + params.cq_entries * size_of(linux.IO_Uring_CQE) + size := max(sq_size, cq_size) + + // PERF: .POPULATE commits all pages right away, is that desired? + + cqe_map := cast([^]byte)(linux.mmap(0, uint(size), {.READ, .WRITE}, {.SHARED, .POPULATE}, fd, linux.IORING_OFF_SQ_RING) or_return) + defer if err != nil { linux.munmap(cqe_map, uint(size)) } + + size_sqes := params.sq_entries * size_of(linux.IO_Uring_SQE) + sqe_map := cast([^]byte)(linux.mmap(0, uint(size_sqes), {.READ, .WRITE}, {.SHARED, .POPULATE}, fd, linux.IORING_OFF_SQES) or_return) + + array := cast([^]u32)cqe_map[params.sq_off.array:] + sqes := cast([^]linux.IO_Uring_SQE)sqe_map + + sq.head = cast(^u32)&cqe_map[params.sq_off.head] + sq.tail = cast(^u32)&cqe_map[params.sq_off.tail] + sq.mask = (cast(^u32)&cqe_map[params.sq_off.ring_mask])^ + sq.flags = cast(^linux.IO_Uring_Submission_Queue_Flags)&cqe_map[params.sq_off.flags] + sq.dropped = cast(^u32)&cqe_map[params.sq_off.dropped] + sq.array = array[:params.sq_entries] + sq.sqes = sqes[:params.sq_entries] + sq.mmap = cqe_map[:size] + sq.mmap_sqes = sqe_map[:size_sqes] + + return +} + +submission_queue_destroy :: proc(sq: ^Submission_Queue) -> (err: linux.Errno) { + err = linux.munmap(raw_data(sq.mmap), uint(len(sq.mmap))) + err2 := linux.munmap(raw_data(sq.mmap_sqes), uint(len(sq.mmap_sqes))) + if err == nil { err = err2 } + return +} + +Completion_Queue :: struct { + head: ^u32, + tail: ^u32, + mask: u32, + overflow: ^u32, + cqes: []linux.IO_Uring_CQE, +} + +completion_queue_make :: proc(fd: linux.Fd, params: ^linux.IO_Uring_Params, sq: ^Submission_Queue) -> Completion_Queue { + assert(fd >= 0, "uninitialized queue fd") + assert(.SINGLE_MMAP in params.features, "required feature SINGLE_MMAP not supported") + + mmap := sq.mmap + cqes := cast([^]linux.IO_Uring_CQE)&mmap[params.cq_off.cqes] + + return( + { + head = cast(^u32)&mmap[params.cq_off.head], + tail = cast(^u32)&mmap[params.cq_off.tail], + mask = (cast(^u32)&mmap[params.cq_off.ring_mask])^, + overflow = cast(^u32)&mmap[params.cq_off.overflow], + cqes = cqes[:params.cq_entries], + } \ + ) +} diff --git a/core/sys/orca/orca.odin b/core/sys/orca/orca.odin index a36c5fa2a..a0fe0a041 100644 --- a/core/sys/orca/orca.odin +++ b/core/sys/orca/orca.odin @@ -1,15 +1,13 @@ // Bindings for the Orca platform // // See: [[ https://orca-app.dev ]] + package orca import "core:c" char :: c.char -// currently missing in the api.json -window :: distinct u64 - // currently missing in the api.json pool :: struct { arena: arena, @@ -142,17 +140,6 @@ UNICODE_VARIATION_SELECTORS_SUPPLEMENT :: unicode_range { 0xe0100, 239 } UNICODE_SUPPLEMENTARY_PRIVATE_USE_AREA_A :: unicode_range { 0xf0000, 65533 } UNICODE_SUPPLEMENTARY_PRIVATE_USE_AREA_B :: unicode_range { 0x100000, 65533 } -clock_kind :: enum c.int { - MONOTONIC, - UPTIME, - DATE, -} - -@(default_calling_convention="c", link_prefix="oc_") -foreign { - clock_time :: proc(clock: clock_kind) -> f64 --- -} - file_write_slice :: proc(file: file, slice: []char) -> u64 { return file_write(file, u64(len(slice)), raw_data(slice)) } @@ -204,6 +191,26 @@ foreign { mat2x3_rotate :: proc(radians: f32) -> mat2x3 --- // Return a 2x3 matrix representing a translation. mat2x3_translate :: proc(x: f32, y: f32) -> mat2x3 --- + // Return a 2x3 matrix representing a scale. + mat2x3_scale :: proc(x: f32, y: f32) -> mat2x3 --- +} + +//////////////////////////////////////////////////////////////////////////////// +// API for sampling the system clock. +//////////////////////////////////////////////////////////////////////////////// + +clock_kind :: enum u32 { + // A clock incrementing monotonically. + MONOTONIC = 0, + // A clock incrementing monotonically during uptime. + UPTIME = 1, + // A clock driven by the platform time. + DATE = 2, +} + +@(default_calling_convention="c", link_prefix="oc_") +foreign { + clock_time :: proc(clock: clock_kind) -> f64 --- } //////////////////////////////////////////////////////////////////////////////// @@ -354,10 +361,14 @@ foreign { arena_init_with_options :: proc(arena: ^arena, options: ^arena_options) --- // Release all resources allocated to a memory arena. arena_cleanup :: proc(arena: ^arena) --- - // Allocate a block of memory from an arena. + // Allocate a zero initialized block of memory from an arena. arena_push :: proc(arena: ^arena, size: u64) -> rawptr --- - // Allocate an aligned block of memory from an arena. + // Allocate an aligned, zero initialized block of memory from an arena. arena_push_aligned :: proc(arena: ^arena, size: u64, alignment: u32) -> rawptr --- + // Allocate a block of memory from an arena. + arena_push_uninitialized :: proc(arena: ^arena, size: u64) -> rawptr --- + // Allocate an aligned block of memory from an arena. + arena_push_aligned_uninitialized :: proc(arena: ^arena, size: u64, alignment: u32) -> rawptr --- // Reset an arena. All memory that was previously allocated from this arena is released to the arena, and can be reallocated by later calls to `oc_arena_push` and similar functions. No memory is actually released _to the system_. arena_clear :: proc(arena: ^arena) --- // Begin a memory scope. This creates an `oc_arena_scope` object that stores the current offset of the arena. The arena can later be reset to that offset by calling `oc_arena_scope_end`, releasing all memory that was allocated within the scope to the arena. @@ -530,15 +541,15 @@ utf8_status :: enum u32 { // The operation unexpectedly encountered the end of the utf8 sequence. OUT_OF_BOUNDS = 1, // A continuation byte was encountered where a leading byte was expected. - UNEXPECTED_CONTINUATION_BYTE = 3, + UNEXPECTED_CONTINUATION_BYTE = 2, // A leading byte was encountered in the middle of the encoding of utf8 codepoint. - UNEXPECTED_LEADING_BYTE = 4, + UNEXPECTED_LEADING_BYTE = 3, // The utf8 sequence contains an invalid byte. - INVALID_BYTE = 5, + INVALID_BYTE = 4, // The operation encountered an invalid utf8 codepoint. - INVALID_CODEPOINT = 6, + INVALID_CODEPOINT = 5, // The utf8 sequence contains an overlong encoding of a utf8 codepoint. - OVERLONG_ENCODING = 7, + OVERLONG_ENCODING = 6, } // A type representing the result of decoding of utf8-encoded codepoint. @@ -1044,6 +1055,9 @@ file_dialog_result :: struct { selection: str8_list, } +// An opaque handle identifying a window. +window :: distinct u64 + @(default_calling_convention="c", link_prefix="oc_") foreign { // Set the title of the application's window. @@ -1054,8 +1068,93 @@ foreign { request_quit :: proc() --- // Convert a scancode to a keycode, according to current keyboard layout. scancode_to_keycode :: proc(scanCode: scan_code) -> key_code --- +} + +//////////////////////////////////////////////////////////////////////////////// +// Application user input. +//////////////////////////////////////////////////////////////////////////////// + +key_state :: struct { + lastUpdate: u64, + transitionCount: u32, + repeatCount: u32, + down: bool, + sysClicked: bool, + sysDoubleClicked: bool, + sysTripleClicked: bool, +} + +keyboard_state :: struct { + keys: [349]key_state, + mods: keymod_flags, +} + +mouse_state :: struct { + lastUpdate: u64, + posValid: bool, + pos: vec2, + delta: vec2, + wheel: vec2, + using _: struct #raw_union { + buttons: [5]key_state, + using _: struct { + left: key_state, + right: key_state, + middle: key_state, + ext1: key_state, + ext2: key_state, + }, + }, +} + +BACKING_SIZE :: 64 + +text_state :: struct { + lastUpdate: u64, + backing: [64]utf32, + codePoints: str32, +} + +clipboard_state :: struct { + lastUpdate: u64, + pastedText: str8, +} + +input_state :: struct { + frameCounter: u64, + keyboard: keyboard_state, + mouse: mouse_state, + text: text_state, + clipboard: clipboard_state, +} + +@(default_calling_convention="c", link_prefix="oc_") +foreign { + input_process_event :: proc(arena: ^arena, state: ^input_state, event: ^event) --- + input_next_frame :: proc(state: ^input_state) --- + key_down :: proc(state: ^input_state, key: key_code) -> bool --- + key_press_count :: proc(state: ^input_state, key: key_code) -> u8 --- + key_release_count :: proc(state: ^input_state, key: key_code) -> u8 --- + key_repeat_count :: proc(state: ^input_state, key: key_code) -> u8 --- + key_down_scancode :: proc(state: ^input_state, key: scan_code) -> bool --- + key_press_count_scancode :: proc(state: ^input_state, key: scan_code) -> u8 --- + key_release_count_scancode :: proc(state: ^input_state, key: scan_code) -> u8 --- + key_repeat_count_scancode :: proc(state: ^input_state, key: scan_code) -> u8 --- + mouse_down :: proc(state: ^input_state, button: mouse_button) -> bool --- + mouse_pressed :: proc(state: ^input_state, button: mouse_button) -> u8 --- + mouse_released :: proc(state: ^input_state, button: mouse_button) -> u8 --- + mouse_clicked :: proc(state: ^input_state, button: mouse_button) -> bool --- + mouse_double_clicked :: proc(state: ^input_state, button: mouse_button) -> bool --- + mouse_position :: proc(state: ^input_state) -> vec2 --- + mouse_delta :: proc(state: ^input_state) -> vec2 --- + mouse_wheel :: proc(state: ^input_state) -> vec2 --- + input_text_utf32 :: proc(arena: ^arena, state: ^input_state) -> str32 --- + input_text_utf8 :: proc(arena: ^arena, state: ^input_state) -> str8 --- // Put a string in the clipboard. clipboard_set_string :: proc(string: str8) --- + clipboard_pasted :: proc(state: ^input_state) -> bool --- + clipboard_pasted_text :: proc(state: ^input_state) -> str8 --- + key_mods :: proc(state: ^input_state) -> keymod_flags --- } //////////////////////////////////////////////////////////////////////////////// @@ -1073,7 +1172,7 @@ file :: distinct u64 // Flags for the `oc_file_open()` function. file_open_flag :: enum u16 { // Open the file in 'append' mode. All writes append data at the end of the file. - APPEND = 1, + APPEND = 0, // Truncate the file to 0 bytes when opening. TRUNCATE, // Create the file if it does not exist. @@ -1090,7 +1189,7 @@ file_open_flags :: bit_set[file_open_flag; u16] // This enum describes the access permissions of a file handle. file_access_flag :: enum u16 { // The file handle can be used for reading from the file. - READ = 1, + READ = 0, // The file handle can be used for writing to the file. WRITE, } @@ -1242,7 +1341,7 @@ file_type :: enum u32 { // A type describing file permissions. file_perm_flag :: enum u16 { - OTHER_EXEC = 1, + OTHER_EXEC = 0, OTHER_WRITE, OTHER_READ, GROUP_EXEC, @@ -1272,6 +1371,18 @@ file_status :: struct { modificationDate: datestamp, } +// An type describing a list of enumerated files in a given directory. +file_list :: struct { + list: list, + eltCount: u64, +} + +file_listdir_elt :: struct { + listElt: list_elt, + basename: str8, + type: file_type, +} + @(default_calling_convention="c", link_prefix="oc_") foreign { // Send a single I/O request and wait for its completion. @@ -1299,6 +1410,7 @@ foreign { file_get_status :: proc(file: file) -> file_status --- file_size :: proc(file: file) -> u64 --- file_open_with_request :: proc(path: str8, rights: file_access, flags: file_open_flags) -> file --- + file_listdir :: proc(arena: ^arena, directory: str8) -> file_list --- } //////////////////////////////////////////////////////////////////////////////// @@ -1703,87 +1815,6 @@ foreign { // Graphical User Interface API. //////////////////////////////////////////////////////////////////////////////// -key_state :: struct { - lastUpdate: u64, - transitionCount: u32, - repeatCount: u32, - down: bool, - sysClicked: bool, - sysDoubleClicked: bool, - sysTripleClicked: bool, -} - -keyboard_state :: struct { - keys: [349]key_state, - mods: keymod_flags, -} - -mouse_state :: struct { - lastUpdate: u64, - posValid: bool, - pos: vec2, - delta: vec2, - wheel: vec2, - using _: struct #raw_union { - buttons: [5]key_state, - using _: struct { - left: key_state, - right: key_state, - middle: key_state, - ext1: key_state, - ext2: key_state, - }, - }, -} - -BACKING_SIZE :: 64 - -text_state :: struct { - lastUpdate: u64, - backing: [64]utf32, - codePoints: str32, -} - -clipboard_state :: struct { - lastUpdate: u64, - pastedText: str8, -} - -input_state :: struct { - frameCounter: u64, - keyboard: keyboard_state, - mouse: mouse_state, - text: text_state, - clipboard: clipboard_state, -} - -@(default_calling_convention="c", link_prefix="oc_") -foreign { - input_process_event :: proc(arena: ^arena, state: ^input_state, event: ^event) --- - input_next_frame :: proc(state: ^input_state) --- - key_down :: proc(state: ^input_state, key: key_code) -> bool --- - key_press_count :: proc(state: ^input_state, key: key_code) -> u8 --- - key_release_count :: proc(state: ^input_state, key: key_code) -> u8 --- - key_repeat_count :: proc(state: ^input_state, key: key_code) -> u8 --- - key_down_scancode :: proc(state: ^input_state, key: scan_code) -> bool --- - key_press_count_scancode :: proc(state: ^input_state, key: scan_code) -> u8 --- - key_release_count_scancode :: proc(state: ^input_state, key: scan_code) -> u8 --- - key_repeat_count_scancode :: proc(state: ^input_state, key: scan_code) -> u8 --- - mouse_down :: proc(state: ^input_state, button: mouse_button) -> bool --- - mouse_pressed :: proc(state: ^input_state, button: mouse_button) -> u8 --- - mouse_released :: proc(state: ^input_state, button: mouse_button) -> u8 --- - mouse_clicked :: proc(state: ^input_state, button: mouse_button) -> bool --- - mouse_double_clicked :: proc(state: ^input_state, button: mouse_button) -> bool --- - mouse_position :: proc(state: ^input_state) -> vec2 --- - mouse_delta :: proc(state: ^input_state) -> vec2 --- - mouse_wheel :: proc(state: ^input_state) -> vec2 --- - input_text_utf32 :: proc(arena: ^arena, state: ^input_state) -> str32 --- - input_text_utf8 :: proc(arena: ^arena, state: ^input_state) -> str8 --- - clipboard_pasted :: proc(state: ^input_state) -> bool --- - clipboard_pasted_text :: proc(state: ^input_state) -> str8 --- - key_mods :: proc(state: ^input_state) -> keymod_flags --- -} - //////////////////////////////////////////////////////////////////////////////// // Graphical User Interface Core API. //////////////////////////////////////////////////////////////////////////////// @@ -1857,11 +1888,11 @@ ui_attribute_mask :: enum u32 { SIZE_WIDTH = 1, SIZE_HEIGHT = 2, LAYOUT_AXIS = 4, - LAYOUT_ALIGN_X = 64, - LAYOUT_ALIGN_Y = 128, - LAYOUT_SPACING = 32, LAYOUT_MARGIN_X = 8, LAYOUT_MARGIN_Y = 16, + LAYOUT_SPACING = 32, + LAYOUT_ALIGN_X = 64, + LAYOUT_ALIGN_Y = 128, FLOATING_X = 256, FLOATING_Y = 512, FLOAT_TARGET_X = 1024, @@ -1873,10 +1904,10 @@ ui_attribute_mask :: enum u32 { COLOR = 65536, BG_COLOR = 131072, BORDER_COLOR = 262144, - BORDER_SIZE = 2097152, - ROUNDNESS = 4194304, FONT = 524288, FONT_SIZE = 1048576, + BORDER_SIZE = 2097152, + ROUNDNESS = 4194304, DRAW_MASK = 8388608, ANIMATION_TIME = 16777216, ANIMATION_MASK = 33554432, @@ -1898,6 +1929,7 @@ ui_box_size :: [2]ui_size ui_box_floating :: [2]bool +// These bits *disable* the corresponding element when they're set. ui_draw_mask :: enum u32 { BACKGROUND = 1, BORDER = 2, diff --git a/core/sys/posix/fcntl.odin b/core/sys/posix/fcntl.odin index db095c418..52d97f528 100644 --- a/core/sys/posix/fcntl.odin +++ b/core/sys/posix/fcntl.odin @@ -70,7 +70,7 @@ foreign lib { [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html ]] */ - openat :: proc(fd: FD, path: cstring, flags: O_Flags, mode: mode_t = {}) -> FD --- + openat :: proc(fd: FD, path: cstring, flags: O_Flags, #c_vararg mode: ..mode_t) -> FD --- } FCNTL_Cmd :: enum c.int { diff --git a/core/sys/wasm/js/dom.odin b/core/sys/wasm/js/dom.odin index 902dfc941..6dd9dbf45 100644 --- a/core/sys/wasm/js/dom.odin +++ b/core/sys/wasm/js/dom.odin @@ -15,13 +15,15 @@ foreign dom_lib { get_element_value_string_length :: proc(id: string) -> int --- set_element_key_string :: proc(id: string, key: string, value: string) --- - get_element_key_string_length :: proc(id: string, key: string, ) -> int --- + get_element_key_string_length :: proc(id: string, key: string) -> int --- device_pixel_ratio :: proc() -> f64 --- window_set_scroll :: proc(x, y: f64) --- set_element_style :: proc(id: string, key: string, value: string) --- + + set_document_title :: proc(title: string) --- } get_element_value_string :: proc "contextless" (id: string, buf: []byte) -> string { diff --git a/core/sys/wasm/js/odin.js b/core/sys/wasm/js/odin.js index 43a6b002a..19ac3093e 100644 --- a/core/sys/wasm/js/odin.js +++ b/core/sys/wasm/js/odin.js @@ -616,6 +616,9 @@ class WebGLInterface { FramebufferTexture2D: (target, attachment, textarget, texture, level) => { this.ctx.framebufferTexture2D(target, attachment, textarget, this.textures[texture], level); }, + CheckFramebufferStatus: (target) => { + return this.ctx.checkFramebufferStatus(target) + }, FrontFace: (mode) => { this.ctx.frontFace(mode); }, @@ -625,6 +628,47 @@ class WebGLInterface { this.ctx.generateMipmap(target); }, + GetActiveAttrib: (program, index, size_ptr, type_ptr, name_buf_ptr, name_buf_len, name_len_ptr) => { + const info = this.ctx.getActiveAttrib(this.programs[program], index); + + if (size_ptr) { + this.mem.storeInt(size_ptr, info.size); + } + + if (type_ptr) { + this.mem.storeI32(type_ptr, info.type); + } + + if (name_buf_ptr && name_buf_len > 0) { + let n = Math.min(name_buf_len, info.name.length); + let name = info.name.substring(0, n); + this.mem.loadBytes(name_buf_ptr, name_buf_len).set(new TextEncoder().encode(name)); + this.mem.storeInt(name_len_ptr, n); + } else if (name_len_ptr) { + this.mem.storeInt(name_len_ptr, info.name.length); + } + }, + + GetActiveUniform: (program, index, size_ptr, type_ptr, name_buf_ptr, name_buf_len, name_len_ptr) => { + let info = this.ctx.getActiveUniform(this.programs[program], index); + + if (size_ptr) { + this.mem.storeInt(size_ptr, info.size); + } + + if (type_ptr) { + this.mem.storeI32(type_ptr, info.type); + } + + if (name_buf_ptr && name_buf_len > 0) { + let n = Math.min(name_buf_len, info.name.length); + let name = info.name.substring(0, n); + this.mem.loadBytes(name_buf_ptr, name_buf_len).set(new TextEncoder().encode(name)); + this.mem.storeInt(name_len_ptr, n); + } else if (name_len_ptr) { + this.mem.storeInt(name_len_ptr, info.name.length); + } + }, GetAttribLocation: (program, name_ptr, name_len) => { let name = this.mem.loadString(name_ptr, name_len); @@ -1260,15 +1304,34 @@ class WebGLInterface { this.assertWebGL2(); return this.ctx.getUniformBlockIndex(this.programs[program], this.mem.loadString(uniformBlockName_ptr, uniformBlockName_len)); }, - // any getActiveUniformBlockParameter(WebGLProgram program, GLuint uniformBlockIndex, GLenum pname); - GetActiveUniformBlockName: (program, uniformBlockIndex, buf_ptr, buf_len, length_ptr) => { + GetActiveUniformBlockName: (program, uniformBlockIndex, name_buf_ptr, name_buf_len, name_length_ptr) => { this.assertWebGL2(); let name = this.ctx.getActiveUniformBlockName(this.programs[program], uniformBlockIndex); - let n = Math.min(buf_len, name.length); - name = name.substring(0, n); - this.mem.loadBytes(buf_ptr, buf_len).set(new TextEncoder().encode(name)) - this.mem.storeInt(length_ptr, n); + if (name_buf_ptr && name_buf_len > 0) { + let n = Math.min(name_buf_len, name.length); + name = name.substring(0, n); + this.mem.loadBytes(name_buf_ptr, name_buf_len).set(new TextEncoder().encode(name)); + this.mem.storeInt(name_length_ptr, n); + } else if (name_length_ptr) { + this.mem.storeInt(name_length_ptr, name.length); + } + }, + GetActiveUniforms: (program, uniformIndices_ptr, uniformIndices_len, pname, res_ptr) => { + this.assertWebGL2(); + let indices = this.mem.loadU32Array(uniformIndices_ptr, uniformIndices_len); + this.ctx.getActiveUniforms(this.programs[program], indices, pname) + this.mem.loadI32Array(res_ptr, indices.length).set(indices) + }, + GetActiveUniformBlockParameter: (program, uniformBlockIndex, pname, params_ptr) => { + this.assertWebGL2(); + let res = this.ctx.getActiveUniformBlockParameter(this.programs[program], uniformBlockIndex, pname); + + if (res instanceof Uint32Array) { // for pname GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES + this.mem.loadU32Array(params_ptr, res.length).set(res) + } else { + this.mem.storeI32(params_ptr, res) + } }, UniformBlockBinding: (program, uniformBlockIndex, uniformBlockBinding) => { this.assertWebGL2(); @@ -1840,6 +1903,7 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement, memory) { return false; }, + // Writes a struct of type `Gamepad_State`, see `core/sys/wasm/js/events.odin` get_gamepad_state: (gamepad_id, ep) => { let index = gamepad_id; let gps = navigator.getGamepads(); @@ -1986,6 +2050,11 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement, memory) { } }, + set_document_title: (title_ptr, title_len) => { + let title = wasmMemoryInterface.loadString(title_ptr, title_len); + document.title = title; + }, + get_element_key_f64: (id_ptr, id_len, key_ptr, key_len) => { let id = wasmMemoryInterface.loadString(id_ptr, id_len); let key = wasmMemoryInterface.loadString(key_ptr, key_len); @@ -2107,7 +2176,7 @@ async function runWasm(wasmPath, consoleElement, extraForeignImports, wasmMemory if (exports.memory) { if (wasmMemoryInterface.memory) { - console.warn("WASM module exports memory, but `runWasm` was given an interface with existing memory too"); + console.warn('WASM module exports memory, but `runWasm` was given an interface with existing memory too. Did you mean to use `-extra-linker-flags:"--import-memory"` to tell the compiler not to export memory?'); } wasmMemoryInterface.setMemory(exports.memory); } diff --git a/core/sys/win32/removal.odin b/core/sys/win32/removal.odin deleted file mode 100644 index 09c16aa05..000000000 --- a/core/sys/win32/removal.odin +++ /dev/null @@ -1,3 +0,0 @@ -package sys_win32 - -#panic(`"core:sys/win32" has been removed. Please use "core:sys/windows"`) \ No newline at end of file diff --git a/core/sys/windows/advapi32.odin b/core/sys/windows/advapi32.odin index 22cb27863..d4b86b875 100644 --- a/core/sys/windows/advapi32.odin +++ b/core/sys/windows/advapi32.odin @@ -228,7 +228,7 @@ foreign advapi32 { } PTOKEN_INFORMATION_CLASS :: ^TOKEN_INFORMATION_CLASS -TOKEN_INFORMATION_CLASS :: enum i32 { +TOKEN_INFORMATION_CLASS :: enum c_int { TokenUser = 1, TokenGroups, TokenPrivileges, @@ -282,7 +282,7 @@ TOKEN_INFORMATION_CLASS :: enum i32 { } PSID_NAME_USE :: ^SID_NAME_USE -SID_NAME_USE :: enum i32 { +SID_NAME_USE :: enum c_int { SidTypeUser = 1, SidTypeGroup, SidTypeDomain, @@ -303,35 +303,35 @@ TOKEN_USER :: struct { PSID_AND_ATTRIBUTES :: ^SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES :: struct { - Sid: rawptr, + Sid: rawptr, Attributes: ULONG, } PTOKEN_TYPE :: ^TOKEN_TYPE TOKEN_TYPE :: enum { - TokenPrimary = 1, + TokenPrimary = 1, TokenImpersonation = 2, } PTOKEN_STATISTICS :: ^TOKEN_STATISTICS TOKEN_STATISTICS :: struct { - TokenId: LUID, - AuthenticationId: LUID, - ExpirationTime: LARGE_INTEGER, - TokenType: TOKEN_TYPE, + TokenId: LUID, + AuthenticationId: LUID, + ExpirationTime: LARGE_INTEGER, + TokenType: TOKEN_TYPE, ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL, - DynamicCharged: DWORD, - DynamicAvailable: DWORD, - GroupCount: DWORD, - PrivilegeCount: DWORD, - ModifiedId: LUID, + DynamicCharged: DWORD, + DynamicAvailable: DWORD, + GroupCount: DWORD, + PrivilegeCount: DWORD, + ModifiedId: LUID, } TOKEN_SOURCE_LENGTH :: 8 PTOKEN_SOURCE :: ^TOKEN_SOURCE TOKEN_SOURCE :: struct { - SourceName: [TOKEN_SOURCE_LENGTH]CHAR, + SourceName: [TOKEN_SOURCE_LENGTH]CHAR, SourceIdentifier: LUID, } @@ -339,7 +339,7 @@ TOKEN_SOURCE :: struct { PTOKEN_PRIVILEGES :: ^TOKEN_PRIVILEGES TOKEN_PRIVILEGES :: struct { PrivilegeCount: DWORD, - Privileges: [0]LUID_AND_ATTRIBUTES, + Privileges: [0]LUID_AND_ATTRIBUTES, } PTOKEN_PRIMARY_GROUP :: ^TOKEN_PRIMARY_GROUP @@ -354,16 +354,16 @@ TOKEN_OWNER :: struct { PTOKEN_GROUPS_AND_PRIVILEGES :: ^TOKEN_GROUPS_AND_PRIVILEGES TOKEN_GROUPS_AND_PRIVILEGES :: struct { - SidCount: DWORD, - SidLength: DWORD, - Sids: PSID_AND_ATTRIBUTES, - RestrictedSidCount: DWORD, + SidCount: DWORD, + SidLength: DWORD, + Sids: PSID_AND_ATTRIBUTES, + RestrictedSidCount: DWORD, RestrictedSidLength: DWORD, - RestrictedSids: PSID_AND_ATTRIBUTES, - PrivilegeCount: DWORD, - PrivilegeLength: DWORD, - Privileges: PLUID_AND_ATTRIBUTES, - AuthenticationId: LUID, + RestrictedSids: PSID_AND_ATTRIBUTES, + PrivilegeCount: DWORD, + PrivilegeLength: DWORD, + Privileges: PLUID_AND_ATTRIBUTES, + AuthenticationId: LUID, } PTOKEN_DEFAULT_DACL :: ^TOKEN_DEFAULT_DACL @@ -374,8 +374,8 @@ TOKEN_DEFAULT_DACL :: struct { PACL :: ^ACL ACL :: struct { AclRevision: BYTE, - Sbz1: BYTE, - AclSize: WORD, - AceCount: WORD, - Sbz2: WORD, + Sbz1: BYTE, + AclSize: WORD, + AceCount: WORD, + Sbz2: WORD, } diff --git a/core/sys/windows/comctl32.odin b/core/sys/windows/comctl32.odin index c7a166634..28fab53be 100644 --- a/core/sys/windows/comctl32.odin +++ b/core/sys/windows/comctl32.odin @@ -5,9 +5,9 @@ foreign import "system:Comctl32.lib" @(default_calling_convention="system") foreign Comctl32 { - InitCommonControlsEx :: proc(picce: ^INITCOMMONCONTROLSEX) -> BOOL --- + InitCommonControlsEx :: proc(picce: ^INITCOMMONCONTROLSEX) -> BOOL --- LoadIconWithScaleDown :: proc(hinst: HINSTANCE, pszName: PCWSTR, cx: c_int, cy: c_int, phico: ^HICON) -> HRESULT --- - SetWindowSubclass :: proc(hwnd: HWND, pfnSubclass: SUBCLASSPROC, uIdSubclass: UINT_PTR, dwRefData: DWORD_PTR) --- + SetWindowSubclass :: proc(hwnd: HWND, pfnSubclass: SUBCLASSPROC, uIdSubclass: UINT_PTR, dwRefData: DWORD_PTR) --- } ICC_LISTVIEW_CLASSES :: 0x00000001 @@ -155,85 +155,85 @@ ILP_NORMAL :: 0 ILP_DOWNLEVEL :: 1 IMAGELISTDRAWPARAMS :: struct { - cbSize: DWORD, - himl: HIMAGELIST, - i: i32, - hdcDst: HDC, - x: i32, - y: i32, - cx: i32, - cy: i32, - xBitmap: i32, - yBitmap: i32, - rgbBk: COLORREF, - rgbFg: COLORREF, - fStyle: UINT, - dwRop: DWORD, - fState: DWORD, - Frame: DWORD, + cbSize: DWORD, + himl: HIMAGELIST, + i: c_int, + hdcDst: HDC, + x: c_int, + y: c_int, + cx: c_int, + cy: c_int, + xBitmap: c_int, + yBitmap: c_int, + rgbBk: COLORREF, + rgbFg: COLORREF, + fStyle: UINT, + dwRop: DWORD, + fState: DWORD, + Frame: DWORD, crEffect: COLORREF, } LPIMAGELISTDRAWPARAMS :: ^IMAGELISTDRAWPARAMS IMAGEINFO :: struct { hbmImage: HBITMAP, - hbmMask: HBITMAP, - Unused1: i32, - Unused2: i32, - rcImage: RECT, + hbmMask: HBITMAP, + Unused1: c_int, + Unused2: c_int, + rcImage: RECT, } LPIMAGEINFO :: ^IMAGEINFO @(default_calling_convention="system") foreign Comctl32 { - ImageList_Create :: proc(cx, cy: i32, flags: UINT, cInitial, cGrow: i32) -> HIMAGELIST --- - ImageList_Destroy :: proc(himl: HIMAGELIST) -> BOOL --- - ImageList_GetImageCount :: proc(himl: HIMAGELIST) -> i32 --- - ImageList_SetImageCount :: proc(himl: HIMAGELIST, uNewCount: UINT) -> BOOL --- - ImageList_Add :: proc(himl: HIMAGELIST, hbmImage, hbmMask: HBITMAP) -> i32 --- - ImageList_ReplaceIcon :: proc(himl: HIMAGELIST, i: i32, hicon: HICON) -> i32 --- - ImageList_SetBkColor :: proc(himl: HIMAGELIST, clrBk: COLORREF) -> COLORREF --- - ImageList_GetBkColor :: proc(himl: HIMAGELIST) -> COLORREF --- - ImageList_SetOverlayImage :: proc(himl: HIMAGELIST, iImage: i32, iOverlay: i32) -> BOOL --- - ImageList_Draw :: proc(himl: HIMAGELIST, i: i32, hdcDst: HDC, x, y: i32, fStyle: UINT) -> BOOL --- - ImageList_Replace :: proc(himl: HIMAGELIST, i: i32, hbmImage, hbmMask: HBITMAP) -> BOOL --- - ImageList_AddMasked :: proc(himl: HIMAGELIST, hbmImage: HBITMAP, crMask: COLORREF) -> i32 --- - ImageList_DrawEx :: proc(himl: HIMAGELIST, i: i32, hdcDst: HDC, x, y, dx, dy: i32, rgbBk, rgbFg: COLORREF, fStyle: UINT) -> BOOL --- - ImageList_DrawIndirect :: proc(pimldp: ^IMAGELISTDRAWPARAMS) -> BOOL --- - ImageList_Remove :: proc(himl: HIMAGELIST, i: i32) -> BOOL --- - ImageList_GetIcon :: proc(himl: HIMAGELIST, i: i32, flags: UINT) -> HICON --- - ImageList_LoadImageW :: proc(hi: HINSTANCE, lpbmp: LPCWSTR, cx, cgrow: i32, crMask: COLORREF, uType, uFlags: UINT) -> HIMAGELIST --- - ImageList_Copy :: proc(himlDst: HIMAGELIST, iDst: i32, himlSrc: HIMAGELIST, iSrc: i32, uFlags: UINT) -> BOOL --- - ImageList_BeginDrag :: proc(himlTrack: HIMAGELIST, iTrack, dxHotspot, dyHotspot: i32) -> BOOL --- - ImageList_EndDrag :: proc() --- - ImageList_DragEnter :: proc(hwndLock: HWND, x, y: i32) -> BOOL --- - ImageList_DragLeave :: proc(hwndLock: HWND) -> BOOL --- - ImageList_DragMove :: proc(x, y: i32) -> BOOL --- - ImageList_SetDragCursorImage :: proc(himlDrag: HIMAGELIST, iDrag, dxHotspot, dyHotspot: i32) -> BOOL --- - ImageList_DragShowNolock :: proc(fShow: BOOL) -> BOOL --- - ImageList_GetDragImage :: proc(ppt, pptHotspot: ^POINT) -> HIMAGELIST --- - ImageList_Read :: proc(pstm: ^IStream) -> HIMAGELIST --- - ImageList_Write :: proc(himl: HIMAGELIST, pstm: ^IStream) -> BOOL --- - ImageList_ReadEx :: proc(dwFlags: DWORD, pstm: ^IStream, riid: REFIID, ppv: PVOID) -> HRESULT --- - ImageList_WriteEx :: proc(himl: HIMAGELIST, dwFlags: DWORD, pstm: ^IStream) -> HRESULT --- - ImageList_GetIconSize :: proc(himl: HIMAGELIST, cx, cy: ^i32) -> BOOL --- - ImageList_SetIconSize :: proc(himl: HIMAGELIST, cx, cy: i32) -> BOOL --- - ImageList_GetImageInfo :: proc(himl: HIMAGELIST, i: i32, pImageInfo: ^IMAGEINFO) -> BOOL --- - ImageList_Merge :: proc(himl1: HIMAGELIST, i1: i32, himl2: HIMAGELIST, i2: i32, dx, dy: i32) -> HIMAGELIST --- - ImageList_Duplicate :: proc(himl: HIMAGELIST) -> HIMAGELIST --- - HIMAGELIST_QueryInterface :: proc(himl: HIMAGELIST, riid: REFIID, ppv: rawptr) -> HRESULT --- + ImageList_Create :: proc(cx, cy: c_int, flags: UINT, cInitial, cGrow: c_int) -> HIMAGELIST --- + ImageList_Destroy :: proc(himl: HIMAGELIST) -> BOOL --- + ImageList_GetImageCount :: proc(himl: HIMAGELIST) -> c_int --- + ImageList_SetImageCount :: proc(himl: HIMAGELIST, uNewCount: UINT) -> BOOL --- + ImageList_Add :: proc(himl: HIMAGELIST, hbmImage, hbmMask: HBITMAP) -> c_int --- + ImageList_ReplaceIcon :: proc(himl: HIMAGELIST, i: c_int, hicon: HICON) -> c_int --- + ImageList_SetBkColor :: proc(himl: HIMAGELIST, clrBk: COLORREF) -> COLORREF --- + ImageList_GetBkColor :: proc(himl: HIMAGELIST) -> COLORREF --- + ImageList_SetOverlayImage :: proc(himl: HIMAGELIST, iImage: c_int, iOverlay: c_int) -> BOOL --- + ImageList_Draw :: proc(himl: HIMAGELIST, i: c_int, hdcDst: HDC, x, y: c_int, fStyle: UINT) -> BOOL --- + ImageList_Replace :: proc(himl: HIMAGELIST, i: c_int, hbmImage, hbmMask: HBITMAP) -> BOOL --- + ImageList_AddMasked :: proc(himl: HIMAGELIST, hbmImage: HBITMAP, crMask: COLORREF) -> c_int --- + ImageList_DrawEx :: proc(himl: HIMAGELIST, i: c_int, hdcDst: HDC, x, y, dx, dy: c_int, rgbBk, rgbFg: COLORREF, fStyle: UINT) -> BOOL --- + ImageList_DrawIndirect :: proc(pimldp: ^IMAGELISTDRAWPARAMS) -> BOOL --- + ImageList_Remove :: proc(himl: HIMAGELIST, i: c_int) -> BOOL --- + ImageList_GetIcon :: proc(himl: HIMAGELIST, i: c_int, flags: UINT) -> HICON --- + ImageList_LoadImageW :: proc(hi: HINSTANCE, lpbmp: LPCWSTR, cx, cgrow: c_int, crMask: COLORREF, uType, uFlags: UINT) -> HIMAGELIST --- + ImageList_Copy :: proc(himlDst: HIMAGELIST, iDst: c_int, himlSrc: HIMAGELIST, iSrc: c_int, uFlags: UINT) -> BOOL --- + ImageList_BeginDrag :: proc(himlTrack: HIMAGELIST, iTrack, dxHotspot, dyHotspot: c_int) -> BOOL --- + ImageList_EndDrag :: proc() --- + ImageList_DragEnter :: proc(hwndLock: HWND, x, y: c_int) -> BOOL --- + ImageList_DragLeave :: proc(hwndLock: HWND) -> BOOL --- + ImageList_DragMove :: proc(x, y: c_int) -> BOOL --- + ImageList_SetDragCursorImage :: proc(himlDrag: HIMAGELIST, iDrag, dxHotspot, dyHotspot: c_int) -> BOOL --- + ImageList_DragShowNolock :: proc(fShow: BOOL) -> BOOL --- + ImageList_GetDragImage :: proc(ppt, pptHotspot: ^POINT) -> HIMAGELIST --- + ImageList_Read :: proc(pstm: ^IStream) -> HIMAGELIST --- + ImageList_Write :: proc(himl: HIMAGELIST, pstm: ^IStream) -> BOOL --- + ImageList_ReadEx :: proc(dwFlags: DWORD, pstm: ^IStream, riid: REFIID, ppv: PVOID) -> HRESULT --- + ImageList_WriteEx :: proc(himl: HIMAGELIST, dwFlags: DWORD, pstm: ^IStream) -> HRESULT --- + ImageList_GetIconSize :: proc(himl: HIMAGELIST, cx, cy: ^c_int) -> BOOL --- + ImageList_SetIconSize :: proc(himl: HIMAGELIST, cx, cy: c_int) -> BOOL --- + ImageList_GetImageInfo :: proc(himl: HIMAGELIST, i: c_int, pImageInfo: ^IMAGEINFO) -> BOOL --- + ImageList_Merge :: proc(himl1: HIMAGELIST, i1: c_int, himl2: HIMAGELIST, i2: c_int, dx, dy: c_int) -> HIMAGELIST --- + ImageList_Duplicate :: proc(himl: HIMAGELIST) -> HIMAGELIST --- + HIMAGELIST_QueryInterface :: proc(himl: HIMAGELIST, riid: REFIID, ppv: rawptr) -> HRESULT --- } -ImageList_AddIcon :: #force_inline proc "system" (himl: HIMAGELIST, hicon: HICON) -> i32 { +ImageList_AddIcon :: #force_inline proc "system" (himl: HIMAGELIST, hicon: HICON) -> c_int { return ImageList_ReplaceIcon(himl, -1, hicon) } ImageList_RemoveAll :: #force_inline proc "system" (himl: HIMAGELIST) -> BOOL { return ImageList_Remove(himl, -1) } -ImageList_ExtractIcon :: #force_inline proc "system" (hi: HINSTANCE, himl: HIMAGELIST, i: i32) -> HICON { +ImageList_ExtractIcon :: #force_inline proc "system" (hi: HINSTANCE, himl: HIMAGELIST, i: c_int) -> HICON { return ImageList_GetIcon(himl, i, 0) } -ImageList_LoadBitmap :: #force_inline proc "system" (hi: HINSTANCE, lpbmp: LPCWSTR, cx, cGrow: i32, crMask: COLORREF) -> HIMAGELIST { +ImageList_LoadBitmap :: #force_inline proc "system" (hi: HINSTANCE, lpbmp: LPCWSTR, cx, cGrow: c_int, crMask: COLORREF) -> HIMAGELIST { return ImageList_LoadImageW(hi, lpbmp, cx, cGrow, crMask, IMAGE_BITMAP, 0) } @@ -1609,9 +1609,9 @@ LPTV_ITEMEXW :: LPTVITEMEXW TVINSERTSTRUCTW :: struct { hParent: HTREEITEM, hInsertAfter: HTREEITEM, - _: struct #raw_union { - itemex: TVITEMEXW, - item: TV_ITEMW, + using _: struct #raw_union { + itemex: TVITEMEXW, + item: TV_ITEMW, }, } TV_INSERTSTRUCTW :: TVINSERTSTRUCTW @@ -1703,7 +1703,7 @@ TreeView_Expand :: #force_inline proc "system" (hwnd: HWND, hitem: HTREEITEM, co } TreeView_GetItemRect :: #force_inline proc "system" (hwnd: HWND, hitem: HTREEITEM, prc: ^RECT, code: UINT) -> BOOL { alias: struct #raw_union { - rc: ^RECT, + rc: ^RECT, hitem: ^HTREEITEM, } diff --git a/core/sys/windows/dbghelp.odin b/core/sys/windows/dbghelp.odin index e32b4c874..4904c5fb4 100644 --- a/core/sys/windows/dbghelp.odin +++ b/core/sys/windows/dbghelp.odin @@ -55,23 +55,54 @@ MINIDUMP_CALLBACK_INFORMATION :: struct { CallbackParam: PVOID, } +MINIDUMP_CALLBACK_TYPE :: enum ULONG { + ModuleCallback, + ThreadCallback, + ThreadExCallback, + IncludeThreadCallback, + IncludeModuleCallback, + MemoryCallback, + CancelCallback, + WriteKernelMinidumpCallback, + KernelMinidumpStatusCallback, + RemoveMemoryCallback, + IncludeVmRegionCallback, + IoStartCallback, + IoWriteAllCallback, + IoFinishCallback, + ReadMemoryFailureCallback, + SecondaryFlagsCallback, + IsProcessSnapshotCallback, + VmStartCallback, + VmQueryCallback, + VmPreReadCallback, + VmPostReadCallback, +} + +MINIDUMP_SECONDARY_FLAG :: enum ULONG { + WithoutPowerInfo = 0, +} +MINIDUMP_SECONDARY_FLAGS :: distinct bit_set[MINIDUMP_SECONDARY_FLAG; ULONG] +MiniSecondaryWithoutPowerInfo :: MINIDUMP_SECONDARY_FLAGS{.WithoutPowerInfo} +MiniSecondaryValidFlags :: MINIDUMP_SECONDARY_FLAGS{.WithoutPowerInfo} + MINIDUMP_CALLBACK_INPUT :: struct { ProcessId: ULONG, ProcessHandle: HANDLE, - CallbackType: ULONG, + CallbackType: MINIDUMP_CALLBACK_TYPE, using _: struct #raw_union { - Status: HRESULT, - Thread: MINIDUMP_THREAD_CALLBACK, - ThreadEx: MINIDUMP_THREAD_EX_CALLBACK, - Module: MINIDUMP_MODULE_CALLBACK, - IncludeThread: MINIDUMP_INCLUDE_THREAD_CALLBACK, - IncludeModule: MINIDUMP_INCLUDE_MODULE_CALLBACK, - Io: MINIDUMP_IO_CALLBACK, - ReadMemoryFailure: MINIDUMP_READ_MEMORY_FAILURE_CALLBACK, - SecondaryFlags: ULONG, - VmQuery: MINIDUMP_VM_QUERY_CALLBACK, - VmPreRead: MINIDUMP_VM_PRE_READ_CALLBACK, - VmPostRead: MINIDUMP_VM_POST_READ_CALLBACK, + Status: HRESULT `raw_union_tag:"KernelMinidumpStatusCallback"`, + Thread: MINIDUMP_THREAD_CALLBACK `raw_union_tag:"ThreadCallback"`, + ThreadEx: MINIDUMP_THREAD_EX_CALLBACK `raw_union_tag:"ThreadExCallback"`, + Module: MINIDUMP_MODULE_CALLBACK `raw_union_tag:"ModuleCallback"`, + IncludeThread: MINIDUMP_INCLUDE_THREAD_CALLBACK `raw_union_tag:"IncludeThreadCallback"`, + IncludeModule: MINIDUMP_INCLUDE_MODULE_CALLBACK `raw_union_tag:"IncludeModuleCallback"`, + Io: MINIDUMP_IO_CALLBACK `raw_union_tag:"IoStartCallback,IoWriteAllCallback,IoFinishCallback"`, + ReadMemoryFailure: MINIDUMP_READ_MEMORY_FAILURE_CALLBACK `raw_union_tag:"ReadMemoryFailureCallback"`, + SecondaryFlags: MINIDUMP_SECONDARY_FLAGS `raw_union_tag:"SecondaryFlagsCallback"`, + VmQuery: MINIDUMP_VM_QUERY_CALLBACK `raw_union_tag:"VmQueryCallback"`, + VmPreRead: MINIDUMP_VM_PRE_READ_CALLBACK `raw_union_tag:"VmPreReadCallback"`, + VmPostRead: MINIDUMP_VM_POST_READ_CALLBACK `raw_union_tag:"VmPostReadCallback"`, }, } diff --git a/core/sys/windows/dnsapi.odin b/core/sys/windows/dnsapi.odin index 728813696..73e565118 100644 --- a/core/sys/windows/dnsapi.odin +++ b/core/sys/windows/dnsapi.odin @@ -5,6 +5,6 @@ foreign import "system:Dnsapi.lib" @(default_calling_convention="system") foreign Dnsapi { - DnsQuery_UTF8 :: proc(name: cstring, type: u16, options: DNS_QUERY_OPTIONS, extra: PVOID, results: ^^DNS_RECORD, reserved: PVOID) -> DNS_STATUS --- - DnsRecordListFree :: proc(list: ^DNS_RECORD, options: DWORD) --- + DnsQuery_UTF8 :: proc(name: cstring, type: u16, options: DNS_QUERY_OPTIONS, extra: PVOID, results: ^^DNS_RECORD, reserved: PVOID) -> DNS_STATUS --- + DnsRecordListFree :: proc(list: ^DNS_RECORD, options: DWORD) --- } diff --git a/core/sys/windows/dwmapi.odin b/core/sys/windows/dwmapi.odin index e86730660..0980c2e94 100644 --- a/core/sys/windows/dwmapi.odin +++ b/core/sys/windows/dwmapi.odin @@ -47,9 +47,9 @@ DWM_WINDOW_CORNER_PREFERENCE :: enum c_int { @(default_calling_convention="system") foreign dwmapi { - DwmFlush :: proc() -> HRESULT --- - DwmIsCompositionEnabled :: proc(pfEnabled: ^BOOL) -> HRESULT --- + DwmFlush :: proc() -> HRESULT --- + DwmIsCompositionEnabled :: proc(pfEnabled: ^BOOL) -> HRESULT --- DwmExtendFrameIntoClientArea :: proc(hWnd: HWND, pMarInset: PMARGINS) -> HRESULT --- - DwmGetWindowAttribute :: proc(hWnd: HWND, dwAttribute: DWORD, pvAttribute: PVOID, cbAttribute: DWORD) -> HRESULT --- - DwmSetWindowAttribute :: proc(hWnd: HWND, dwAttribute: DWORD, pvAttribute: LPCVOID, cbAttribute: DWORD) -> HRESULT --- + DwmGetWindowAttribute :: proc(hWnd: HWND, dwAttribute: DWORD, pvAttribute: PVOID, cbAttribute: DWORD) -> HRESULT --- + DwmSetWindowAttribute :: proc(hWnd: HWND, dwAttribute: DWORD, pvAttribute: LPCVOID, cbAttribute: DWORD) -> HRESULT --- } diff --git a/core/sys/windows/gdi32.odin b/core/sys/windows/gdi32.odin index 141429483..ad2243b56 100644 --- a/core/sys/windows/gdi32.odin +++ b/core/sys/windows/gdi32.odin @@ -7,85 +7,95 @@ foreign import gdi32 "system:Gdi32.lib" @(default_calling_convention="system") foreign gdi32 { - GetDeviceCaps :: proc(hdc: HDC, index: INT) -> INT --- + GetDeviceCaps :: proc(hdc: HDC, index: INT) -> INT --- GetStockObject :: proc(i: INT) -> HGDIOBJ --- - SelectObject :: proc(hdc: HDC, h: HGDIOBJ) -> HGDIOBJ --- - DeleteObject :: proc(ho: HGDIOBJ) -> BOOL --- - SetBkColor :: proc(hdc: HDC, color: COLORREF) -> COLORREF --- - SetBkMode :: proc(hdc: HDC, mode: BKMODE) -> INT --- + SelectObject :: proc(hdc: HDC, h: HGDIOBJ) -> HGDIOBJ --- + DeleteObject :: proc(ho: HGDIOBJ) -> BOOL --- + SetBkColor :: proc(hdc: HDC, color: COLORREF) -> COLORREF --- + SetBkMode :: proc(hdc: HDC, mode: BKMODE) -> INT --- CreateCompatibleDC :: proc(hdc: HDC) -> HDC --- - DeleteDC :: proc(hdc: HDC) -> BOOL --- - CancelDC :: proc(hdc: HDC) -> BOOL --- - SaveDC :: proc(hdc: HDC) -> INT --- - RestoreDC :: proc(hdc: HDC, nSavedDC: INT) -> BOOL --- + DeleteDC :: proc(hdc: HDC) -> BOOL --- + CancelDC :: proc(hdc: HDC) -> BOOL --- + SaveDC :: proc(hdc: HDC) -> INT --- + RestoreDC :: proc(hdc: HDC, nSavedDC: INT) -> BOOL --- CreateDIBPatternBrush :: proc(h: HGLOBAL, iUsage: UINT) -> HBRUSH --- - CreateDIBitmap :: proc(hdc: HDC, pbmih: ^BITMAPINFOHEADER, flInit: DWORD, pjBits: VOID, pbmi: ^BITMAPINFO, iUsage: UINT) -> HBITMAP --- - CreateDIBSection :: proc(hdc: HDC, pbmi: ^BITMAPINFO, usage: UINT, ppvBits: ^^VOID, hSection: HANDLE, offset: DWORD) -> HBITMAP --- - StretchDIBits :: proc(hdc: HDC, xDest, yDest, DestWidth, DestHeight, xSrc, ySrc, SrcWidth, SrcHeight: INT, lpBits: VOID, lpbmi: ^BITMAPINFO, iUsage: UINT, rop: DWORD) -> INT --- - StretchBlt :: proc(hdcDest: HDC, xDest, yDest, wDest, hDest: INT, hdcSrc: HDC, xSrc, ySrc, wSrc, hSrc: INT, rop: DWORD) -> BOOL --- + CreateDIBitmap :: proc(hdc: HDC, pbmih: ^BITMAPINFOHEADER, flInit: DWORD, pjBits: VOID, pbmi: ^BITMAPINFO, iUsage: UINT) -> HBITMAP --- + CreateDIBSection :: proc(hdc: HDC, pbmi: ^BITMAPINFO, usage: UINT, ppvBits: ^^VOID, hSection: HANDLE, offset: DWORD) -> HBITMAP --- + StretchDIBits :: proc(hdc: HDC, xDest, yDest, DestWidth, DestHeight, xSrc, ySrc, SrcWidth, SrcHeight: INT, lpBits: VOID, lpbmi: ^BITMAPINFO, iUsage: UINT, rop: DWORD) -> INT --- + StretchBlt :: proc(hdcDest: HDC, xDest, yDest, wDest, hDest: INT, hdcSrc: HDC, xSrc, ySrc, wSrc, hSrc: INT, rop: DWORD) -> BOOL --- - SetPixelFormat :: proc(hdc: HDC, format: INT, ppfd: ^PIXELFORMATDESCRIPTOR) -> BOOL --- - ChoosePixelFormat :: proc(hdc: HDC, ppfd: ^PIXELFORMATDESCRIPTOR) -> INT --- + SetPixelFormat :: proc(hdc: HDC, format: INT, ppfd: ^PIXELFORMATDESCRIPTOR) -> BOOL --- + ChoosePixelFormat :: proc(hdc: HDC, ppfd: ^PIXELFORMATDESCRIPTOR) -> INT --- DescribePixelFormat :: proc(hdc: HDC, iPixelFormat: INT, nBytes: UINT, ppfd: ^PIXELFORMATDESCRIPTOR) -> INT --- - SwapBuffers :: proc(hdc: HDC) -> BOOL --- + SwapBuffers :: proc(hdc: HDC) -> BOOL --- SetDCBrushColor :: proc(hdc: HDC, color: COLORREF) -> COLORREF --- GetDCBrushColor :: proc(hdc: HDC) -> COLORREF --- - PatBlt :: proc(hdc: HDC, x, y, w, h: INT, rop: DWORD) -> BOOL --- - Rectangle :: proc(hdc: HDC, left, top, right, bottom: INT) -> BOOL --- + PatBlt :: proc(hdc: HDC, x, y, w, h: INT, rop: DWORD) -> BOOL --- - CreateFontW :: proc(cHeight, cWidth, cEscapement, cOrientation, cWeight: INT, bItalic, bUnderline, bStrikeOut, iCharSet, iOutPrecision: DWORD, iClipPrecision, iQuality, iPitchAndFamily: DWORD, pszFaceName: LPCWSTR) -> HFONT --- - CreateFontIndirectW :: proc(lplf: ^LOGFONTW) -> HFONT --- + CreateFontW :: proc(cHeight, cWidth, cEscapement, cOrientation, cWeight: INT, bItalic, bUnderline, bStrikeOut, iCharSet, iOutPrecision: DWORD, iClipPrecision, iQuality, iPitchAndFamily: DWORD, pszFaceName: LPCWSTR) -> HFONT --- + CreateFontIndirectW :: proc(lplf: ^LOGFONTW) -> HFONT --- CreateFontIndirectExW :: proc(unnamedParam1: ^ENUMLOGFONTEXDVW) -> HFONT --- - AddFontResourceW :: proc(unnamedParam1: LPCWSTR) -> INT --- - AddFontResourceExW :: proc(name: LPCWSTR, fl: DWORD, res: PVOID) -> INT --- - AddFontMemResourceEx :: proc(pFileView: PVOID, cjSize: DWORD, pvResrved: PVOID, pNumFonts: ^DWORD) -> HANDLE --- - EnumFontsW :: proc(hdc: HDC, lpLogfont: LPCWSTR, lpProc: FONTENUMPROCW, lParam: LPARAM) -> INT --- - EnumFontFamiliesW :: proc(hdc: HDC, lpLogfont: LPCWSTR, lpProc: FONTENUMPROCW, lParam: LPARAM) -> INT --- - EnumFontFamiliesExW :: proc(hdc: HDC, lpLogfont: LPLOGFONTW, lpProc: FONTENUMPROCW, lParam: LPARAM, dwFlags: DWORD) -> INT --- + AddFontResourceW :: proc(unnamedParam1: LPCWSTR) -> INT --- + AddFontResourceExW :: proc(name: LPCWSTR, fl: DWORD, res: PVOID) -> INT --- + AddFontMemResourceEx :: proc(pFileView: PVOID, cjSize: DWORD, pvResrved: PVOID, pNumFonts: ^DWORD) -> HANDLE --- + EnumFontsW :: proc(hdc: HDC, lpLogfont: LPCWSTR, lpProc: FONTENUMPROCW, lParam: LPARAM) -> INT --- + EnumFontFamiliesW :: proc(hdc: HDC, lpLogfont: LPCWSTR, lpProc: FONTENUMPROCW, lParam: LPARAM) -> INT --- + EnumFontFamiliesExW :: proc(hdc: HDC, lpLogfont: LPLOGFONTW, lpProc: FONTENUMPROCW, lParam: LPARAM, dwFlags: DWORD) -> INT --- - TextOutW :: proc(hdc: HDC, x, y: INT, lpString: LPCWSTR, c: INT) -> BOOL --- + TextOutW :: proc(hdc: HDC, x, y: INT, lpString: LPCWSTR, c: INT) -> BOOL --- GetTextExtentPoint32W :: proc(hdc: HDC, lpString: LPCWSTR, c: INT, psizl: LPSIZE) -> BOOL --- - GetTextMetricsW :: proc(hdc: HDC, lptm: LPTEXTMETRICW) -> BOOL --- + GetTextMetricsW :: proc(hdc: HDC, lptm: LPTEXTMETRICW) -> BOOL --- CreateSolidBrush :: proc(color: COLORREF) -> HBRUSH --- - GetObjectW :: proc(h: HANDLE, c: INT, pv: LPVOID) -> int --- + GetObjectW :: proc(h: HANDLE, c: INT, pv: LPVOID) -> c_int --- CreateCompatibleBitmap :: proc(hdc: HDC, cx, cy: INT) -> HBITMAP --- - BitBlt :: proc(hdc: HDC, x, y, cx, cy: INT, hdcSrc: HDC, x1, y1: INT, rop: DWORD) -> BOOL --- - GetDIBits :: proc(hdc: HDC, hbm: HBITMAP, start, cLines: UINT, lpvBits: LPVOID, lpbmi: ^BITMAPINFO, usage: UINT) -> INT --- - SetDIBits :: proc(hdc: HDC, hbm: HBITMAP, start: UINT, cLines: UINT, lpBits: VOID, lpbmi: ^BITMAPINFO, ColorUse: UINT) -> INT --- - SetDIBColorTable :: proc(hdc: HDC, iStart: UINT, cEntries: UINT, prgbq: ^RGBQUAD) -> UINT --- - GetDIBColorTable :: proc(hdc: HDC, iStart: UINT, cEntries: UINT, prgbq: ^RGBQUAD) -> UINT --- + BitBlt :: proc(hdc: HDC, x, y, cx, cy: INT, hdcSrc: HDC, x1, y1: INT, rop: DWORD) -> BOOL --- + GetDIBits :: proc(hdc: HDC, hbm: HBITMAP, start, cLines: UINT, lpvBits: LPVOID, lpbmi: ^BITMAPINFO, usage: UINT) -> INT --- + SetDIBits :: proc(hdc: HDC, hbm: HBITMAP, start: UINT, cLines: UINT, lpBits: VOID, lpbmi: ^BITMAPINFO, ColorUse: UINT) -> INT --- + SetDIBColorTable :: proc(hdc: HDC, iStart: UINT, cEntries: UINT, prgbq: ^RGBQUAD) -> UINT --- + GetDIBColorTable :: proc(hdc: HDC, iStart: UINT, cEntries: UINT, prgbq: ^RGBQUAD) -> UINT --- - CreatePen :: proc(iStyle, cWidth: INT, color: COLORREF) -> HPEN --- - ExtCreatePen :: proc(iPenStyle, cWidth: DWORD, plbrush: ^LOGBRUSH, cStyle: DWORD, pstyle: ^DWORD) -> HPEN --- + CreatePen :: proc(iStyle, cWidth: INT, color: COLORREF) -> HPEN --- + ExtCreatePen :: proc(iPenStyle, cWidth: DWORD, plbrush: ^LOGBRUSH, cStyle: DWORD, pstyle: ^DWORD) -> HPEN --- SetDCPenColor :: proc(hdc: HDC, color: COLORREF) -> COLORREF --- GetDCPenColor :: proc(hdc: HDC) -> COLORREF --- - CreatePalette :: proc(plpal: ^LOGPALETTE) -> HPALETTE --- - SelectPalette :: proc(hdc: HDC, hPal: HPALETTE, bForceBkgd: BOOL) -> HPALETTE --- + CreatePalette :: proc(plpal: ^LOGPALETTE) -> HPALETTE --- + SelectPalette :: proc(hdc: HDC, hPal: HPALETTE, bForceBkgd: BOOL) -> HPALETTE --- RealizePalette :: proc(hdc: HDC) -> UINT --- SetTextColor :: proc(hdc: HDC, color: COLORREF) -> COLORREF --- - RoundRect :: proc(hdc: HDC, left: INT, top: INT, right: INT, bottom: INT, width: INT, height: INT) -> BOOL --- - SetPixel :: proc(hdc: HDC, x: INT, y: INT, color: COLORREF) -> COLORREF --- + SetPixel :: proc(hdc: HDC, x: INT, y: INT, color: COLORREF) -> COLORREF --- GdiTransparentBlt :: proc(hdcDest: HDC, xoriginDest, yoriginDest, wDest, hDest: INT, hdcSrc: HDC, xoriginSrc, yoriginSrc, wSrc, hSrc: INT, crTransparent: UINT) -> BOOL --- - GdiGradientFill :: proc(hdc: HDC, pVertex: PTRIVERTEX, nVertex: ULONG, pMesh: PVOID, nCount: ULONG, ulMode: ULONG) -> BOOL --- - GdiAlphaBlend :: proc(hdcDest: HDC, xoriginDest, yoriginDest, wDest, hDest: INT, hdcSrc: HDC, xoriginSrc, yoriginSrc, wSrc, hSrc: INT, ftn: BLENDFUNCTION) -> BOOL --- + GdiGradientFill :: proc(hdc: HDC, pVertex: PTRIVERTEX, nVertex: ULONG, pMesh: PVOID, nCount: ULONG, ulMode: ULONG) -> BOOL --- + GdiAlphaBlend :: proc(hdcDest: HDC, xoriginDest, yoriginDest, wDest, hDest: INT, hdcSrc: HDC, xoriginSrc, yoriginSrc, wSrc, hSrc: INT, ftn: BLENDFUNCTION) -> BOOL --- + + // Filled Shape Functions + Rectangle :: proc(hdc: HDC, left, top, right, bottom: c_int) -> BOOL --- + Ellipse :: proc(hdc: HDC, left, top, right, bottom: c_int) -> BOOL --- + RoundRect :: proc(hdc: HDC, left, top, right, bottom, width, height: c_int) -> BOOL --- + Pie :: proc(hdc: HDC, left, right, top, bottom, xr1, yr1, xr2, yr2: c_int) -> BOOL --- + Chord :: proc(hdc: HDC, x1, y1, x2, y2, x3, y3, x4, y4: c_int) -> BOOL --- + Polygon :: proc(hdc: HDC, apt: [^]POINT, cpt: c_int) -> BOOL --- + PolyPolygon :: proc(hdc: HDC, apt: [^]POINT, asz: [^]c_int, csz: c_int) -> BOOL --- } +@(require_results) RGB :: #force_inline proc "contextless" (#any_int r, g, b: int) -> COLORREF { return COLORREF(DWORD(BYTE(r)) | (DWORD(BYTE(g)) << 8) | (DWORD(BYTE(b)) << 16)) } +@(require_results) PALETTERGB :: #force_inline proc "contextless" (#any_int r, g, b: int) -> COLORREF { return 0x02000000 | RGB(r, g, b) } +@(require_results) PALETTEINDEX :: #force_inline proc "contextless" (#any_int i: int) -> COLORREF { return COLORREF(DWORD(0x01000000) | DWORD(WORD(i))) } @@ -154,17 +164,21 @@ ICONINFOEXW :: struct { } PICONINFOEXW :: ^ICONINFOEXW -AC_SRC_OVER :: 0x00 +AC_SRC_OVER :: 0x00 AC_SRC_ALPHA :: 0x01 TransparentBlt :: GdiTransparentBlt -GradientFill :: GdiGradientFill -AlphaBlend :: GdiAlphaBlend +GradientFill :: GdiGradientFill +AlphaBlend :: GdiAlphaBlend COLOR16 :: USHORT TRIVERTEX :: struct { - x, y: LONG, - Red, Green, Blue, Alpha: COLOR16, + x: LONG, + y: LONG, + Red: COLOR16, + Green: COLOR16, + Blue: COLOR16, + Alpha: COLOR16, } PTRIVERTEX :: ^TRIVERTEX @@ -179,7 +193,10 @@ GRADIENT_RECT :: struct { PGRADIENT_RECT :: ^GRADIENT_RECT BLENDFUNCTION :: struct { - BlendOp, BlendFlags, SourceConstantAlpha, AlphaFormat: BYTE, + BlendOp: BYTE, + BlendFlags: BYTE, + SourceConstantAlpha: BYTE, + AlphaFormat: BYTE, } GRADIENT_FILL_RECT_H : ULONG : 0x00000000 diff --git a/core/sys/windows/hidpi.odin b/core/sys/windows/hidpi.odin index 5e9787527..2cf2b2f34 100644 --- a/core/sys/windows/hidpi.odin +++ b/core/sys/windows/hidpi.odin @@ -1,213 +1,212 @@ #+build windows package sys_windows -import "core:c" HIDD_CONFIGURATION :: struct { - cookie: PVOID, - size: ULONG, + cookie: PVOID, + size: ULONG, RingBufferSize: ULONG, } PHIDD_CONFIGURATION :: ^HIDD_CONFIGURATION HIDD_ATTRIBUTES :: struct { - Size: ULONG, - VendorID: USHORT, - ProductID: USHORT, + Size: ULONG, + VendorID: USHORT, + ProductID: USHORT, VersionNumber: USHORT, } PHIDD_ATTRIBUTES :: ^HIDD_ATTRIBUTES HIDP_CAPS :: struct { - Usage: USAGE, - UsagePage: USAGE, - InputReportByteLength: USHORT, - OutputReportByteLength: USHORT, - FeatureReportByteLength: USHORT, - Reserved: [17]USHORT, + Usage: USAGE, + UsagePage: USAGE, + InputReportByteLength: USHORT, + OutputReportByteLength: USHORT, + FeatureReportByteLength: USHORT, + Reserved: [17]USHORT, NumberLinkCollectionNodes: USHORT, - NumberInputButtonCaps: USHORT, - NumberInputValueCaps: USHORT, - NumberInputDataIndices: USHORT, - NumberOutputButtonCaps: USHORT, - NumberOutputValueCaps: USHORT, - NumberOutputDataIndices: USHORT, - NumberFeatureButtonCaps: USHORT, - NumberFeatureValueCaps: USHORT, - NumberFeatureDataIndices: USHORT, + NumberInputButtonCaps: USHORT, + NumberInputValueCaps: USHORT, + NumberInputDataIndices: USHORT, + NumberOutputButtonCaps: USHORT, + NumberOutputValueCaps: USHORT, + NumberOutputDataIndices: USHORT, + NumberFeatureButtonCaps: USHORT, + NumberFeatureValueCaps: USHORT, + NumberFeatureDataIndices: USHORT, } PHIDP_CAPS :: ^HIDP_CAPS HIDP_BUTTON_CAPS :: struct { - UsagePage: USAGE, - ReportID: UCHAR, - IsAlias: BOOLEAN, - BitField: USHORT, - LinkCollection: USHORT, - LinkUsage: USAGE, - LinkUsagePage: USAGE, - IsRange: BOOLEAN, - IsStringRange: BOOLEAN, + UsagePage: USAGE, + ReportID: UCHAR, + IsAlias: BOOLEAN, + BitField: USHORT, + LinkCollection: USHORT, + LinkUsage: USAGE, + LinkUsagePage: USAGE, + IsRange: BOOLEAN, + IsStringRange: BOOLEAN, IsDesignatorRange: BOOLEAN, - IsAbsolute: BOOLEAN, - ReportCount: USHORT, - Reserved2: USHORT, - Reserved: [9]ULONG, + IsAbsolute: BOOLEAN, + ReportCount: USHORT, + Reserved2: USHORT, + Reserved: [9]ULONG, using _: struct #raw_union { Range: struct { - UsageMin: USAGE, - UsageMax: USAGE, - StringMin: USHORT, - StringMax: USHORT, + UsageMin: USAGE, + UsageMax: USAGE, + StringMin: USHORT, + StringMax: USHORT, DesignatorMin: USHORT, DesignatorMax: USHORT, - DataIndexMin: USHORT, - DataIndexMax: USHORT, - }, + DataIndexMin: USHORT, + DataIndexMax: USHORT, + } `raw_union_tag:"IsRange=true"`, NotRange: struct { - Usage: USAGE, - Reserved1: USAGE, - StringIndex: USHORT, - Reserved2: USHORT, + Usage: USAGE, + Reserved1: USAGE, + StringIndex: USHORT, + Reserved2: USHORT, DesignatorIndex: USHORT, - Reserved3: USHORT, - DataIndex: USHORT, - Reserved4: USHORT, - }, + Reserved3: USHORT, + DataIndex: USHORT, + Reserved4: USHORT, + } `raw_union_tag:"IsRange=false"`, }, } PHIDP_BUTTON_CAPS :: ^HIDP_BUTTON_CAPS HIDP_VALUE_CAPS :: struct { - UsagePage: USAGE, - ReportID: UCHAR, - IsAlias: BOOLEAN, - BitField: USHORT, - LinkCollection: USHORT, - LinkUsage: USAGE, - LinkUsagePage: USAGE, - IsRange: BOOLEAN, - IsStringRange: BOOLEAN, + UsagePage: USAGE, + ReportID: UCHAR, + IsAlias: BOOLEAN, + BitField: USHORT, + LinkCollection: USHORT, + LinkUsage: USAGE, + LinkUsagePage: USAGE, + IsRange: BOOLEAN, + IsStringRange: BOOLEAN, IsDesignatorRange: BOOLEAN, - IsAbsolute: BOOLEAN, - HasNull: BOOLEAN, - Reserved: UCHAR, - BitSize: USHORT, - ReportCount: USHORT, - Reserved2: [5]USHORT, - UnitsExp: ULONG, - Units: ULONG, - LogicalMin: LONG, - LogicalMax: LONG, - PhysicalMin: LONG, - PhysicalMax: LONG, + IsAbsolute: BOOLEAN, + HasNull: BOOLEAN, + Reserved: UCHAR, + BitSize: USHORT, + ReportCount: USHORT, + Reserved2: [5]USHORT, + UnitsExp: ULONG, + Units: ULONG, + LogicalMin: LONG, + LogicalMax: LONG, + PhysicalMin: LONG, + PhysicalMax: LONG, using _: struct #raw_union { Range: struct { - UsageMin: USAGE, - UsageMax: USAGE, - StringMin: USHORT, - StringMax: USHORT, + UsageMin: USAGE, + UsageMax: USAGE, + StringMin: USHORT, + StringMax: USHORT, DesignatorMin: USHORT, DesignatorMax: USHORT, - DataIndexMin: USHORT, - DataIndexMax: USHORT, - }, + DataIndexMin: USHORT, + DataIndexMax: USHORT, + } `raw_union_tag:"IsRange=true"`, NotRange: struct { - Usage: USAGE, - Reserved1: USAGE, - StringIndex: USHORT, - Reserved2: USHORT, + Usage: USAGE, + Reserved1: USAGE, + StringIndex: USHORT, + Reserved2: USHORT, DesignatorIndex: USHORT, - Reserved3: USHORT, - DataIndex: USHORT, - Reserved4: USHORT, - }, + Reserved3: USHORT, + DataIndex: USHORT, + Reserved4: USHORT, + } `raw_union_tag:"IsRange=false"`, }, } PHIDP_VALUE_CAPS :: ^HIDP_VALUE_CAPS HIDP_DATA :: struct { DataIndex: USHORT, - Reserved: USHORT, + Reserved: USHORT, using _ : struct #raw_union { RawValue: ULONG, - On: BOOLEAN, + On: BOOLEAN, }, } PHIDP_DATA :: ^HIDP_DATA HIDP_LINK_COLLECTION_NODE :: struct { - LinkUsage: USAGE, - LinkUsagePage: USAGE, - Parent: USHORT, + LinkUsage: USAGE, + LinkUsagePage: USAGE, + Parent: USHORT, NumberOfChildren: USHORT, - NextSibling: USHORT, - FirstChild: USHORT, - CollectionType: [8]ULONG, - IsAlias: [1]ULONG, - Reserved: [23]ULONG, - UserContext: PVOID, + NextSibling: USHORT, + FirstChild: USHORT, + CollectionType: [8]ULONG, + IsAlias: [1]ULONG, + Reserved: [23]ULONG, + UserContext: PVOID, } PHIDP_LINK_COLLECTION_NODE :: ^HIDP_LINK_COLLECTION_NODE HIDP_PREPARSED_DATA :: rawptr PHIDP_PREPARSED_DATA :: ^HIDP_PREPARSED_DATA -HIDP_REPORT_TYPE :: enum c.int { +HIDP_REPORT_TYPE :: enum c_int { Input, Output, Feature, } -HIDP_STATUS_SUCCESS : NTSTATUS : 0x110000 -HIDP_STATUS_NULL : NTSTATUS : -2146369535 //0x80110001 -HIDP_STATUS_INVALID_PREPARSED_DATA : NTSTATUS : -1072627711 //0xC0110001 -HIDP_STATUS_INVALID_REPORT_TYPE : NTSTATUS : -1072627710 //0xC0110002 -HIDP_STATUS_INVALID_REPORT_LENGTH : NTSTATUS : -1072627709 //0xC0110003 -HIDP_STATUS_USAGE_NOT_FOUND : NTSTATUS : -1072627708 //0xC0110004 -HIDP_STATUS_VALUE_OUT_OF_RANGE : NTSTATUS : -1072627707 //0xC0110005 -HIDP_STATUS_BAD_LOG_PHY_VALUES : NTSTATUS : -1072627706 //0xC0100006 -HIDP_STATUS_BUFFER_TOO_SMALL : NTSTATUS : -1072627705 //0xC0110007 -HIDP_STATUS_INTERNAL_ERROR : NTSTATUS : -1072627704 //0xC0110008 -HIDP_STATUS_I8042_TRANS_UNKNOWN : NTSTATUS : -1072627703 //0xC0110009 -HIDP_STATUS_INCOMPATIBLE_REPORT_ID : NTSTATUS : -1072627702 //0xC011000A -HIDP_STATUS_NOT_VALUE_ARRAY : NTSTATUS : -1072627701 //0xC011000B -HIDP_STATUS_IS_VALUE_ARRAY : NTSTATUS : -1072627700 //0xC011000C -HIDP_STATUS_DATA_INDEX_NOT_FOUND : NTSTATUS : -1072627699 //0xC011000D +HIDP_STATUS_SUCCESS : NTSTATUS : 0x110000 +HIDP_STATUS_NULL : NTSTATUS : -2146369535 //0x80110001 +HIDP_STATUS_INVALID_PREPARSED_DATA : NTSTATUS : -1072627711 //0xC0110001 +HIDP_STATUS_INVALID_REPORT_TYPE : NTSTATUS : -1072627710 //0xC0110002 +HIDP_STATUS_INVALID_REPORT_LENGTH : NTSTATUS : -1072627709 //0xC0110003 +HIDP_STATUS_USAGE_NOT_FOUND : NTSTATUS : -1072627708 //0xC0110004 +HIDP_STATUS_VALUE_OUT_OF_RANGE : NTSTATUS : -1072627707 //0xC0110005 +HIDP_STATUS_BAD_LOG_PHY_VALUES : NTSTATUS : -1072627706 //0xC0100006 +HIDP_STATUS_BUFFER_TOO_SMALL : NTSTATUS : -1072627705 //0xC0110007 +HIDP_STATUS_INTERNAL_ERROR : NTSTATUS : -1072627704 //0xC0110008 +HIDP_STATUS_I8042_TRANS_UNKNOWN : NTSTATUS : -1072627703 //0xC0110009 +HIDP_STATUS_INCOMPATIBLE_REPORT_ID : NTSTATUS : -1072627702 //0xC011000A +HIDP_STATUS_NOT_VALUE_ARRAY : NTSTATUS : -1072627701 //0xC011000B +HIDP_STATUS_IS_VALUE_ARRAY : NTSTATUS : -1072627700 //0xC011000C +HIDP_STATUS_DATA_INDEX_NOT_FOUND : NTSTATUS : -1072627699 //0xC011000D HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE : NTSTATUS : -1072627698 //0xC011000E -HIDP_STATUS_BUTTON_NOT_PRESSED : NTSTATUS : -1072627697 //0xC011000F -HIDP_STATUS_REPORT_DOES_NOT_EXIST : NTSTATUS : -1072627696 //0xC0110010 -HIDP_STATUS_NOT_IMPLEMENTED : NTSTATUS : -1072627680 //0xC0110020 -HIDP_STATUS_NOT_BUTTON_ARRAY : NTSTATUS : -1072627679 //0xC0110021 +HIDP_STATUS_BUTTON_NOT_PRESSED : NTSTATUS : -1072627697 //0xC011000F +HIDP_STATUS_REPORT_DOES_NOT_EXIST : NTSTATUS : -1072627696 //0xC0110010 +HIDP_STATUS_NOT_IMPLEMENTED : NTSTATUS : -1072627680 //0xC0110020 +HIDP_STATUS_NOT_BUTTON_ARRAY : NTSTATUS : -1072627679 //0xC0110021 HIDP_STATUS_I8242_TRANS_UNKNOWN :: HIDP_STATUS_I8042_TRANS_UNKNOWN foreign import hid "system:hid.lib" @(default_calling_convention="system") foreign hid { - HidP_GetCaps :: proc(PreparsedData: PHIDP_PREPARSED_DATA, Capabilities: PHIDP_CAPS) -> NTSTATUS --- - HidP_GetButtonCaps :: proc(ReportType: HIDP_REPORT_TYPE, ButtonCaps: PHIDP_BUTTON_CAPS, ButtonCapsLength: PUSHORT, PreparsedData: PHIDP_PREPARSED_DATA) -> NTSTATUS --- - HidP_GetValueCaps :: proc(ReportType: HIDP_REPORT_TYPE, ValueCaps: PHIDP_VALUE_CAPS, ValueCapsLength: PUSHORT, PreparsedData: PHIDP_PREPARSED_DATA) -> NTSTATUS --- - HidP_GetUsages :: proc(ReportType: HIDP_REPORT_TYPE, UsagePage: USAGE, LinkCollection: USHORT, UsageList: PUSAGE, UsageLength: PULONG, PreparsedData: PHIDP_PREPARSED_DATA, Report: PCHAR, ReportLength: ULONG) -> NTSTATUS --- - HidP_GetUsageValue :: proc(ReportType: HIDP_REPORT_TYPE, UsagePage: USAGE, LinkCollection: USHORT, Usage: USAGE, UsageValue: PULONG, PreparsedData: PHIDP_PREPARSED_DATA, Report: PCHAR, ReportLength: ULONG) -> NTSTATUS --- - HidP_GetData :: proc(ReportType: HIDP_REPORT_TYPE, DataList: PHIDP_DATA, DataLength: PULONG, PreparsedData: PHIDP_PREPARSED_DATA, Report: PCHAR, ReportLength: ULONG) -> NTSTATUS --- + HidP_GetCaps :: proc(PreparsedData: PHIDP_PREPARSED_DATA, Capabilities: PHIDP_CAPS) -> NTSTATUS --- + HidP_GetButtonCaps :: proc(ReportType: HIDP_REPORT_TYPE, ButtonCaps: PHIDP_BUTTON_CAPS, ButtonCapsLength: PUSHORT, PreparsedData: PHIDP_PREPARSED_DATA) -> NTSTATUS --- + HidP_GetValueCaps :: proc(ReportType: HIDP_REPORT_TYPE, ValueCaps: PHIDP_VALUE_CAPS, ValueCapsLength: PUSHORT, PreparsedData: PHIDP_PREPARSED_DATA) -> NTSTATUS --- + HidP_GetUsages :: proc(ReportType: HIDP_REPORT_TYPE, UsagePage: USAGE, LinkCollection: USHORT, UsageList: PUSAGE, UsageLength: PULONG, PreparsedData: PHIDP_PREPARSED_DATA, Report: PCHAR, ReportLength: ULONG) -> NTSTATUS --- + HidP_GetUsageValue :: proc(ReportType: HIDP_REPORT_TYPE, UsagePage: USAGE, LinkCollection: USHORT, Usage: USAGE, UsageValue: PULONG, PreparsedData: PHIDP_PREPARSED_DATA, Report: PCHAR, ReportLength: ULONG) -> NTSTATUS --- + HidP_GetData :: proc(ReportType: HIDP_REPORT_TYPE, DataList: PHIDP_DATA, DataLength: PULONG, PreparsedData: PHIDP_PREPARSED_DATA, Report: PCHAR, ReportLength: ULONG) -> NTSTATUS --- HidP_GetLinkCollectionNodes :: proc(LinkCollectionNodes: PHIDP_LINK_COLLECTION_NODE, LinkCollectionNodesLength: PULONG, PreparsedData: PHIDP_PREPARSED_DATA) -> NTSTATUS --- - HidD_GetAttributes :: proc(HidDeviceObject: HANDLE, Attributes: PHIDD_ATTRIBUTES) -> BOOLEAN --- - HidD_GetHidGuid :: proc(HidGuid: LPGUID) --- - HidD_GetPreparsedData :: proc(HidDeviceObject: HANDLE, PreparsedData: ^PHIDP_PREPARSED_DATA) -> BOOLEAN --- - HidD_FreePreparsedData :: proc(PreparsedData: PHIDP_PREPARSED_DATA) -> BOOLEAN --- - HidD_FlushQueue :: proc(HidDeviceObject: HANDLE) -> BOOLEAN --- - HidD_GetConfiguration :: proc(HidDeviceObject: HANDLE, Configuration: PHIDD_CONFIGURATION, ConfigurationLength: ULONG) -> BOOLEAN --- - HidD_SetConfiguration :: proc(HidDeviceObject: HANDLE, Configuration: PHIDD_CONFIGURATION, ConfigurationLength: ULONG) -> BOOLEAN --- - HidD_GetFeature :: proc(HidDeviceObject: HANDLE, ReportBuffer: PVOID, ReportBufferLength: ULONG) -> BOOLEAN --- - HidD_SetFeature :: proc(HidDeviceObject: HANDLE, ReportBuffer: PVOID, ReportBufferLength: ULONG) -> BOOLEAN --- - HidD_GetInputReport :: proc(HidDeviceObject: HANDLE, ReportBuffer: PVOID, ReportBufferLength: ULONG) -> BOOLEAN --- - HidD_SetOutputReport :: proc(HidDeviceObject: HANDLE, ReportBuffer: PVOID, ReportBufferLength: ULONG) -> BOOLEAN --- - HidD_GetNumInputBuffers :: proc(HidDeviceObject: HANDLE, NumberBuffers: PULONG) -> BOOLEAN --- - HidD_SetNumInputBuffers :: proc(HidDeviceObject: HANDLE, NumberBuffers: ULONG) -> BOOLEAN --- + HidD_GetAttributes :: proc(HidDeviceObject: HANDLE, Attributes: PHIDD_ATTRIBUTES) -> BOOLEAN --- + HidD_GetHidGuid :: proc(HidGuid: LPGUID) --- + HidD_GetPreparsedData :: proc(HidDeviceObject: HANDLE, PreparsedData: ^PHIDP_PREPARSED_DATA) -> BOOLEAN --- + HidD_FreePreparsedData :: proc(PreparsedData: PHIDP_PREPARSED_DATA) -> BOOLEAN --- + HidD_FlushQueue :: proc(HidDeviceObject: HANDLE) -> BOOLEAN --- + HidD_GetConfiguration :: proc(HidDeviceObject: HANDLE, Configuration: PHIDD_CONFIGURATION, ConfigurationLength: ULONG) -> BOOLEAN --- + HidD_SetConfiguration :: proc(HidDeviceObject: HANDLE, Configuration: PHIDD_CONFIGURATION, ConfigurationLength: ULONG) -> BOOLEAN --- + HidD_GetFeature :: proc(HidDeviceObject: HANDLE, ReportBuffer: PVOID, ReportBufferLength: ULONG) -> BOOLEAN --- + HidD_SetFeature :: proc(HidDeviceObject: HANDLE, ReportBuffer: PVOID, ReportBufferLength: ULONG) -> BOOLEAN --- + HidD_GetInputReport :: proc(HidDeviceObject: HANDLE, ReportBuffer: PVOID, ReportBufferLength: ULONG) -> BOOLEAN --- + HidD_SetOutputReport :: proc(HidDeviceObject: HANDLE, ReportBuffer: PVOID, ReportBufferLength: ULONG) -> BOOLEAN --- + HidD_GetNumInputBuffers :: proc(HidDeviceObject: HANDLE, NumberBuffers: PULONG) -> BOOLEAN --- + HidD_SetNumInputBuffers :: proc(HidDeviceObject: HANDLE, NumberBuffers: ULONG) -> BOOLEAN --- HidD_GetPhysicalDescriptor :: proc(HidDeviceObject: HANDLE, Buffer: PVOID, BufferLength: ULONG) -> BOOLEAN --- HidD_GetManufacturerString :: proc(HidDeviceObject: HANDLE, Buffer: PVOID, BufferLength: ULONG) -> BOOLEAN --- - HidD_GetProductString :: proc(HidDeviceObject: HANDLE, Buffer: PVOID, BufferLength: ULONG) -> BOOLEAN --- - HidD_GetIndexedString :: proc(HidDeviceObject: HANDLE, StringIndex: ULONG, Buffer: PVOID, BufferLength: ULONG) -> BOOLEAN --- + HidD_GetProductString :: proc(HidDeviceObject: HANDLE, Buffer: PVOID, BufferLength: ULONG) -> BOOLEAN --- + HidD_GetIndexedString :: proc(HidDeviceObject: HANDLE, StringIndex: ULONG, Buffer: PVOID, BufferLength: ULONG) -> BOOLEAN --- HidD_GetSerialNumberString :: proc(HidDeviceObject: HANDLE, Buffer: PVOID, BufferLength: ULONG) -> BOOLEAN --- - HidD_GetMsGenreDescriptor :: proc(HidDeviceObject: HANDLE, Buffer: PVOID, BufferLength: ULONG) -> BOOLEAN --- + HidD_GetMsGenreDescriptor :: proc(HidDeviceObject: HANDLE, Buffer: PVOID, BufferLength: ULONG) -> BOOLEAN --- } diff --git a/core/sys/windows/hidusage.odin b/core/sys/windows/hidusage.odin index eb2a85f2e..5f87bea2d 100644 --- a/core/sys/windows/hidusage.odin +++ b/core/sys/windows/hidusage.odin @@ -4,260 +4,260 @@ package sys_windows USAGE :: distinct USHORT PUSAGE :: ^USAGE -HID_USAGE_PAGE_UNDEFINED :: 0x00 -HID_USAGE_PAGE_GENERIC :: 0x01 -HID_USAGE_PAGE_SIMULATION :: 0x02 -HID_USAGE_PAGE_VR :: 0x03 -HID_USAGE_PAGE_SPORT :: 0x04 -HID_USAGE_PAGE_GAME :: 0x05 -HID_USAGE_PAGE_GENERIC_DEVICE :: 0x06 -HID_USAGE_PAGE_KEYBOARD :: 0x07 -HID_USAGE_PAGE_LED :: 0x08 -HID_USAGE_PAGE_BUTTON :: 0x09 -HID_USAGE_PAGE_ORDINAL :: 0x0A -HID_USAGE_PAGE_TELEPHONY :: 0x0B -HID_USAGE_PAGE_CONSUMER :: 0x0C -HID_USAGE_PAGE_DIGITIZER :: 0x0D -HID_USAGE_PAGE_HAPTICS :: 0x0E -HID_USAGE_PAGE_PID :: 0x0F -HID_USAGE_PAGE_UNICODE :: 0x10 -HID_USAGE_PAGE_ALPHANUMERIC :: 0x14 -HID_USAGE_PAGE_SENSOR :: 0x20 -HID_USAGE_PAGE_LIGHTING_ILLUMINATION :: 0x59 -HID_USAGE_PAGE_BARCODE_SCANNER :: 0x8C -HID_USAGE_PAGE_WEIGHING_DEVICE :: 0x8D -HID_USAGE_PAGE_MAGNETIC_STRIPE_READER :: 0x8E -HID_USAGE_PAGE_CAMERA_CONTROL :: 0x90 -HID_USAGE_PAGE_ARCADE :: 0x91 +HID_USAGE_PAGE_UNDEFINED :: 0x00 +HID_USAGE_PAGE_GENERIC :: 0x01 +HID_USAGE_PAGE_SIMULATION :: 0x02 +HID_USAGE_PAGE_VR :: 0x03 +HID_USAGE_PAGE_SPORT :: 0x04 +HID_USAGE_PAGE_GAME :: 0x05 +HID_USAGE_PAGE_GENERIC_DEVICE :: 0x06 +HID_USAGE_PAGE_KEYBOARD :: 0x07 +HID_USAGE_PAGE_LED :: 0x08 +HID_USAGE_PAGE_BUTTON :: 0x09 +HID_USAGE_PAGE_ORDINAL :: 0x0A +HID_USAGE_PAGE_TELEPHONY :: 0x0B +HID_USAGE_PAGE_CONSUMER :: 0x0C +HID_USAGE_PAGE_DIGITIZER :: 0x0D +HID_USAGE_PAGE_HAPTICS :: 0x0E +HID_USAGE_PAGE_PID :: 0x0F +HID_USAGE_PAGE_UNICODE :: 0x10 +HID_USAGE_PAGE_ALPHANUMERIC :: 0x14 +HID_USAGE_PAGE_SENSOR :: 0x20 +HID_USAGE_PAGE_LIGHTING_ILLUMINATION :: 0x59 +HID_USAGE_PAGE_BARCODE_SCANNER :: 0x8C +HID_USAGE_PAGE_WEIGHING_DEVICE :: 0x8D +HID_USAGE_PAGE_MAGNETIC_STRIPE_READER :: 0x8E +HID_USAGE_PAGE_CAMERA_CONTROL :: 0x90 +HID_USAGE_PAGE_ARCADE :: 0x91 HID_USAGE_PAGE_MICROSOFT_BLUETOOTH_HANDSFREE :: 0xFFF3 -HID_USAGE_PAGE_VENDOR_DEFINED_BEGIN :: 0xFF00 -HID_USAGE_PAGE_VENDOR_DEFINED_END :: 0xFFFF +HID_USAGE_PAGE_VENDOR_DEFINED_BEGIN :: 0xFF00 +HID_USAGE_PAGE_VENDOR_DEFINED_END :: 0xFFFF -HID_USAGE_GENERIC_POINTER :: 0x01 -HID_USAGE_GENERIC_MOUSE :: 0x02 -HID_USAGE_GENERIC_JOYSTICK :: 0x04 -HID_USAGE_GENERIC_GAMEPAD :: 0x05 -HID_USAGE_GENERIC_KEYBOARD :: 0x06 -HID_USAGE_GENERIC_KEYPAD :: 0x07 -HID_USAGE_GENERIC_MULTI_AXIS_CONTROLLER :: 0x08 -HID_USAGE_GENERIC_TABLET_PC_SYSTEM_CTL :: 0x09 +HID_USAGE_GENERIC_POINTER :: 0x01 +HID_USAGE_GENERIC_MOUSE :: 0x02 +HID_USAGE_GENERIC_JOYSTICK :: 0x04 +HID_USAGE_GENERIC_GAMEPAD :: 0x05 +HID_USAGE_GENERIC_KEYBOARD :: 0x06 +HID_USAGE_GENERIC_KEYPAD :: 0x07 +HID_USAGE_GENERIC_MULTI_AXIS_CONTROLLER :: 0x08 +HID_USAGE_GENERIC_TABLET_PC_SYSTEM_CTL :: 0x09 HID_USAGE_GENERIC_PORTABLE_DEVICE_CONTROL :: 0x0D -HID_USAGE_GENERIC_INTERACTIVE_CONTROL :: 0x0E -HID_USAGE_GENERIC_SYSTEM_CTL :: 0x80 +HID_USAGE_GENERIC_INTERACTIVE_CONTROL :: 0x0E +HID_USAGE_GENERIC_SYSTEM_CTL :: 0x80 -HID_USAGE_GENERIC_X :: 0x30 -HID_USAGE_GENERIC_Y :: 0x31 -HID_USAGE_GENERIC_Z :: 0x32 -HID_USAGE_GENERIC_RX :: 0x33 -HID_USAGE_GENERIC_RY :: 0x34 -HID_USAGE_GENERIC_RZ :: 0x35 -HID_USAGE_GENERIC_SLIDER :: 0x36 -HID_USAGE_GENERIC_DIAL :: 0x37 -HID_USAGE_GENERIC_WHEEL :: 0x38 -HID_USAGE_GENERIC_HATSWITCH :: 0x39 -HID_USAGE_GENERIC_COUNTED_BUFFER :: 0x3A -HID_USAGE_GENERIC_BYTE_COUNT :: 0x3B -HID_USAGE_GENERIC_MOTION_WAKEUP :: 0x3C -HID_USAGE_GENERIC_START :: 0x3D -HID_USAGE_GENERIC_SELECT :: 0x3E -HID_USAGE_GENERIC_VX :: 0x40 -HID_USAGE_GENERIC_VY :: 0x41 -HID_USAGE_GENERIC_VZ :: 0x42 -HID_USAGE_GENERIC_VBRX :: 0x43 -HID_USAGE_GENERIC_VBRY :: 0x44 -HID_USAGE_GENERIC_VBRZ :: 0x45 -HID_USAGE_GENERIC_VNO :: 0x46 -HID_USAGE_GENERIC_FEATURE_NOTIFICATION :: 0x47 -HID_USAGE_GENERIC_RESOLUTION_MULTIPLIER :: 0x48 -HID_USAGE_GENERIC_SYSCTL_POWER :: 0x81 -HID_USAGE_GENERIC_SYSCTL_SLEEP :: 0x82 -HID_USAGE_GENERIC_SYSCTL_WAKE :: 0x83 -HID_USAGE_GENERIC_SYSCTL_CONTEXT_MENU :: 0x84 -HID_USAGE_GENERIC_SYSCTL_MAIN_MENU :: 0x85 -HID_USAGE_GENERIC_SYSCTL_APP_MENU :: 0x86 -HID_USAGE_GENERIC_SYSCTL_HELP_MENU :: 0x87 -HID_USAGE_GENERIC_SYSCTL_MENU_EXIT :: 0x88 -HID_USAGE_GENERIC_SYSCTL_MENU_SELECT :: 0x89 -HID_USAGE_GENERIC_SYSCTL_MENU_RIGHT :: 0x8A -HID_USAGE_GENERIC_SYSCTL_MENU_LEFT :: 0x8B -HID_USAGE_GENERIC_SYSCTL_MENU_UP :: 0x8C -HID_USAGE_GENERIC_SYSCTL_MENU_DOWN :: 0x8D -HID_USAGE_GENERIC_SYSCTL_COLD_RESTART :: 0x8E -HID_USAGE_GENERIC_SYSCTL_WARM_RESTART :: 0x8F -HID_USAGE_GENERIC_DPAD_UP :: 0x90 -HID_USAGE_GENERIC_DPAD_DOWN :: 0x91 -HID_USAGE_GENERIC_DPAD_RIGHT :: 0x92 -HID_USAGE_GENERIC_DPAD_LEFT :: 0x93 -HID_USAGE_GENERIC_SYSCTL_FN :: 0x97 -HID_USAGE_GENERIC_SYSCTL_FN_LOCK :: 0x98 -HID_USAGE_GENERIC_SYSCTL_FN_LOCK_INDICATOR :: 0x99 -HID_USAGE_GENERIC_SYSCTL_DISMISS_NOTIFICATION :: 0x9A -HID_USAGE_GENERIC_SYSCTL_DOCK :: 0xA0 -HID_USAGE_GENERIC_SYSCTL_UNDOCK :: 0xA1 -HID_USAGE_GENERIC_SYSCTL_SETUP :: 0xA2 -HID_USAGE_GENERIC_SYSCTL_SYS_BREAK :: 0xA3 -HID_USAGE_GENERIC_SYSCTL_SYS_DBG_BREAK :: 0xA4 -HID_USAGE_GENERIC_SYSCTL_APP_BREAK :: 0xA5 -HID_USAGE_GENERIC_SYSCTL_APP_DBG_BREAK :: 0xA6 -HID_USAGE_GENERIC_SYSCTL_MUTE :: 0xA7 -HID_USAGE_GENERIC_SYSCTL_HIBERNATE :: 0xA8 -HID_USAGE_GENERIC_SYSCTL_DISP_INVERT :: 0xB0 -HID_USAGE_GENERIC_SYSCTL_DISP_INTERNAL :: 0xB1 -HID_USAGE_GENERIC_SYSCTL_DISP_EXTERNAL :: 0xB2 -HID_USAGE_GENERIC_SYSCTL_DISP_BOTH :: 0xB3 -HID_USAGE_GENERIC_SYSCTL_DISP_DUAL :: 0xB4 -HID_USAGE_GENERIC_SYSCTL_DISP_TOGGLE :: 0xB5 -HID_USAGE_GENERIC_SYSCTL_DISP_SWAP :: 0xB6 -HID_USAGE_GENERIC_SYSCTL_DISP_AUTOSCALE :: 0xB7 -HID_USAGE_GENERIC_SYSTEM_DISPLAY_ROTATION_LOCK_BUTTON :: 0xC9 +HID_USAGE_GENERIC_X :: 0x30 +HID_USAGE_GENERIC_Y :: 0x31 +HID_USAGE_GENERIC_Z :: 0x32 +HID_USAGE_GENERIC_RX :: 0x33 +HID_USAGE_GENERIC_RY :: 0x34 +HID_USAGE_GENERIC_RZ :: 0x35 +HID_USAGE_GENERIC_SLIDER :: 0x36 +HID_USAGE_GENERIC_DIAL :: 0x37 +HID_USAGE_GENERIC_WHEEL :: 0x38 +HID_USAGE_GENERIC_HATSWITCH :: 0x39 +HID_USAGE_GENERIC_COUNTED_BUFFER :: 0x3A +HID_USAGE_GENERIC_BYTE_COUNT :: 0x3B +HID_USAGE_GENERIC_MOTION_WAKEUP :: 0x3C +HID_USAGE_GENERIC_START :: 0x3D +HID_USAGE_GENERIC_SELECT :: 0x3E +HID_USAGE_GENERIC_VX :: 0x40 +HID_USAGE_GENERIC_VY :: 0x41 +HID_USAGE_GENERIC_VZ :: 0x42 +HID_USAGE_GENERIC_VBRX :: 0x43 +HID_USAGE_GENERIC_VBRY :: 0x44 +HID_USAGE_GENERIC_VBRZ :: 0x45 +HID_USAGE_GENERIC_VNO :: 0x46 +HID_USAGE_GENERIC_FEATURE_NOTIFICATION :: 0x47 +HID_USAGE_GENERIC_RESOLUTION_MULTIPLIER :: 0x48 +HID_USAGE_GENERIC_SYSCTL_POWER :: 0x81 +HID_USAGE_GENERIC_SYSCTL_SLEEP :: 0x82 +HID_USAGE_GENERIC_SYSCTL_WAKE :: 0x83 +HID_USAGE_GENERIC_SYSCTL_CONTEXT_MENU :: 0x84 +HID_USAGE_GENERIC_SYSCTL_MAIN_MENU :: 0x85 +HID_USAGE_GENERIC_SYSCTL_APP_MENU :: 0x86 +HID_USAGE_GENERIC_SYSCTL_HELP_MENU :: 0x87 +HID_USAGE_GENERIC_SYSCTL_MENU_EXIT :: 0x88 +HID_USAGE_GENERIC_SYSCTL_MENU_SELECT :: 0x89 +HID_USAGE_GENERIC_SYSCTL_MENU_RIGHT :: 0x8A +HID_USAGE_GENERIC_SYSCTL_MENU_LEFT :: 0x8B +HID_USAGE_GENERIC_SYSCTL_MENU_UP :: 0x8C +HID_USAGE_GENERIC_SYSCTL_MENU_DOWN :: 0x8D +HID_USAGE_GENERIC_SYSCTL_COLD_RESTART :: 0x8E +HID_USAGE_GENERIC_SYSCTL_WARM_RESTART :: 0x8F +HID_USAGE_GENERIC_DPAD_UP :: 0x90 +HID_USAGE_GENERIC_DPAD_DOWN :: 0x91 +HID_USAGE_GENERIC_DPAD_RIGHT :: 0x92 +HID_USAGE_GENERIC_DPAD_LEFT :: 0x93 +HID_USAGE_GENERIC_SYSCTL_FN :: 0x97 +HID_USAGE_GENERIC_SYSCTL_FN_LOCK :: 0x98 +HID_USAGE_GENERIC_SYSCTL_FN_LOCK_INDICATOR :: 0x99 +HID_USAGE_GENERIC_SYSCTL_DISMISS_NOTIFICATION :: 0x9A +HID_USAGE_GENERIC_SYSCTL_DOCK :: 0xA0 +HID_USAGE_GENERIC_SYSCTL_UNDOCK :: 0xA1 +HID_USAGE_GENERIC_SYSCTL_SETUP :: 0xA2 +HID_USAGE_GENERIC_SYSCTL_SYS_BREAK :: 0xA3 +HID_USAGE_GENERIC_SYSCTL_SYS_DBG_BREAK :: 0xA4 +HID_USAGE_GENERIC_SYSCTL_APP_BREAK :: 0xA5 +HID_USAGE_GENERIC_SYSCTL_APP_DBG_BREAK :: 0xA6 +HID_USAGE_GENERIC_SYSCTL_MUTE :: 0xA7 +HID_USAGE_GENERIC_SYSCTL_HIBERNATE :: 0xA8 +HID_USAGE_GENERIC_SYSCTL_DISP_INVERT :: 0xB0 +HID_USAGE_GENERIC_SYSCTL_DISP_INTERNAL :: 0xB1 +HID_USAGE_GENERIC_SYSCTL_DISP_EXTERNAL :: 0xB2 +HID_USAGE_GENERIC_SYSCTL_DISP_BOTH :: 0xB3 +HID_USAGE_GENERIC_SYSCTL_DISP_DUAL :: 0xB4 +HID_USAGE_GENERIC_SYSCTL_DISP_TOGGLE :: 0xB5 +HID_USAGE_GENERIC_SYSCTL_DISP_SWAP :: 0xB6 +HID_USAGE_GENERIC_SYSCTL_DISP_AUTOSCALE :: 0xB7 +HID_USAGE_GENERIC_SYSTEM_DISPLAY_ROTATION_LOCK_BUTTON :: 0xC9 HID_USAGE_GENERIC_SYSTEM_DISPLAY_ROTATION_LOCK_SLIDER_SWITCH :: 0xCA -HID_USAGE_GENERIC_CONTROL_ENABLE :: 0xCB +HID_USAGE_GENERIC_CONTROL_ENABLE :: 0xCB -HID_USAGE_SIMULATION_FLIGHT_SIMULATION_DEVICE :: 0x01 -HID_USAGE_SIMULATION_AUTOMOBILE_SIMULATION_DEVICE :: 0x02 -HID_USAGE_SIMULATION_TANK_SIMULATION_DEVICE :: 0x03 -HID_USAGE_SIMULATION_SPACESHIP_SIMULATION_DEVICE :: 0x04 -HID_USAGE_SIMULATION_SUBMARINE_SIMULATION_DEVICE :: 0x05 -HID_USAGE_SIMULATION_SAILING_SIMULATION_DEVICE :: 0x06 -HID_USAGE_SIMULATION_MOTORCYCLE_SIMULATION_DEVICE :: 0x07 -HID_USAGE_SIMULATION_SPORTS_SIMULATION_DEVICE :: 0x08 -HID_USAGE_SIMULATION_AIRPLANE_SIMULATION_DEVICE :: 0x09 -HID_USAGE_SIMULATION_HELICOPTER_SIMULATION_DEVICE :: 0x0A +HID_USAGE_SIMULATION_FLIGHT_SIMULATION_DEVICE :: 0x01 +HID_USAGE_SIMULATION_AUTOMOBILE_SIMULATION_DEVICE :: 0x02 +HID_USAGE_SIMULATION_TANK_SIMULATION_DEVICE :: 0x03 +HID_USAGE_SIMULATION_SPACESHIP_SIMULATION_DEVICE :: 0x04 +HID_USAGE_SIMULATION_SUBMARINE_SIMULATION_DEVICE :: 0x05 +HID_USAGE_SIMULATION_SAILING_SIMULATION_DEVICE :: 0x06 +HID_USAGE_SIMULATION_MOTORCYCLE_SIMULATION_DEVICE :: 0x07 +HID_USAGE_SIMULATION_SPORTS_SIMULATION_DEVICE :: 0x08 +HID_USAGE_SIMULATION_AIRPLANE_SIMULATION_DEVICE :: 0x09 +HID_USAGE_SIMULATION_HELICOPTER_SIMULATION_DEVICE :: 0x0A HID_USAGE_SIMULATION_MAGIC_CARPET_SIMULATION_DEVICE :: 0x0B -HID_USAGE_SIMULATION_BICYCLE_SIMULATION_DEVICE :: 0x0C -HID_USAGE_SIMULATION_FLIGHT_CONTROL_STICK :: 0x20 -HID_USAGE_SIMULATION_FLIGHT_STICK :: 0x21 -HID_USAGE_SIMULATION_CYCLIC_CONTROL :: 0x22 -HID_USAGE_SIMULATION_CYCLIC_TRIM :: 0x23 -HID_USAGE_SIMULATION_FLIGHT_YOKE :: 0x24 -HID_USAGE_SIMULATION_TRACK_CONTROL :: 0x25 +HID_USAGE_SIMULATION_BICYCLE_SIMULATION_DEVICE :: 0x0C +HID_USAGE_SIMULATION_FLIGHT_CONTROL_STICK :: 0x20 +HID_USAGE_SIMULATION_FLIGHT_STICK :: 0x21 +HID_USAGE_SIMULATION_CYCLIC_CONTROL :: 0x22 +HID_USAGE_SIMULATION_CYCLIC_TRIM :: 0x23 +HID_USAGE_SIMULATION_FLIGHT_YOKE :: 0x24 +HID_USAGE_SIMULATION_TRACK_CONTROL :: 0x25 -HID_USAGE_SIMULATION_AILERON :: 0xB0 -HID_USAGE_SIMULATION_AILERON_TRIM :: 0xB1 -HID_USAGE_SIMULATION_ANTI_TORQUE_CONTROL :: 0xB2 -HID_USAGE_SIMULATION_AUTOPIOLOT_ENABLE :: 0xB3 -HID_USAGE_SIMULATION_CHAFF_RELEASE :: 0xB4 -HID_USAGE_SIMULATION_COLLECTIVE_CONTROL :: 0xB5 -HID_USAGE_SIMULATION_DIVE_BRAKE :: 0xB6 +HID_USAGE_SIMULATION_AILERON :: 0xB0 +HID_USAGE_SIMULATION_AILERON_TRIM :: 0xB1 +HID_USAGE_SIMULATION_ANTI_TORQUE_CONTROL :: 0xB2 +HID_USAGE_SIMULATION_AUTOPIOLOT_ENABLE :: 0xB3 +HID_USAGE_SIMULATION_CHAFF_RELEASE :: 0xB4 +HID_USAGE_SIMULATION_COLLECTIVE_CONTROL :: 0xB5 +HID_USAGE_SIMULATION_DIVE_BRAKE :: 0xB6 HID_USAGE_SIMULATION_ELECTRONIC_COUNTERMEASURES :: 0xB7 -HID_USAGE_SIMULATION_ELEVATOR :: 0xB8 -HID_USAGE_SIMULATION_ELEVATOR_TRIM :: 0xB9 -HID_USAGE_SIMULATION_RUDDER :: 0xBA -HID_USAGE_SIMULATION_THROTTLE :: 0xBB -HID_USAGE_SIMULATION_FLIGHT_COMMUNICATIONS :: 0xBC -HID_USAGE_SIMULATION_FLARE_RELEASE :: 0xBD -HID_USAGE_SIMULATION_LANDING_GEAR :: 0xBE -HID_USAGE_SIMULATION_TOE_BRAKE :: 0xBF -HID_USAGE_SIMULATION_TRIGGER :: 0xC0 -HID_USAGE_SIMULATION_WEAPONS_ARM :: 0xC1 -HID_USAGE_SIMULATION_WEAPONS_SELECT :: 0xC2 -HID_USAGE_SIMULATION_WING_FLAPS :: 0xC3 -HID_USAGE_SIMULATION_ACCELLERATOR :: 0xC4 -HID_USAGE_SIMULATION_BRAKE :: 0xC5 -HID_USAGE_SIMULATION_CLUTCH :: 0xC6 -HID_USAGE_SIMULATION_SHIFTER :: 0xC7 -HID_USAGE_SIMULATION_STEERING :: 0xC8 -HID_USAGE_SIMULATION_TURRET_DIRECTION :: 0xC9 -HID_USAGE_SIMULATION_BARREL_ELEVATION :: 0xCA -HID_USAGE_SIMULATION_DIVE_PLANE :: 0xCB -HID_USAGE_SIMULATION_BALLAST :: 0xCC -HID_USAGE_SIMULATION_BICYCLE_CRANK :: 0xCD -HID_USAGE_SIMULATION_HANDLE_BARS :: 0xCE -HID_USAGE_SIMULATION_FRONT_BRAKE :: 0xCF -HID_USAGE_SIMULATION_REAR_BRAKE :: 0xD0 +HID_USAGE_SIMULATION_ELEVATOR :: 0xB8 +HID_USAGE_SIMULATION_ELEVATOR_TRIM :: 0xB9 +HID_USAGE_SIMULATION_RUDDER :: 0xBA +HID_USAGE_SIMULATION_THROTTLE :: 0xBB +HID_USAGE_SIMULATION_FLIGHT_COMMUNICATIONS :: 0xBC +HID_USAGE_SIMULATION_FLARE_RELEASE :: 0xBD +HID_USAGE_SIMULATION_LANDING_GEAR :: 0xBE +HID_USAGE_SIMULATION_TOE_BRAKE :: 0xBF +HID_USAGE_SIMULATION_TRIGGER :: 0xC0 +HID_USAGE_SIMULATION_WEAPONS_ARM :: 0xC1 +HID_USAGE_SIMULATION_WEAPONS_SELECT :: 0xC2 +HID_USAGE_SIMULATION_WING_FLAPS :: 0xC3 +HID_USAGE_SIMULATION_ACCELLERATOR :: 0xC4 +HID_USAGE_SIMULATION_BRAKE :: 0xC5 +HID_USAGE_SIMULATION_CLUTCH :: 0xC6 +HID_USAGE_SIMULATION_SHIFTER :: 0xC7 +HID_USAGE_SIMULATION_STEERING :: 0xC8 +HID_USAGE_SIMULATION_TURRET_DIRECTION :: 0xC9 +HID_USAGE_SIMULATION_BARREL_ELEVATION :: 0xCA +HID_USAGE_SIMULATION_DIVE_PLANE :: 0xCB +HID_USAGE_SIMULATION_BALLAST :: 0xCC +HID_USAGE_SIMULATION_BICYCLE_CRANK :: 0xCD +HID_USAGE_SIMULATION_HANDLE_BARS :: 0xCE +HID_USAGE_SIMULATION_FRONT_BRAKE :: 0xCF +HID_USAGE_SIMULATION_REAR_BRAKE :: 0xD0 -HID_USAGE_VR_BELT :: 0x01 -HID_USAGE_VR_BODY_SUIT :: 0x02 -HID_USAGE_VR_FLEXOR :: 0x03 -HID_USAGE_VR_GLOVE :: 0x04 -HID_USAGE_VR_HEAD_TRACKER :: 0x05 +HID_USAGE_VR_BELT :: 0x01 +HID_USAGE_VR_BODY_SUIT :: 0x02 +HID_USAGE_VR_FLEXOR :: 0x03 +HID_USAGE_VR_GLOVE :: 0x04 +HID_USAGE_VR_HEAD_TRACKER :: 0x05 HID_USAGE_VR_HEAD_MOUNTED_DISPLAY :: 0x06 -HID_USAGE_VR_HAND_TRACKER :: 0x07 -HID_USAGE_VR_OCULOMETER :: 0x08 -HID_USAGE_VR_VEST :: 0x09 -HID_USAGE_VR_ANIMATRONIC_DEVICE :: 0x0A +HID_USAGE_VR_HAND_TRACKER :: 0x07 +HID_USAGE_VR_OCULOMETER :: 0x08 +HID_USAGE_VR_VEST :: 0x09 +HID_USAGE_VR_ANIMATRONIC_DEVICE :: 0x0A -HID_USAGE_VR_STEREO_ENABLE :: 0x20 +HID_USAGE_VR_STEREO_ENABLE :: 0x20 HID_USAGE_VR_DISPLAY_ENABLE :: 0x21 -HID_USAGE_SPORT_BASEBALL_BAT :: 0x01 -HID_USAGE_SPORT_GOLF_CLUB :: 0x02 +HID_USAGE_SPORT_BASEBALL_BAT :: 0x01 +HID_USAGE_SPORT_GOLF_CLUB :: 0x02 HID_USAGE_SPORT_ROWING_MACHINE :: 0x03 -HID_USAGE_SPORT_TREADMILL :: 0x04 -HID_USAGE_SPORT_STICK_TYPE :: 0x38 +HID_USAGE_SPORT_TREADMILL :: 0x04 +HID_USAGE_SPORT_STICK_TYPE :: 0x38 -HID_USAGE_SPORT_OAR :: 0x30 -HID_USAGE_SPORT_SLOPE :: 0x31 -HID_USAGE_SPORT_RATE :: 0x32 -HID_USAGE_SPORT_STICK_SPEED :: 0x33 +HID_USAGE_SPORT_OAR :: 0x30 +HID_USAGE_SPORT_SLOPE :: 0x31 +HID_USAGE_SPORT_RATE :: 0x32 +HID_USAGE_SPORT_STICK_SPEED :: 0x33 HID_USAGE_SPORT_STICK_FACE_ANGLE :: 0x34 -HID_USAGE_SPORT_HEEL_TOE :: 0x35 -HID_USAGE_SPORT_FOLLOW_THROUGH :: 0x36 -HID_USAGE_SPORT_TEMPO :: 0x37 -HID_USAGE_SPORT_HEIGHT :: 0x39 -HID_USAGE_SPORT_PUTTER :: 0x50 -HID_USAGE_SPORT_1_IRON :: 0x51 -HID_USAGE_SPORT_2_IRON :: 0x52 -HID_USAGE_SPORT_3_IRON :: 0x53 -HID_USAGE_SPORT_4_IRON :: 0x54 -HID_USAGE_SPORT_5_IRON :: 0x55 -HID_USAGE_SPORT_6_IRON :: 0x56 -HID_USAGE_SPORT_7_IRON :: 0x57 -HID_USAGE_SPORT_8_IRON :: 0x58 -HID_USAGE_SPORT_9_IRON :: 0x59 -HID_USAGE_SPORT_10_IRON :: 0x5A -HID_USAGE_SPORT_11_IRON :: 0x5B -HID_USAGE_SPORT_SAND_WEDGE :: 0x5C -HID_USAGE_SPORT_LOFT_WEDGE :: 0x5D -HID_USAGE_SPORT_POWER_WEDGE :: 0x5E -HID_USAGE_SPORT_1_WOOD :: 0x5F -HID_USAGE_SPORT_3_WOOD :: 0x60 -HID_USAGE_SPORT_5_WOOD :: 0x61 -HID_USAGE_SPORT_7_WOOD :: 0x62 -HID_USAGE_SPORT_9_WOOD :: 0x63 +HID_USAGE_SPORT_HEEL_TOE :: 0x35 +HID_USAGE_SPORT_FOLLOW_THROUGH :: 0x36 +HID_USAGE_SPORT_TEMPO :: 0x37 +HID_USAGE_SPORT_HEIGHT :: 0x39 +HID_USAGE_SPORT_PUTTER :: 0x50 +HID_USAGE_SPORT_1_IRON :: 0x51 +HID_USAGE_SPORT_2_IRON :: 0x52 +HID_USAGE_SPORT_3_IRON :: 0x53 +HID_USAGE_SPORT_4_IRON :: 0x54 +HID_USAGE_SPORT_5_IRON :: 0x55 +HID_USAGE_SPORT_6_IRON :: 0x56 +HID_USAGE_SPORT_7_IRON :: 0x57 +HID_USAGE_SPORT_8_IRON :: 0x58 +HID_USAGE_SPORT_9_IRON :: 0x59 +HID_USAGE_SPORT_10_IRON :: 0x5A +HID_USAGE_SPORT_11_IRON :: 0x5B +HID_USAGE_SPORT_SAND_WEDGE :: 0x5C +HID_USAGE_SPORT_LOFT_WEDGE :: 0x5D +HID_USAGE_SPORT_POWER_WEDGE :: 0x5E +HID_USAGE_SPORT_1_WOOD :: 0x5F +HID_USAGE_SPORT_3_WOOD :: 0x60 +HID_USAGE_SPORT_5_WOOD :: 0x61 +HID_USAGE_SPORT_7_WOOD :: 0x62 +HID_USAGE_SPORT_9_WOOD :: 0x63 HID_USAGE_GAME_3D_GAME_CONTROLLER :: 0x01 -HID_USAGE_GAME_PINBALL_DEVICE :: 0x02 -HID_USAGE_GAME_GUN_DEVICE :: 0x03 -HID_USAGE_GAME_POINT_OF_VIEW :: 0x20 -HID_USAGE_GAME_GUN_SELECTOR :: 0x32 -HID_USAGE_GAME_GAMEPAD_FIRE_JUMP :: 0x37 -HID_USAGE_GAME_GAMEPAD_TRIGGER :: 0x39 +HID_USAGE_GAME_PINBALL_DEVICE :: 0x02 +HID_USAGE_GAME_GUN_DEVICE :: 0x03 +HID_USAGE_GAME_POINT_OF_VIEW :: 0x20 +HID_USAGE_GAME_GUN_SELECTOR :: 0x32 +HID_USAGE_GAME_GAMEPAD_FIRE_JUMP :: 0x37 +HID_USAGE_GAME_GAMEPAD_TRIGGER :: 0x39 -HID_USAGE_GAME_TURN_RIGHT_LEFT :: 0x21 +HID_USAGE_GAME_TURN_RIGHT_LEFT :: 0x21 HID_USAGE_GAME_PITCH_FORWARD_BACK :: 0x22 -HID_USAGE_GAME_ROLL_RIGHT_LEFT :: 0x23 -HID_USAGE_GAME_MOVE_RIGHT_LEFT :: 0x24 -HID_USAGE_GAME_MOVE_FORWARD_BACK :: 0x25 -HID_USAGE_GAME_MOVE_UP_DOWN :: 0x26 -HID_USAGE_GAME_LEAN_RIGHT_LEFT :: 0x27 -HID_USAGE_GAME_LEAN_FORWARD_BACK :: 0x28 -HID_USAGE_GAME_POV_HEIGHT :: 0x29 -HID_USAGE_GAME_FLIPPER :: 0x2A -HID_USAGE_GAME_SECONDARY_FLIPPER :: 0x2B -HID_USAGE_GAME_BUMP :: 0x2C -HID_USAGE_GAME_NEW_GAME :: 0x2D -HID_USAGE_GAME_SHOOT_BALL :: 0x2E -HID_USAGE_GAME_PLAYER :: 0x2F -HID_USAGE_GAME_GUN_BOLT :: 0x30 -HID_USAGE_GAME_GUN_CLIP :: 0x31 -HID_USAGE_GAME_GUN_SINGLE_SHOT :: 0x33 -HID_USAGE_GAME_GUN_BURST :: 0x34 -HID_USAGE_GAME_GUN_AUTOMATIC :: 0x35 -HID_USAGE_GAME_GUN_SAFETY :: 0x36 +HID_USAGE_GAME_ROLL_RIGHT_LEFT :: 0x23 +HID_USAGE_GAME_MOVE_RIGHT_LEFT :: 0x24 +HID_USAGE_GAME_MOVE_FORWARD_BACK :: 0x25 +HID_USAGE_GAME_MOVE_UP_DOWN :: 0x26 +HID_USAGE_GAME_LEAN_RIGHT_LEFT :: 0x27 +HID_USAGE_GAME_LEAN_FORWARD_BACK :: 0x28 +HID_USAGE_GAME_POV_HEIGHT :: 0x29 +HID_USAGE_GAME_FLIPPER :: 0x2A +HID_USAGE_GAME_SECONDARY_FLIPPER :: 0x2B +HID_USAGE_GAME_BUMP :: 0x2C +HID_USAGE_GAME_NEW_GAME :: 0x2D +HID_USAGE_GAME_SHOOT_BALL :: 0x2E +HID_USAGE_GAME_PLAYER :: 0x2F +HID_USAGE_GAME_GUN_BOLT :: 0x30 +HID_USAGE_GAME_GUN_CLIP :: 0x31 +HID_USAGE_GAME_GUN_SINGLE_SHOT :: 0x33 +HID_USAGE_GAME_GUN_BURST :: 0x34 +HID_USAGE_GAME_GUN_AUTOMATIC :: 0x35 +HID_USAGE_GAME_GUN_SAFETY :: 0x36 -HID_USAGE_GENERIC_DEVICE_BATTERY_STRENGTH :: 0x20 -HID_USAGE_GENERIC_DEVICE_WIRELESS_CHANNEL :: 0x21 -HID_USAGE_GENERIC_DEVICE_WIRELESS_ID :: 0x22 -HID_USAGE_GENERIC_DEVICE_DISCOVER_WIRELESS_CONTROL :: 0x23 +HID_USAGE_GENERIC_DEVICE_BATTERY_STRENGTH :: 0x20 +HID_USAGE_GENERIC_DEVICE_WIRELESS_CHANNEL :: 0x21 +HID_USAGE_GENERIC_DEVICE_WIRELESS_ID :: 0x22 +HID_USAGE_GENERIC_DEVICE_DISCOVER_WIRELESS_CONTROL :: 0x23 HID_USAGE_GENERIC_DEVICE_SECURITY_CODE_CHAR_ENTERED :: 0x24 -HID_USAGE_GENERIC_DEVICE_SECURITY_CODE_CHAR_ERASED :: 0x25 -HID_USAGE_GENERIC_DEVICE_SECURITY_CODE_CLEARED :: 0x26 +HID_USAGE_GENERIC_DEVICE_SECURITY_CODE_CHAR_ERASED :: 0x25 +HID_USAGE_GENERIC_DEVICE_SECURITY_CODE_CLEARED :: 0x26 // Error "keys" -HID_USAGE_KEYBOARD_NOEVENT :: 0x00 -HID_USAGE_KEYBOARD_ROLLOVER :: 0x01 -HID_USAGE_KEYBOARD_POSTFAIL :: 0x02 +HID_USAGE_KEYBOARD_NOEVENT :: 0x00 +HID_USAGE_KEYBOARD_ROLLOVER :: 0x01 +HID_USAGE_KEYBOARD_POSTFAIL :: 0x02 HID_USAGE_KEYBOARD_UNDEFINED :: 0x03 // Letters @@ -265,32 +265,32 @@ HID_USAGE_KEYBOARD_aA :: 0x04 HID_USAGE_KEYBOARD_zZ :: 0x1D // Numbers -HID_USAGE_KEYBOARD_ONE :: 0x1E +HID_USAGE_KEYBOARD_ONE :: 0x1E HID_USAGE_KEYBOARD_ZERO :: 0x27 // Modifier Keys -HID_USAGE_KEYBOARD_LCTRL :: 0xE0 -HID_USAGE_KEYBOARD_LSHFT :: 0xE1 -HID_USAGE_KEYBOARD_LALT :: 0xE2 -HID_USAGE_KEYBOARD_LGUI :: 0xE3 -HID_USAGE_KEYBOARD_RCTRL :: 0xE4 -HID_USAGE_KEYBOARD_RSHFT :: 0xE5 -HID_USAGE_KEYBOARD_RALT :: 0xE6 -HID_USAGE_KEYBOARD_RGUI :: 0xE7 +HID_USAGE_KEYBOARD_LCTRL :: 0xE0 +HID_USAGE_KEYBOARD_LSHFT :: 0xE1 +HID_USAGE_KEYBOARD_LALT :: 0xE2 +HID_USAGE_KEYBOARD_LGUI :: 0xE3 +HID_USAGE_KEYBOARD_RCTRL :: 0xE4 +HID_USAGE_KEYBOARD_RSHFT :: 0xE5 +HID_USAGE_KEYBOARD_RALT :: 0xE6 +HID_USAGE_KEYBOARD_RGUI :: 0xE7 HID_USAGE_KEYBOARD_SCROLL_LOCK :: 0x47 -HID_USAGE_KEYBOARD_NUM_LOCK :: 0x53 -HID_USAGE_KEYBOARD_CAPS_LOCK :: 0x39 +HID_USAGE_KEYBOARD_NUM_LOCK :: 0x53 +HID_USAGE_KEYBOARD_CAPS_LOCK :: 0x39 // Function keys -HID_USAGE_KEYBOARD_F1 :: 0x3A -HID_USAGE_KEYBOARD_F2 :: 0x3B -HID_USAGE_KEYBOARD_F3 :: 0x3C -HID_USAGE_KEYBOARD_F4 :: 0x3D -HID_USAGE_KEYBOARD_F5 :: 0x3E -HID_USAGE_KEYBOARD_F6 :: 0x3F -HID_USAGE_KEYBOARD_F7 :: 0x40 -HID_USAGE_KEYBOARD_F8 :: 0x41 -HID_USAGE_KEYBOARD_F9 :: 0x42 +HID_USAGE_KEYBOARD_F1 :: 0x3A +HID_USAGE_KEYBOARD_F2 :: 0x3B +HID_USAGE_KEYBOARD_F3 :: 0x3C +HID_USAGE_KEYBOARD_F4 :: 0x3D +HID_USAGE_KEYBOARD_F5 :: 0x3E +HID_USAGE_KEYBOARD_F6 :: 0x3F +HID_USAGE_KEYBOARD_F7 :: 0x40 +HID_USAGE_KEYBOARD_F8 :: 0x41 +HID_USAGE_KEYBOARD_F9 :: 0x42 HID_USAGE_KEYBOARD_F10 :: 0x43 HID_USAGE_KEYBOARD_F11 :: 0x44 HID_USAGE_KEYBOARD_F12 :: 0x45 @@ -315,103 +315,103 @@ HID_USAGE_KEYBOARD_PRINT_SCREEN :: 0x46 HID_USAGE_KEYBOARD_DELETE_FORWARD :: 0x4C // Numeric Keypad -HID_USAGE_KEYBOARD_KEYPAD_1_AND_END :: 0x59 +HID_USAGE_KEYBOARD_KEYPAD_1_AND_END :: 0x59 HID_USAGE_KEYBOARD_KEYPAD_0_AND_INSERT :: 0x62 -HID_USAGE_LED_NUM_LOCK :: 0x01 -HID_USAGE_LED_CAPS_LOCK :: 0x02 -HID_USAGE_LED_SCROLL_LOCK :: 0x03 -HID_USAGE_LED_COMPOSE :: 0x04 -HID_USAGE_LED_KANA :: 0x05 -HID_USAGE_LED_POWER :: 0x06 -HID_USAGE_LED_SHIFT :: 0x07 -HID_USAGE_LED_DO_NOT_DISTURB :: 0x08 -HID_USAGE_LED_MUTE :: 0x09 -HID_USAGE_LED_TONE_ENABLE :: 0x0A -HID_USAGE_LED_HIGH_CUT_FILTER :: 0x0B -HID_USAGE_LED_LOW_CUT_FILTER :: 0x0C -HID_USAGE_LED_EQUALIZER_ENABLE :: 0x0D -HID_USAGE_LED_SOUND_FIELD_ON :: 0x0E -HID_USAGE_LED_SURROUND_FIELD_ON :: 0x0F -HID_USAGE_LED_REPEAT :: 0x10 -HID_USAGE_LED_STEREO :: 0x11 +HID_USAGE_LED_NUM_LOCK :: 0x01 +HID_USAGE_LED_CAPS_LOCK :: 0x02 +HID_USAGE_LED_SCROLL_LOCK :: 0x03 +HID_USAGE_LED_COMPOSE :: 0x04 +HID_USAGE_LED_KANA :: 0x05 +HID_USAGE_LED_POWER :: 0x06 +HID_USAGE_LED_SHIFT :: 0x07 +HID_USAGE_LED_DO_NOT_DISTURB :: 0x08 +HID_USAGE_LED_MUTE :: 0x09 +HID_USAGE_LED_TONE_ENABLE :: 0x0A +HID_USAGE_LED_HIGH_CUT_FILTER :: 0x0B +HID_USAGE_LED_LOW_CUT_FILTER :: 0x0C +HID_USAGE_LED_EQUALIZER_ENABLE :: 0x0D +HID_USAGE_LED_SOUND_FIELD_ON :: 0x0E +HID_USAGE_LED_SURROUND_FIELD_ON :: 0x0F +HID_USAGE_LED_REPEAT :: 0x10 +HID_USAGE_LED_STEREO :: 0x11 HID_USAGE_LED_SAMPLING_RATE_DETECT :: 0x12 -HID_USAGE_LED_SPINNING :: 0x13 -HID_USAGE_LED_CAV :: 0x14 -HID_USAGE_LED_CLV :: 0x15 +HID_USAGE_LED_SPINNING :: 0x13 +HID_USAGE_LED_CAV :: 0x14 +HID_USAGE_LED_CLV :: 0x15 HID_USAGE_LED_RECORDING_FORMAT_DET :: 0x16 -HID_USAGE_LED_OFF_HOOK :: 0x17 -HID_USAGE_LED_RING :: 0x18 -HID_USAGE_LED_MESSAGE_WAITING :: 0x19 -HID_USAGE_LED_DATA_MODE :: 0x1A -HID_USAGE_LED_BATTERY_OPERATION :: 0x1B -HID_USAGE_LED_BATTERY_OK :: 0x1C -HID_USAGE_LED_BATTERY_LOW :: 0x1D -HID_USAGE_LED_SPEAKER :: 0x1E -HID_USAGE_LED_HEAD_SET :: 0x1F -HID_USAGE_LED_HOLD :: 0x20 -HID_USAGE_LED_MICROPHONE :: 0x21 -HID_USAGE_LED_COVERAGE :: 0x22 -HID_USAGE_LED_NIGHT_MODE :: 0x23 -HID_USAGE_LED_SEND_CALLS :: 0x24 -HID_USAGE_LED_CALL_PICKUP :: 0x25 -HID_USAGE_LED_CONFERENCE :: 0x26 -HID_USAGE_LED_STAND_BY :: 0x27 -HID_USAGE_LED_CAMERA_ON :: 0x28 -HID_USAGE_LED_CAMERA_OFF :: 0x29 -HID_USAGE_LED_ON_LINE :: 0x2A -HID_USAGE_LED_OFF_LINE :: 0x2B -HID_USAGE_LED_BUSY :: 0x2C -HID_USAGE_LED_READY :: 0x2D -HID_USAGE_LED_PAPER_OUT :: 0x2E -HID_USAGE_LED_PAPER_JAM :: 0x2F -HID_USAGE_LED_REMOTE :: 0x30 -HID_USAGE_LED_FORWARD :: 0x31 -HID_USAGE_LED_REVERSE :: 0x32 -HID_USAGE_LED_STOP :: 0x33 -HID_USAGE_LED_REWIND :: 0x34 -HID_USAGE_LED_FAST_FORWARD :: 0x35 -HID_USAGE_LED_PLAY :: 0x36 -HID_USAGE_LED_PAUSE :: 0x37 -HID_USAGE_LED_RECORD :: 0x38 -HID_USAGE_LED_ERROR :: 0x39 -HID_USAGE_LED_SELECTED_INDICATOR :: 0x3A -HID_USAGE_LED_IN_USE_INDICATOR :: 0x3B +HID_USAGE_LED_OFF_HOOK :: 0x17 +HID_USAGE_LED_RING :: 0x18 +HID_USAGE_LED_MESSAGE_WAITING :: 0x19 +HID_USAGE_LED_DATA_MODE :: 0x1A +HID_USAGE_LED_BATTERY_OPERATION :: 0x1B +HID_USAGE_LED_BATTERY_OK :: 0x1C +HID_USAGE_LED_BATTERY_LOW :: 0x1D +HID_USAGE_LED_SPEAKER :: 0x1E +HID_USAGE_LED_HEAD_SET :: 0x1F +HID_USAGE_LED_HOLD :: 0x20 +HID_USAGE_LED_MICROPHONE :: 0x21 +HID_USAGE_LED_COVERAGE :: 0x22 +HID_USAGE_LED_NIGHT_MODE :: 0x23 +HID_USAGE_LED_SEND_CALLS :: 0x24 +HID_USAGE_LED_CALL_PICKUP :: 0x25 +HID_USAGE_LED_CONFERENCE :: 0x26 +HID_USAGE_LED_STAND_BY :: 0x27 +HID_USAGE_LED_CAMERA_ON :: 0x28 +HID_USAGE_LED_CAMERA_OFF :: 0x29 +HID_USAGE_LED_ON_LINE :: 0x2A +HID_USAGE_LED_OFF_LINE :: 0x2B +HID_USAGE_LED_BUSY :: 0x2C +HID_USAGE_LED_READY :: 0x2D +HID_USAGE_LED_PAPER_OUT :: 0x2E +HID_USAGE_LED_PAPER_JAM :: 0x2F +HID_USAGE_LED_REMOTE :: 0x30 +HID_USAGE_LED_FORWARD :: 0x31 +HID_USAGE_LED_REVERSE :: 0x32 +HID_USAGE_LED_STOP :: 0x33 +HID_USAGE_LED_REWIND :: 0x34 +HID_USAGE_LED_FAST_FORWARD :: 0x35 +HID_USAGE_LED_PLAY :: 0x36 +HID_USAGE_LED_PAUSE :: 0x37 +HID_USAGE_LED_RECORD :: 0x38 +HID_USAGE_LED_ERROR :: 0x39 +HID_USAGE_LED_SELECTED_INDICATOR :: 0x3A +HID_USAGE_LED_IN_USE_INDICATOR :: 0x3B HID_USAGE_LED_MULTI_MODE_INDICATOR :: 0x3C -HID_USAGE_LED_INDICATOR_ON :: 0x3D -HID_USAGE_LED_INDICATOR_FLASH :: 0x3E +HID_USAGE_LED_INDICATOR_ON :: 0x3D +HID_USAGE_LED_INDICATOR_FLASH :: 0x3E HID_USAGE_LED_INDICATOR_SLOW_BLINK :: 0x3F HID_USAGE_LED_INDICATOR_FAST_BLINK :: 0x40 -HID_USAGE_LED_INDICATOR_OFF :: 0x41 -HID_USAGE_LED_FLASH_ON_TIME :: 0x42 -HID_USAGE_LED_SLOW_BLINK_ON_TIME :: 0x43 -HID_USAGE_LED_SLOW_BLINK_OFF_TIME :: 0x44 -HID_USAGE_LED_FAST_BLINK_ON_TIME :: 0x45 -HID_USAGE_LED_FAST_BLINK_OFF_TIME :: 0x46 -HID_USAGE_LED_INDICATOR_COLOR :: 0x47 -HID_USAGE_LED_RED :: 0x48 -HID_USAGE_LED_GREEN :: 0x49 -HID_USAGE_LED_AMBER :: 0x4A -HID_USAGE_LED_GENERIC_INDICATOR :: 0x4B -HID_USAGE_LED_SYSTEM_SUSPEND :: 0x4C -HID_USAGE_LED_EXTERNAL_POWER :: 0x4D +HID_USAGE_LED_INDICATOR_OFF :: 0x41 +HID_USAGE_LED_FLASH_ON_TIME :: 0x42 +HID_USAGE_LED_SLOW_BLINK_ON_TIME :: 0x43 +HID_USAGE_LED_SLOW_BLINK_OFF_TIME :: 0x44 +HID_USAGE_LED_FAST_BLINK_ON_TIME :: 0x45 +HID_USAGE_LED_FAST_BLINK_OFF_TIME :: 0x46 +HID_USAGE_LED_INDICATOR_COLOR :: 0x47 +HID_USAGE_LED_RED :: 0x48 +HID_USAGE_LED_GREEN :: 0x49 +HID_USAGE_LED_AMBER :: 0x4A +HID_USAGE_LED_GENERIC_INDICATOR :: 0x4B +HID_USAGE_LED_SYSTEM_SUSPEND :: 0x4C +HID_USAGE_LED_EXTERNAL_POWER :: 0x4D -HID_USAGE_TELEPHONY_PHONE :: 0x01 -HID_USAGE_TELEPHONY_ANSWERING_MACHINE :: 0x02 -HID_USAGE_TELEPHONY_MESSAGE_CONTROLS :: 0x03 -HID_USAGE_TELEPHONY_HANDSET :: 0x04 -HID_USAGE_TELEPHONY_HEADSET :: 0x05 -HID_USAGE_TELEPHONY_KEYPAD :: 0x06 +HID_USAGE_TELEPHONY_PHONE :: 0x01 +HID_USAGE_TELEPHONY_ANSWERING_MACHINE :: 0x02 +HID_USAGE_TELEPHONY_MESSAGE_CONTROLS :: 0x03 +HID_USAGE_TELEPHONY_HANDSET :: 0x04 +HID_USAGE_TELEPHONY_HEADSET :: 0x05 +HID_USAGE_TELEPHONY_KEYPAD :: 0x06 HID_USAGE_TELEPHONY_PROGRAMMABLE_BUTTON :: 0x07 -HID_USAGE_TELEPHONY_REDIAL :: 0x24 -HID_USAGE_TELEPHONY_TRANSFER :: 0x25 -HID_USAGE_TELEPHONY_DROP :: 0x26 -HID_USAGE_TELEPHONY_LINE :: 0x2A -HID_USAGE_TELEPHONY_RING_ENABLE :: 0x2D -HID_USAGE_TELEPHONY_SEND :: 0x31 -HID_USAGE_TELEPHONY_KEYPAD_0 :: 0xB0 -HID_USAGE_TELEPHONY_KEYPAD_D :: 0xBF -HID_USAGE_TELEPHONY_HOST_AVAILABLE :: 0xF1 +HID_USAGE_TELEPHONY_REDIAL :: 0x24 +HID_USAGE_TELEPHONY_TRANSFER :: 0x25 +HID_USAGE_TELEPHONY_DROP :: 0x26 +HID_USAGE_TELEPHONY_LINE :: 0x2A +HID_USAGE_TELEPHONY_RING_ENABLE :: 0x2D +HID_USAGE_TELEPHONY_SEND :: 0x31 +HID_USAGE_TELEPHONY_KEYPAD_0 :: 0xB0 +HID_USAGE_TELEPHONY_KEYPAD_D :: 0xBF +HID_USAGE_TELEPHONY_HOST_AVAILABLE :: 0xF1 HID_USAGE_CONSUMERCTRL :: 0x01 @@ -420,271 +420,271 @@ HID_USAGE_CONSUMER_CHANNEL_INCREMENT :: 0x9C HID_USAGE_CONSUMER_CHANNEL_DECREMENT :: 0x9D // transport control -HID_USAGE_CONSUMER_PLAY :: 0xB0 -HID_USAGE_CONSUMER_PAUSE :: 0xB1 -HID_USAGE_CONSUMER_RECORD :: 0xB2 -HID_USAGE_CONSUMER_FAST_FORWARD :: 0xB3 -HID_USAGE_CONSUMER_REWIND :: 0xB4 +HID_USAGE_CONSUMER_PLAY :: 0xB0 +HID_USAGE_CONSUMER_PAUSE :: 0xB1 +HID_USAGE_CONSUMER_RECORD :: 0xB2 +HID_USAGE_CONSUMER_FAST_FORWARD :: 0xB3 +HID_USAGE_CONSUMER_REWIND :: 0xB4 HID_USAGE_CONSUMER_SCAN_NEXT_TRACK :: 0xB5 HID_USAGE_CONSUMER_SCAN_PREV_TRACK :: 0xB6 -HID_USAGE_CONSUMER_STOP :: 0xB7 -HID_USAGE_CONSUMER_PLAY_PAUSE :: 0xCD +HID_USAGE_CONSUMER_STOP :: 0xB7 +HID_USAGE_CONSUMER_PLAY_PAUSE :: 0xCD // GameDVR -HID_USAGE_CONSUMER_GAMEDVR_OPEN_GAMEBAR :: 0xD0 -HID_USAGE_CONSUMER_GAMEDVR_TOGGLE_RECORD :: 0xD1 -HID_USAGE_CONSUMER_GAMEDVR_RECORD_CLIP :: 0xD2 -HID_USAGE_CONSUMER_GAMEDVR_SCREENSHOT :: 0xD3 -HID_USAGE_CONSUMER_GAMEDVR_TOGGLE_INDICATOR :: 0xD4 +HID_USAGE_CONSUMER_GAMEDVR_OPEN_GAMEBAR :: 0xD0 +HID_USAGE_CONSUMER_GAMEDVR_TOGGLE_RECORD :: 0xD1 +HID_USAGE_CONSUMER_GAMEDVR_RECORD_CLIP :: 0xD2 +HID_USAGE_CONSUMER_GAMEDVR_SCREENSHOT :: 0xD3 +HID_USAGE_CONSUMER_GAMEDVR_TOGGLE_INDICATOR :: 0xD4 HID_USAGE_CONSUMER_GAMEDVR_TOGGLE_MICROPHONE :: 0xD5 -HID_USAGE_CONSUMER_GAMEDVR_TOGGLE_CAMERA :: 0xD6 -HID_USAGE_CONSUMER_GAMEDVR_TOGGLE_BROADCAST :: 0xD7 +HID_USAGE_CONSUMER_GAMEDVR_TOGGLE_CAMERA :: 0xD6 +HID_USAGE_CONSUMER_GAMEDVR_TOGGLE_BROADCAST :: 0xD7 // audio -HID_USAGE_CONSUMER_VOLUME :: 0xE0 -HID_USAGE_CONSUMER_BALANCE :: 0xE1 -HID_USAGE_CONSUMER_MUTE :: 0xE2 -HID_USAGE_CONSUMER_BASS :: 0xE3 -HID_USAGE_CONSUMER_TREBLE :: 0xE4 -HID_USAGE_CONSUMER_BASS_BOOST :: 0xE5 -HID_USAGE_CONSUMER_SURROUND_MODE :: 0xE6 -HID_USAGE_CONSUMER_LOUDNESS :: 0xE7 -HID_USAGE_CONSUMER_MPX :: 0xE8 +HID_USAGE_CONSUMER_VOLUME :: 0xE0 +HID_USAGE_CONSUMER_BALANCE :: 0xE1 +HID_USAGE_CONSUMER_MUTE :: 0xE2 +HID_USAGE_CONSUMER_BASS :: 0xE3 +HID_USAGE_CONSUMER_TREBLE :: 0xE4 +HID_USAGE_CONSUMER_BASS_BOOST :: 0xE5 +HID_USAGE_CONSUMER_SURROUND_MODE :: 0xE6 +HID_USAGE_CONSUMER_LOUDNESS :: 0xE7 +HID_USAGE_CONSUMER_MPX :: 0xE8 HID_USAGE_CONSUMER_VOLUME_INCREMENT :: 0xE9 HID_USAGE_CONSUMER_VOLUME_DECREMENT :: 0xEA // supplementary audio -HID_USAGE_CONSUMER_BASS_INCREMENT :: 0x152 -HID_USAGE_CONSUMER_BASS_DECREMENT :: 0x153 +HID_USAGE_CONSUMER_BASS_INCREMENT :: 0x152 +HID_USAGE_CONSUMER_BASS_DECREMENT :: 0x153 HID_USAGE_CONSUMER_TREBLE_INCREMENT :: 0x154 HID_USAGE_CONSUMER_TREBLE_DECREMENT :: 0x155 // Application Launch HID_USAGE_CONSUMER_AL_CONFIGURATION :: 0x183 -HID_USAGE_CONSUMER_AL_EMAIL :: 0x18A -HID_USAGE_CONSUMER_AL_CALCULATOR :: 0x192 -HID_USAGE_CONSUMER_AL_BROWSER :: 0x194 -HID_USAGE_CONSUMER_AL_SEARCH :: 0x1C6 +HID_USAGE_CONSUMER_AL_EMAIL :: 0x18A +HID_USAGE_CONSUMER_AL_CALCULATOR :: 0x192 +HID_USAGE_CONSUMER_AL_BROWSER :: 0x194 +HID_USAGE_CONSUMER_AL_SEARCH :: 0x1C6 // Application Control -HID_USAGE_CONSUMER_AC_SEARCH :: 0x221 -HID_USAGE_CONSUMER_AC_GOTO :: 0x222 -HID_USAGE_CONSUMER_AC_HOME :: 0x223 -HID_USAGE_CONSUMER_AC_BACK :: 0x224 -HID_USAGE_CONSUMER_AC_FORWARD :: 0x225 -HID_USAGE_CONSUMER_AC_STOP :: 0x226 -HID_USAGE_CONSUMER_AC_REFRESH :: 0x227 -HID_USAGE_CONSUMER_AC_PREVIOUS :: 0x228 -HID_USAGE_CONSUMER_AC_NEXT :: 0x229 +HID_USAGE_CONSUMER_AC_SEARCH :: 0x221 +HID_USAGE_CONSUMER_AC_GOTO :: 0x222 +HID_USAGE_CONSUMER_AC_HOME :: 0x223 +HID_USAGE_CONSUMER_AC_BACK :: 0x224 +HID_USAGE_CONSUMER_AC_FORWARD :: 0x225 +HID_USAGE_CONSUMER_AC_STOP :: 0x226 +HID_USAGE_CONSUMER_AC_REFRESH :: 0x227 +HID_USAGE_CONSUMER_AC_PREVIOUS :: 0x228 +HID_USAGE_CONSUMER_AC_NEXT :: 0x229 HID_USAGE_CONSUMER_AC_BOOKMARKS :: 0x22A -HID_USAGE_CONSUMER_AC_PAN :: 0x238 +HID_USAGE_CONSUMER_AC_PAN :: 0x238 // Keyboard Extended Attributes (defined on consumer page in HUTRR42) -HID_USAGE_CONSUMER_EXTENDED_KEYBOARD_ATTRIBUTES_COLLECTION :: 0x2C0 -HID_USAGE_CONSUMER_KEYBOARD_FORM_FACTOR :: 0x2C1 -HID_USAGE_CONSUMER_KEYBOARD_KEY_TYPE :: 0x2C2 -HID_USAGE_CONSUMER_KEYBOARD_PHYSICAL_LAYOUT :: 0x2C3 -HID_USAGE_CONSUMER_VENDOR_SPECIFIC_KEYBOARD_PHYSICAL_LAYOUT :: 0x2C4 -HID_USAGE_CONSUMER_KEYBOARD_IETF_LANGUAGE_TAG_INDEX :: 0x2C5 +HID_USAGE_CONSUMER_EXTENDED_KEYBOARD_ATTRIBUTES_COLLECTION :: 0x2C0 +HID_USAGE_CONSUMER_KEYBOARD_FORM_FACTOR :: 0x2C1 +HID_USAGE_CONSUMER_KEYBOARD_KEY_TYPE :: 0x2C2 +HID_USAGE_CONSUMER_KEYBOARD_PHYSICAL_LAYOUT :: 0x2C3 +HID_USAGE_CONSUMER_VENDOR_SPECIFIC_KEYBOARD_PHYSICAL_LAYOUT :: 0x2C4 +HID_USAGE_CONSUMER_KEYBOARD_IETF_LANGUAGE_TAG_INDEX :: 0x2C5 HID_USAGE_CONSUMER_IMPLEMENTED_KEYBOARD_INPUT_ASSIST_CONTROLS :: 0x2C6 -HID_USAGE_DIGITIZER_DIGITIZER :: 0x01 -HID_USAGE_DIGITIZER_PEN :: 0x02 -HID_USAGE_DIGITIZER_LIGHT_PEN :: 0x03 -HID_USAGE_DIGITIZER_TOUCH_SCREEN :: 0x04 -HID_USAGE_DIGITIZER_TOUCH_PAD :: 0x05 -HID_USAGE_DIGITIZER_WHITE_BOARD :: 0x06 -HID_USAGE_DIGITIZER_COORD_MEASURING :: 0x07 -HID_USAGE_DIGITIZER_3D_DIGITIZER :: 0x08 -HID_USAGE_DIGITIZER_STEREO_PLOTTER :: 0x09 -HID_USAGE_DIGITIZER_ARTICULATED_ARM :: 0x0A -HID_USAGE_DIGITIZER_ARMATURE :: 0x0B -HID_USAGE_DIGITIZER_MULTI_POINT :: 0x0C -HID_USAGE_DIGITIZER_FREE_SPACE_WAND :: 0x0D -HID_USAGE_DIGITIZER_HEAT_MAP :: 0x0F -HID_USAGE_DIGITIZER_STYLUS :: 0x20 -HID_USAGE_DIGITIZER_PUCK :: 0x21 -HID_USAGE_DIGITIZER_FINGER :: 0x22 +HID_USAGE_DIGITIZER_DIGITIZER :: 0x01 +HID_USAGE_DIGITIZER_PEN :: 0x02 +HID_USAGE_DIGITIZER_LIGHT_PEN :: 0x03 +HID_USAGE_DIGITIZER_TOUCH_SCREEN :: 0x04 +HID_USAGE_DIGITIZER_TOUCH_PAD :: 0x05 +HID_USAGE_DIGITIZER_WHITE_BOARD :: 0x06 +HID_USAGE_DIGITIZER_COORD_MEASURING :: 0x07 +HID_USAGE_DIGITIZER_3D_DIGITIZER :: 0x08 +HID_USAGE_DIGITIZER_STEREO_PLOTTER :: 0x09 +HID_USAGE_DIGITIZER_ARTICULATED_ARM :: 0x0A +HID_USAGE_DIGITIZER_ARMATURE :: 0x0B +HID_USAGE_DIGITIZER_MULTI_POINT :: 0x0C +HID_USAGE_DIGITIZER_FREE_SPACE_WAND :: 0x0D +HID_USAGE_DIGITIZER_HEAT_MAP :: 0x0F +HID_USAGE_DIGITIZER_STYLUS :: 0x20 +HID_USAGE_DIGITIZER_PUCK :: 0x21 +HID_USAGE_DIGITIZER_FINGER :: 0x22 HID_USAGE_DIGITIZER_TABLET_FUNC_KEYS :: 0x39 HID_USAGE_DIGITIZER_PROG_CHANGE_KEYS :: 0x3A -HID_USAGE_DIGITIZER_TIP_PRESSURE :: 0x30 -HID_USAGE_DIGITIZER_BARREL_PRESSURE :: 0x31 -HID_USAGE_DIGITIZER_IN_RANGE :: 0x32 -HID_USAGE_DIGITIZER_TOUCH :: 0x33 -HID_USAGE_DIGITIZER_UNTOUCH :: 0x34 -HID_USAGE_DIGITIZER_TAP :: 0x35 -HID_USAGE_DIGITIZER_QUALITY :: 0x36 -HID_USAGE_DIGITIZER_DATA_VALID :: 0x37 -HID_USAGE_DIGITIZER_TRANSDUCER_INDEX :: 0x38 -HID_USAGE_DIGITIZER_BATTERY_STRENGTH :: 0x3B -HID_USAGE_DIGITIZER_INVERT :: 0x3C -HID_USAGE_DIGITIZER_X_TILT :: 0x3D -HID_USAGE_DIGITIZER_Y_TILT :: 0x3E -HID_USAGE_DIGITIZER_AZIMUTH :: 0x3F -HID_USAGE_DIGITIZER_ALTITUDE :: 0x40 -HID_USAGE_DIGITIZER_TWIST :: 0x41 -HID_USAGE_DIGITIZER_TIP_SWITCH :: 0x42 -HID_USAGE_DIGITIZER_SECONDARY_TIP_SWITCH :: 0x43 -HID_USAGE_DIGITIZER_BARREL_SWITCH :: 0x44 -HID_USAGE_DIGITIZER_ERASER :: 0x45 -HID_USAGE_DIGITIZER_TABLET_PICK :: 0x46 -HID_USAGE_DIGITIZER_TRANSDUCER_SERIAL :: 0x5B +HID_USAGE_DIGITIZER_TIP_PRESSURE :: 0x30 +HID_USAGE_DIGITIZER_BARREL_PRESSURE :: 0x31 +HID_USAGE_DIGITIZER_IN_RANGE :: 0x32 +HID_USAGE_DIGITIZER_TOUCH :: 0x33 +HID_USAGE_DIGITIZER_UNTOUCH :: 0x34 +HID_USAGE_DIGITIZER_TAP :: 0x35 +HID_USAGE_DIGITIZER_QUALITY :: 0x36 +HID_USAGE_DIGITIZER_DATA_VALID :: 0x37 +HID_USAGE_DIGITIZER_TRANSDUCER_INDEX :: 0x38 +HID_USAGE_DIGITIZER_BATTERY_STRENGTH :: 0x3B +HID_USAGE_DIGITIZER_INVERT :: 0x3C +HID_USAGE_DIGITIZER_X_TILT :: 0x3D +HID_USAGE_DIGITIZER_Y_TILT :: 0x3E +HID_USAGE_DIGITIZER_AZIMUTH :: 0x3F +HID_USAGE_DIGITIZER_ALTITUDE :: 0x40 +HID_USAGE_DIGITIZER_TWIST :: 0x41 +HID_USAGE_DIGITIZER_TIP_SWITCH :: 0x42 +HID_USAGE_DIGITIZER_SECONDARY_TIP_SWITCH :: 0x43 +HID_USAGE_DIGITIZER_BARREL_SWITCH :: 0x44 +HID_USAGE_DIGITIZER_ERASER :: 0x45 +HID_USAGE_DIGITIZER_TABLET_PICK :: 0x46 +HID_USAGE_DIGITIZER_TRANSDUCER_SERIAL :: 0x5B HID_USAGE_DIGITIZER_HEAT_MAP_PROTOCOL_VENDOR_ID :: 0x6A -HID_USAGE_DIGITIZER_HEAT_MAP_PROTOCOL_VERSION :: 0x6B -HID_USAGE_DIGITIZER_HEAT_MAP_FRAME_DATA :: 0x6C -HID_USAGE_DIGITIZER_TRANSDUCER_SERIAL_PART2 :: 0x6E -HID_USAGE_DIGITIZER_TRANSDUCER_VENDOR :: 0x91 -HID_USAGE_DIGITIZER_TRANSDUCER_PRODUCT :: 0x92 -HID_USAGE_DIGITIZER_TRANSDUCER_CONNECTED :: 0xA2 +HID_USAGE_DIGITIZER_HEAT_MAP_PROTOCOL_VERSION :: 0x6B +HID_USAGE_DIGITIZER_HEAT_MAP_FRAME_DATA :: 0x6C +HID_USAGE_DIGITIZER_TRANSDUCER_SERIAL_PART2 :: 0x6E +HID_USAGE_DIGITIZER_TRANSDUCER_VENDOR :: 0x91 +HID_USAGE_DIGITIZER_TRANSDUCER_PRODUCT :: 0x92 +HID_USAGE_DIGITIZER_TRANSDUCER_CONNECTED :: 0xA2 HID_USAGE_HAPTICS_SIMPLE_CONTROLLER :: 0x01 HID_USAGE_HAPTICS_WAVEFORM_LIST :: 0x10 HID_USAGE_HAPTICS_DURATION_LIST :: 0x11 -HID_USAGE_HAPTICS_AUTO_TRIGGER :: 0x20 -HID_USAGE_HAPTICS_MANUAL_TRIGGER :: 0x21 +HID_USAGE_HAPTICS_AUTO_TRIGGER :: 0x20 +HID_USAGE_HAPTICS_MANUAL_TRIGGER :: 0x21 HID_USAGE_HAPTICS_AUTO_ASSOCIATED_CONTROL :: 0x22 -HID_USAGE_HAPTICS_INTENSITY :: 0x23 -HID_USAGE_HAPTICS_REPEAT_COUNT :: 0x24 -HID_USAGE_HAPTICS_RETRIGGER_PERIOD :: 0x25 -HID_USAGE_HAPTICS_WAVEFORM_VENDOR_PAGE :: 0x26 -HID_USAGE_HAPTICS_WAVEFORM_VENDOR_ID :: 0x27 -HID_USAGE_HAPTICS_WAVEFORM_CUTOFF_TIME :: 0x28 +HID_USAGE_HAPTICS_INTENSITY :: 0x23 +HID_USAGE_HAPTICS_REPEAT_COUNT :: 0x24 +HID_USAGE_HAPTICS_RETRIGGER_PERIOD :: 0x25 +HID_USAGE_HAPTICS_WAVEFORM_VENDOR_PAGE :: 0x26 +HID_USAGE_HAPTICS_WAVEFORM_VENDOR_ID :: 0x27 +HID_USAGE_HAPTICS_WAVEFORM_CUTOFF_TIME :: 0x28 // Waveform types -HID_USAGE_HAPTICS_WAVEFORM_BEGIN :: 0x1000 -HID_USAGE_HAPTICS_WAVEFORM_STOP :: 0x1001 -HID_USAGE_HAPTICS_WAVEFORM_NULL :: 0x1002 -HID_USAGE_HAPTICS_WAVEFORM_CLICK :: 0x1003 -HID_USAGE_HAPTICS_WAVEFORM_BUZZ :: 0x1004 -HID_USAGE_HAPTICS_WAVEFORM_RUMBLE :: 0x1005 -HID_USAGE_HAPTICS_WAVEFORM_PRESS :: 0x1006 +HID_USAGE_HAPTICS_WAVEFORM_BEGIN :: 0x1000 +HID_USAGE_HAPTICS_WAVEFORM_STOP :: 0x1001 +HID_USAGE_HAPTICS_WAVEFORM_NULL :: 0x1002 +HID_USAGE_HAPTICS_WAVEFORM_CLICK :: 0x1003 +HID_USAGE_HAPTICS_WAVEFORM_BUZZ :: 0x1004 +HID_USAGE_HAPTICS_WAVEFORM_RUMBLE :: 0x1005 +HID_USAGE_HAPTICS_WAVEFORM_PRESS :: 0x1006 HID_USAGE_HAPTICS_WAVEFORM_RELEASE :: 0x1007 -HID_USAGE_HAPTICS_WAVEFORM_END :: 0x1FFF +HID_USAGE_HAPTICS_WAVEFORM_END :: 0x1FFF HID_USAGE_HAPTICS_WAVEFORM_VENDOR_BEGIN :: 0x2000 -HID_USAGE_HAPTICS_WAVEFORM_VENDOR_END :: 0x2FFF +HID_USAGE_HAPTICS_WAVEFORM_VENDOR_END :: 0x2FFF -HID_USAGE_ALPHANUMERIC_ALPHANUMERIC_DISPLAY :: 0x01 -HID_USAGE_ALPHANUMERIC_BITMAPPED_DISPLAY :: 0x02 +HID_USAGE_ALPHANUMERIC_ALPHANUMERIC_DISPLAY :: 0x01 +HID_USAGE_ALPHANUMERIC_BITMAPPED_DISPLAY :: 0x02 HID_USAGE_ALPHANUMERIC_DISPLAY_ATTRIBUTES_REPORT :: 0x20 -HID_USAGE_ALPHANUMERIC_DISPLAY_CONTROL_REPORT :: 0x24 -HID_USAGE_ALPHANUMERIC_CHARACTER_REPORT :: 0x2B -HID_USAGE_ALPHANUMERIC_DISPLAY_STATUS :: 0x2D -HID_USAGE_ALPHANUMERIC_CURSOR_POSITION_REPORT :: 0x32 -HID_USAGE_ALPHANUMERIC_FONT_REPORT :: 0x3B -HID_USAGE_ALPHANUMERIC_FONT_DATA :: 0x3C -HID_USAGE_ALPHANUMERIC_CHARACTER_ATTRIBUTE :: 0x48 -HID_USAGE_ALPHANUMERIC_PALETTE_REPORT :: 0x85 -HID_USAGE_ALPHANUMERIC_PALETTE_DATA :: 0x88 -HID_USAGE_ALPHANUMERIC_BLIT_REPORT :: 0x8A -HID_USAGE_ALPHANUMERIC_BLIT_DATA :: 0x8F -HID_USAGE_ALPHANUMERIC_SOFT_BUTTON :: 0x90 +HID_USAGE_ALPHANUMERIC_DISPLAY_CONTROL_REPORT :: 0x24 +HID_USAGE_ALPHANUMERIC_CHARACTER_REPORT :: 0x2B +HID_USAGE_ALPHANUMERIC_DISPLAY_STATUS :: 0x2D +HID_USAGE_ALPHANUMERIC_CURSOR_POSITION_REPORT :: 0x32 +HID_USAGE_ALPHANUMERIC_FONT_REPORT :: 0x3B +HID_USAGE_ALPHANUMERIC_FONT_DATA :: 0x3C +HID_USAGE_ALPHANUMERIC_CHARACTER_ATTRIBUTE :: 0x48 +HID_USAGE_ALPHANUMERIC_PALETTE_REPORT :: 0x85 +HID_USAGE_ALPHANUMERIC_PALETTE_DATA :: 0x88 +HID_USAGE_ALPHANUMERIC_BLIT_REPORT :: 0x8A +HID_USAGE_ALPHANUMERIC_BLIT_DATA :: 0x8F +HID_USAGE_ALPHANUMERIC_SOFT_BUTTON :: 0x90 -HID_USAGE_ALPHANUMERIC_ASCII_CHARACTER_SET :: 0x21 -HID_USAGE_ALPHANUMERIC_DATA_READ_BACK :: 0x22 -HID_USAGE_ALPHANUMERIC_FONT_READ_BACK :: 0x23 -HID_USAGE_ALPHANUMERIC_CLEAR_DISPLAY :: 0x25 -HID_USAGE_ALPHANUMERIC_DISPLAY_ENABLE :: 0x26 -HID_USAGE_ALPHANUMERIC_SCREEN_SAVER_DELAY :: 0x27 -HID_USAGE_ALPHANUMERIC_SCREEN_SAVER_ENABLE :: 0x28 -HID_USAGE_ALPHANUMERIC_VERTICAL_SCROLL :: 0x29 -HID_USAGE_ALPHANUMERIC_HORIZONTAL_SCROLL :: 0x2A -HID_USAGE_ALPHANUMERIC_DISPLAY_DATA :: 0x2C -HID_USAGE_ALPHANUMERIC_STATUS_NOT_READY :: 0x2E -HID_USAGE_ALPHANUMERIC_STATUS_READY :: 0x2F +HID_USAGE_ALPHANUMERIC_ASCII_CHARACTER_SET :: 0x21 +HID_USAGE_ALPHANUMERIC_DATA_READ_BACK :: 0x22 +HID_USAGE_ALPHANUMERIC_FONT_READ_BACK :: 0x23 +HID_USAGE_ALPHANUMERIC_CLEAR_DISPLAY :: 0x25 +HID_USAGE_ALPHANUMERIC_DISPLAY_ENABLE :: 0x26 +HID_USAGE_ALPHANUMERIC_SCREEN_SAVER_DELAY :: 0x27 +HID_USAGE_ALPHANUMERIC_SCREEN_SAVER_ENABLE :: 0x28 +HID_USAGE_ALPHANUMERIC_VERTICAL_SCROLL :: 0x29 +HID_USAGE_ALPHANUMERIC_HORIZONTAL_SCROLL :: 0x2A +HID_USAGE_ALPHANUMERIC_DISPLAY_DATA :: 0x2C +HID_USAGE_ALPHANUMERIC_STATUS_NOT_READY :: 0x2E +HID_USAGE_ALPHANUMERIC_STATUS_READY :: 0x2F HID_USAGE_ALPHANUMERIC_ERR_NOT_A_LOADABLE_CHARACTER :: 0x30 HID_USAGE_ALPHANUMERIC_ERR_FONT_DATA_CANNOT_BE_READ :: 0x31 -HID_USAGE_ALPHANUMERIC_ROW :: 0x33 -HID_USAGE_ALPHANUMERIC_COLUMN :: 0x34 -HID_USAGE_ALPHANUMERIC_ROWS :: 0x35 -HID_USAGE_ALPHANUMERIC_COLUMNS :: 0x36 -HID_USAGE_ALPHANUMERIC_CURSOR_PIXEL_POSITIONING :: 0x37 -HID_USAGE_ALPHANUMERIC_CURSOR_MODE :: 0x38 -HID_USAGE_ALPHANUMERIC_CURSOR_ENABLE :: 0x39 -HID_USAGE_ALPHANUMERIC_CURSOR_BLINK :: 0x3A -HID_USAGE_ALPHANUMERIC_CHAR_WIDTH :: 0x3D -HID_USAGE_ALPHANUMERIC_CHAR_HEIGHT :: 0x3E -HID_USAGE_ALPHANUMERIC_CHAR_SPACING_HORIZONTAL :: 0x3F -HID_USAGE_ALPHANUMERIC_CHAR_SPACING_VERTICAL :: 0x40 -HID_USAGE_ALPHANUMERIC_UNICODE_CHAR_SET :: 0x41 -HID_USAGE_ALPHANUMERIC_FONT_7_SEGMENT :: 0x42 -HID_USAGE_ALPHANUMERIC_7_SEGMENT_DIRECT_MAP :: 0x43 -HID_USAGE_ALPHANUMERIC_FONT_14_SEGMENT :: 0x44 -HID_USAGE_ALPHANUMERIC_14_SEGMENT_DIRECT_MAP :: 0x45 -HID_USAGE_ALPHANUMERIC_DISPLAY_BRIGHTNESS :: 0x46 -HID_USAGE_ALPHANUMERIC_DISPLAY_CONTRAST :: 0x47 -HID_USAGE_ALPHANUMERIC_ATTRIBUTE_READBACK :: 0x49 -HID_USAGE_ALPHANUMERIC_ATTRIBUTE_DATA :: 0x4A -HID_USAGE_ALPHANUMERIC_CHAR_ATTR_ENHANCE :: 0x4B -HID_USAGE_ALPHANUMERIC_CHAR_ATTR_UNDERLINE :: 0x4C -HID_USAGE_ALPHANUMERIC_CHAR_ATTR_BLINK :: 0x4D -HID_USAGE_ALPHANUMERIC_BITMAP_SIZE_X :: 0x80 -HID_USAGE_ALPHANUMERIC_BITMAP_SIZE_Y :: 0x81 -HID_USAGE_ALPHANUMERIC_BIT_DEPTH_FORMAT :: 0x83 -HID_USAGE_ALPHANUMERIC_DISPLAY_ORIENTATION :: 0x84 -HID_USAGE_ALPHANUMERIC_PALETTE_DATA_SIZE :: 0x86 -HID_USAGE_ALPHANUMERIC_PALETTE_DATA_OFFSET :: 0x87 -HID_USAGE_ALPHANUMERIC_BLIT_RECTANGLE_X1 :: 0x8B -HID_USAGE_ALPHANUMERIC_BLIT_RECTANGLE_Y1 :: 0x8C -HID_USAGE_ALPHANUMERIC_BLIT_RECTANGLE_X2 :: 0x8D -HID_USAGE_ALPHANUMERIC_BLIT_RECTANGLE_Y2 :: 0x8E -HID_USAGE_ALPHANUMERIC_SOFT_BUTTON_ID :: 0x91 -HID_USAGE_ALPHANUMERIC_SOFT_BUTTON_SIDE :: 0x92 -HID_USAGE_ALPHANUMERIC_SOFT_BUTTON_OFFSET1 :: 0x93 -HID_USAGE_ALPHANUMERIC_SOFT_BUTTON_OFFSET2 :: 0x94 -HID_USAGE_ALPHANUMERIC_SOFT_BUTTON_REPORT :: 0x95 +HID_USAGE_ALPHANUMERIC_ROW :: 0x33 +HID_USAGE_ALPHANUMERIC_COLUMN :: 0x34 +HID_USAGE_ALPHANUMERIC_ROWS :: 0x35 +HID_USAGE_ALPHANUMERIC_COLUMNS :: 0x36 +HID_USAGE_ALPHANUMERIC_CURSOR_PIXEL_POSITIONING :: 0x37 +HID_USAGE_ALPHANUMERIC_CURSOR_MODE :: 0x38 +HID_USAGE_ALPHANUMERIC_CURSOR_ENABLE :: 0x39 +HID_USAGE_ALPHANUMERIC_CURSOR_BLINK :: 0x3A +HID_USAGE_ALPHANUMERIC_CHAR_WIDTH :: 0x3D +HID_USAGE_ALPHANUMERIC_CHAR_HEIGHT :: 0x3E +HID_USAGE_ALPHANUMERIC_CHAR_SPACING_HORIZONTAL :: 0x3F +HID_USAGE_ALPHANUMERIC_CHAR_SPACING_VERTICAL :: 0x40 +HID_USAGE_ALPHANUMERIC_UNICODE_CHAR_SET :: 0x41 +HID_USAGE_ALPHANUMERIC_FONT_7_SEGMENT :: 0x42 +HID_USAGE_ALPHANUMERIC_7_SEGMENT_DIRECT_MAP :: 0x43 +HID_USAGE_ALPHANUMERIC_FONT_14_SEGMENT :: 0x44 +HID_USAGE_ALPHANUMERIC_14_SEGMENT_DIRECT_MAP :: 0x45 +HID_USAGE_ALPHANUMERIC_DISPLAY_BRIGHTNESS :: 0x46 +HID_USAGE_ALPHANUMERIC_DISPLAY_CONTRAST :: 0x47 +HID_USAGE_ALPHANUMERIC_ATTRIBUTE_READBACK :: 0x49 +HID_USAGE_ALPHANUMERIC_ATTRIBUTE_DATA :: 0x4A +HID_USAGE_ALPHANUMERIC_CHAR_ATTR_ENHANCE :: 0x4B +HID_USAGE_ALPHANUMERIC_CHAR_ATTR_UNDERLINE :: 0x4C +HID_USAGE_ALPHANUMERIC_CHAR_ATTR_BLINK :: 0x4D +HID_USAGE_ALPHANUMERIC_BITMAP_SIZE_X :: 0x80 +HID_USAGE_ALPHANUMERIC_BITMAP_SIZE_Y :: 0x81 +HID_USAGE_ALPHANUMERIC_BIT_DEPTH_FORMAT :: 0x83 +HID_USAGE_ALPHANUMERIC_DISPLAY_ORIENTATION :: 0x84 +HID_USAGE_ALPHANUMERIC_PALETTE_DATA_SIZE :: 0x86 +HID_USAGE_ALPHANUMERIC_PALETTE_DATA_OFFSET :: 0x87 +HID_USAGE_ALPHANUMERIC_BLIT_RECTANGLE_X1 :: 0x8B +HID_USAGE_ALPHANUMERIC_BLIT_RECTANGLE_Y1 :: 0x8C +HID_USAGE_ALPHANUMERIC_BLIT_RECTANGLE_X2 :: 0x8D +HID_USAGE_ALPHANUMERIC_BLIT_RECTANGLE_Y2 :: 0x8E +HID_USAGE_ALPHANUMERIC_SOFT_BUTTON_ID :: 0x91 +HID_USAGE_ALPHANUMERIC_SOFT_BUTTON_SIDE :: 0x92 +HID_USAGE_ALPHANUMERIC_SOFT_BUTTON_OFFSET1 :: 0x93 +HID_USAGE_ALPHANUMERIC_SOFT_BUTTON_OFFSET2 :: 0x94 +HID_USAGE_ALPHANUMERIC_SOFT_BUTTON_REPORT :: 0x95 -HID_USAGE_LAMPARRAY :: 0x01 -HID_USAGE_LAMPARRAY_ATTRBIUTES_REPORT :: 0x02 -HID_USAGE_LAMPARRAY_LAMP_COUNT :: 0x03 -HID_USAGE_LAMPARRAY_BOUNDING_BOX_WIDTH_IN_MICROMETERS :: 0x04 -HID_USAGE_LAMPARRAY_BOUNDING_BOX_HEIGHT_IN_MICROMETERS :: 0x05 -HID_USAGE_LAMPARRAY_BOUNDING_BOX_DEPTH_IN_MICROMETERS :: 0x06 -HID_USAGE_LAMPARRAY_KIND :: 0x07 +HID_USAGE_LAMPARRAY :: 0x01 +HID_USAGE_LAMPARRAY_ATTRBIUTES_REPORT :: 0x02 +HID_USAGE_LAMPARRAY_LAMP_COUNT :: 0x03 +HID_USAGE_LAMPARRAY_BOUNDING_BOX_WIDTH_IN_MICROMETERS :: 0x04 +HID_USAGE_LAMPARRAY_BOUNDING_BOX_HEIGHT_IN_MICROMETERS :: 0x05 +HID_USAGE_LAMPARRAY_BOUNDING_BOX_DEPTH_IN_MICROMETERS :: 0x06 +HID_USAGE_LAMPARRAY_KIND :: 0x07 HID_USAGE_LAMPARRAY_MIN_UPDATE_INTERVAL_IN_MICROSECONDS :: 0x08 // 0x09 - 0x1F Reserved -HID_USAGE_LAMPARRAY_LAMP_ATTRIBUTES_REQUEST_REPORT :: 0x20 -HID_USAGE_LAMPARRAY_LAMP_ID :: 0x21 +HID_USAGE_LAMPARRAY_LAMP_ATTRIBUTES_REQUEST_REPORT :: 0x20 +HID_USAGE_LAMPARRAY_LAMP_ID :: 0x21 HID_USAGE_LAMPARRAY_LAMP_ATTRIBUTES_RESPONSE_REPORT :: 0x22 -HID_USAGE_LAMPARRAY_POSITION_X_IN_MICROMETERS :: 0x23 -HID_USAGE_LAMPARRAY_POSITION_Y_IN_MICROMETERS :: 0x24 -HID_USAGE_LAMPARRAY_POSITION_Z_IN_MICROMETERS :: 0x25 -HID_USAGE_LAMPARRAY_LAMP_PURPOSES :: 0x26 -HID_USAGE_LAMPARRAY_UPDATE_LATENCY_IN_MICROSECONDS :: 0x27 -HID_USAGE_LAMPARRAY_RED_LEVEL_COUNT :: 0x28 -HID_USAGE_LAMPARRAY_GREEN_LEVEL_COUNT :: 0x29 -HID_USAGE_LAMPARRAY_BLUE_LEVEL_COUNT :: 0x2A -HID_USAGE_LAMPARRAY_INTENSITY_LEVEL_COUNT :: 0x2B -HID_USAGE_LAMPARRAY_IS_PROGRAMMABLE :: 0x2C -HID_USAGE_LAMPARRAY_INPUT_BINDING :: 0x2D +HID_USAGE_LAMPARRAY_POSITION_X_IN_MICROMETERS :: 0x23 +HID_USAGE_LAMPARRAY_POSITION_Y_IN_MICROMETERS :: 0x24 +HID_USAGE_LAMPARRAY_POSITION_Z_IN_MICROMETERS :: 0x25 +HID_USAGE_LAMPARRAY_LAMP_PURPOSES :: 0x26 +HID_USAGE_LAMPARRAY_UPDATE_LATENCY_IN_MICROSECONDS :: 0x27 +HID_USAGE_LAMPARRAY_RED_LEVEL_COUNT :: 0x28 +HID_USAGE_LAMPARRAY_GREEN_LEVEL_COUNT :: 0x29 +HID_USAGE_LAMPARRAY_BLUE_LEVEL_COUNT :: 0x2A +HID_USAGE_LAMPARRAY_INTENSITY_LEVEL_COUNT :: 0x2B +HID_USAGE_LAMPARRAY_IS_PROGRAMMABLE :: 0x2C +HID_USAGE_LAMPARRAY_INPUT_BINDING :: 0x2D // 0x2E - 0x4F Reserved -HID_USAGE_LAMPARRAY_LAMP_MULTI_UPDATE_REPORT :: 0x50 -HID_USAGE_LAMPARRAY_LAMP_RED_UPDATE_CHANNEL :: 0x51 -HID_USAGE_LAMPARRAY_LAMP_GREEN_UPDATE_CHANNEL :: 0x52 -HID_USAGE_LAMPARRAY_LAMP_BLUE_UPDATE_CHANNEL :: 0x53 +HID_USAGE_LAMPARRAY_LAMP_MULTI_UPDATE_REPORT :: 0x50 +HID_USAGE_LAMPARRAY_LAMP_RED_UPDATE_CHANNEL :: 0x51 +HID_USAGE_LAMPARRAY_LAMP_GREEN_UPDATE_CHANNEL :: 0x52 +HID_USAGE_LAMPARRAY_LAMP_BLUE_UPDATE_CHANNEL :: 0x53 HID_USAGE_LAMPARRAY_LAMP_INTENSITY_UPDATE_CHANNEL :: 0x54 -HID_USAGE_LAMPARRAY_LAMP_UPDATE_FLAGS :: 0x55 +HID_USAGE_LAMPARRAY_LAMP_UPDATE_FLAGS :: 0x55 // 0x55 - 0x5F Reserved HID_USAGE_LAMPARRAY_LAMP_RANGE_UPDATE_REPORT :: 0x60 -HID_USAGE_LAMPARRAY_LAMP_ID_START :: 0x61 -HID_USAGE_LAMPARRAY_LAMP_ID_END :: 0x62 +HID_USAGE_LAMPARRAY_LAMP_ID_START :: 0x61 +HID_USAGE_LAMPARRAY_LAMP_ID_END :: 0x62 // 0x63 - 0x6F Reserved -HID_USAGE_LAMPARRAY_CONTROL_REPORT :: 0x70 +HID_USAGE_LAMPARRAY_CONTROL_REPORT :: 0x70 HID_USAGE_LAMPARRAY_AUTONOMOUS_MODE :: 0x71 HID_USAGE_CAMERA_AUTO_FOCUS :: 0x20 -HID_USAGE_CAMERA_SHUTTER :: 0x21 +HID_USAGE_CAMERA_SHUTTER :: 0x21 HID_USAGE_MS_BTH_HF_DIALNUMBER :: 0x21 HID_USAGE_MS_BTH_HF_DIALMEMORY :: 0x22 diff --git a/core/sys/windows/icu.odin b/core/sys/windows/icu.odin index 6ed8c9b40..7be9ce4c6 100644 --- a/core/sys/windows/icu.odin +++ b/core/sys/windows/icu.odin @@ -10,5 +10,8 @@ UError :: enum i32 { @(default_calling_convention="system") foreign icu { ucal_getWindowsTimeZoneID :: proc(id: wstring, len: i32, winid: wstring, winidCapacity: i32, status: ^UError) -> i32 --- - ucal_getDefaultTimeZone :: proc(result: wstring, cap: i32, status: ^UError) -> i32 --- + ucal_getDefaultTimeZone :: proc(result: wstring, cap: i32, status: ^UError) -> i32 --- } + + +// NOTE(bill): all of these types actually do use `i32` and not `c_int` diff --git a/core/sys/windows/ip_helper.odin b/core/sys/windows/ip_helper.odin index d2e75d531..74ffa95b9 100644 --- a/core/sys/windows/ip_helper.odin +++ b/core/sys/windows/ip_helper.odin @@ -141,7 +141,7 @@ IP_ADAPTER_DNS_SERVER_ADDRESS_XP :: struct { Address: SOCKET_ADDRESS, } -IF_OPER_STATUS :: enum i32 { +IF_OPER_STATUS :: enum c_int { Up = 1, Down = 2, Testing = 3, @@ -160,17 +160,17 @@ NET_LUID_LH :: struct #raw_union { SOCKET_ADDRESS :: struct { lpSockaddr: ^SOCKADDR, - iSockaddrLength: i32, + iSockaddrLength: INT, } -NET_IF_CONNECTION_TYPE :: enum i32 { +NET_IF_CONNECTION_TYPE :: enum c_int { NET_IF_CONNECTION_DEDICATED = 1, NET_IF_CONNECTION_PASSIVE = 2, NET_IF_CONNECTION_DEMAND = 3, NET_IF_CONNECTION_MAXIMUM = 4, } -TUNNEL_TYPE :: enum i32 { +TUNNEL_TYPE :: enum c_int { TUNNEL_TYPE_NONE = 0, TUNNEL_TYPE_OTHER = 1, TUNNEL_TYPE_DIRECT = 2, @@ -179,7 +179,7 @@ TUNNEL_TYPE :: enum i32 { TUNNEL_TYPE_TEREDO = 14, TUNNEL_TYPE_IPHTTPS = 15, } -NL_PREFIX_ORIGIN :: enum i32 { +NL_PREFIX_ORIGIN :: enum c_int { IpPrefixOriginOther = 0, IpPrefixOriginManual = 1, IpPrefixOriginWellKnown = 2, @@ -188,7 +188,7 @@ NL_PREFIX_ORIGIN :: enum i32 { IpPrefixOriginUnchanged = 16, } -NL_SUFFIX_ORIGIN :: enum i32 { +NL_SUFFIX_ORIGIN :: enum c_int { NlsoOther = 0, NlsoManual = 1, NlsoWellKnown = 2, @@ -204,7 +204,7 @@ NL_SUFFIX_ORIGIN :: enum i32 { IpSuffixOriginUnchanged = 16, } -NL_DAD_STATE :: enum i32 { +NL_DAD_STATE :: enum c_int { NldsInvalid = 0, NldsTentative = 1, NldsDuplicate = 2, @@ -223,7 +223,7 @@ foreign iphlpapi { The GetAdaptersAddresses function retrieves the addresses associated with the adapters on the local computer. See: https://docs.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses */ - @(link_name="GetAdaptersAddresses") get_adapters_addresses :: proc( + GetAdaptersAddresses :: proc( family: Address_Family, flags: GAA_Flags, _reserved: rawptr, @@ -232,3 +232,5 @@ foreign iphlpapi { ) -> ULONG --- } + +get_adapters_addresses :: GetAdaptersAddresses \ No newline at end of file diff --git a/core/sys/windows/kernel32.odin b/core/sys/windows/kernel32.odin index e5163bac7..0309ff16f 100644 --- a/core/sys/windows/kernel32.odin +++ b/core/sys/windows/kernel32.odin @@ -30,6 +30,18 @@ EV_RXCHAR :: DWORD(0x0001) EV_RXFLAG :: DWORD(0x0002) EV_TXEMPTY :: DWORD(0x0004) +WAITORTIMERCALLBACK :: #type proc "system" (lpParameter: PVOID, TimerOrWaitFired: BOOLEAN) + +PAPCFUNC :: #type proc "system" (Parameter: ULONG_PTR) + +WT_EXECUTEDEFAULT :: 0x00000000 +WT_EXECUTEINIOTHREAD :: 0x00000001 +WT_EXECUTEINPERSISTENTTHREAD :: 0x00000080 +WT_EXECUTEINWAITTHREAD :: 0x00000004 +WT_EXECUTELONGFUNCTION :: 0x00000010 +WT_EXECUTEONLYONCE :: 0x00000008 +WT_TRANSFER_IMPERSONATION :: 0x00000100 + @(default_calling_convention="system") foreign kernel32 { OutputDebugStringA :: proc(lpOutputString: LPCSTR) --- // The only A thing that is allowed @@ -60,15 +72,15 @@ foreign kernel32 { // https://learn.microsoft.com/en-us/windows/console/getnumberofconsoleinputevents GetNumberOfConsoleInputEvents :: proc(hConsoleInput: HANDLE, lpcNumberOfEvents: LPDWORD) -> BOOL --- - GetConsoleMode :: proc(hConsoleHandle: HANDLE, lpMode: LPDWORD) -> BOOL --- - SetConsoleMode :: proc(hConsoleHandle: HANDLE, dwMode: DWORD) -> BOOL --- + GetConsoleMode :: proc(hConsoleHandle: HANDLE, lpMode: LPDWORD) -> BOOL --- + SetConsoleMode :: proc(hConsoleHandle: HANDLE, dwMode: DWORD) -> BOOL --- SetConsoleCursorPosition :: proc(hConsoleHandle: HANDLE, dwCursorPosition: COORD) -> BOOL --- - SetConsoleTextAttribute :: proc(hConsoleOutput: HANDLE, wAttributes: WORD) -> BOOL --- - GetConsoleCP :: proc() -> CODEPAGE --- - SetConsoleCP :: proc(wCodePageID: CODEPAGE) -> BOOL --- - GetConsoleOutputCP :: proc() -> CODEPAGE --- - SetConsoleOutputCP :: proc(wCodePageID: CODEPAGE) -> BOOL --- - FlushConsoleInputBuffer :: proc(hConsoleInput: HANDLE) -> BOOL --- + SetConsoleTextAttribute :: proc(hConsoleOutput: HANDLE, wAttributes: WORD) -> BOOL --- + GetConsoleCP :: proc() -> CODEPAGE --- + SetConsoleCP :: proc(wCodePageID: CODEPAGE) -> BOOL --- + GetConsoleOutputCP :: proc() -> CODEPAGE --- + SetConsoleOutputCP :: proc(wCodePageID: CODEPAGE) -> BOOL --- + FlushConsoleInputBuffer :: proc(hConsoleInput: HANDLE) -> BOOL --- GetFileInformationByHandle :: proc(hFile: HANDLE, lpFileInformation: LPBY_HANDLE_FILE_INFORMATION) -> BOOL --- @@ -82,11 +94,11 @@ foreign kernel32 { dwBufferSize: DWORD) -> BOOL --- - AddVectoredExceptionHandler :: proc(FirstHandler: ULONG, VectoredHandler: PVECTORED_EXCEPTION_HANDLER) -> LPVOID --- - AddVectoredContinueHandler :: proc(FirstHandler: ULONG, VectoredHandler: PVECTORED_EXCEPTION_HANDLER) -> LPVOID --- + AddVectoredExceptionHandler :: proc(FirstHandler: ULONG, VectoredHandler: PVECTORED_EXCEPTION_HANDLER) -> LPVOID --- + AddVectoredContinueHandler :: proc(FirstHandler: ULONG, VectoredHandler: PVECTORED_EXCEPTION_HANDLER) -> LPVOID --- RemoveVectoredExceptionHandler :: proc(Handle: LPVOID) -> DWORD --- - RemoveVectoredContinueHandler :: proc(Handle: LPVOID) -> DWORD --- - RaiseException :: proc(dwExceptionCode, dwExceptionFlags, nNumberOfArguments: DWORD, lpArguments: ^ULONG_PTR) -> ! --- + RemoveVectoredContinueHandler :: proc(Handle: LPVOID) -> DWORD --- + RaiseException :: proc(dwExceptionCode, dwExceptionFlags, nNumberOfArguments: DWORD, lpArguments: ^ULONG_PTR) -> ! --- SetUnhandledExceptionFilter :: proc(lpTopLevelExceptionFilter: LPTOP_LEVEL_EXCEPTION_FILTER) -> LPTOP_LEVEL_EXCEPTION_FILTER --- @@ -103,31 +115,31 @@ foreign kernel32 { lpFileInformation: LPVOID, dwBufferSize: DWORD) -> BOOL --- - InitializeCriticalSection :: proc(CriticalSection: ^CRITICAL_SECTION) --- + InitializeCriticalSection :: proc(CriticalSection: ^CRITICAL_SECTION) --- InitializeCriticalSectionAndSpinCount :: proc(CriticalSection: ^CRITICAL_SECTION, dwSpinCount: DWORD) -> BOOL --- - EnterCriticalSection :: proc(CriticalSection: ^CRITICAL_SECTION) --- - TryEnterCriticalSection :: proc(CriticalSection: ^CRITICAL_SECTION) -> BOOLEAN --- - LeaveCriticalSection :: proc(CriticalSection: ^CRITICAL_SECTION) --- - DeleteCriticalSection :: proc(CriticalSection: ^CRITICAL_SECTION) --- + EnterCriticalSection :: proc(CriticalSection: ^CRITICAL_SECTION) --- + TryEnterCriticalSection :: proc(CriticalSection: ^CRITICAL_SECTION) -> BOOLEAN --- + LeaveCriticalSection :: proc(CriticalSection: ^CRITICAL_SECTION) --- + DeleteCriticalSection :: proc(CriticalSection: ^CRITICAL_SECTION) --- - RemoveDirectoryW :: proc(lpPathName: LPCWSTR) -> BOOL --- - SetFileAttributesW :: proc(lpFileName: LPCWSTR, dwFileAttributes: DWORD) -> BOOL --- - SetLastError :: proc(dwErrCode: DWORD) --- - GetCommTimeouts :: proc(handle: HANDLE, timeouts: ^COMMTIMEOUTS) -> BOOL --- - SetCommTimeouts :: proc(handle: HANDLE, timeouts: ^COMMTIMEOUTS) -> BOOL --- - ClearCommError :: proc(hFile: HANDLE, lpErrors: ^Com_Error, lpStat: ^COMSTAT) -> BOOL --- - GetCommState :: proc(handle: HANDLE, dcb: ^DCB) -> BOOL --- - SetCommState :: proc(handle: HANDLE, dcb: ^DCB) -> BOOL --- - SetCommMask :: proc(handle: HANDLE, dwEvtMap: DWORD) -> BOOL --- - GetCommMask :: proc(handle: HANDLE, lpEvtMask: LPDWORD) -> BOOL --- - WaitCommEvent :: proc(handle: HANDLE, lpEvtMask: LPDWORD, lpOverlapped: LPOVERLAPPED) -> BOOL --- - GetCommandLineW :: proc() -> LPCWSTR --- - GetTempPathW :: proc(nBufferLength: DWORD, lpBuffer: LPCWSTR) -> DWORD --- - GetTempFileNameW :: proc(lpPathName: LPCWSTR, lpPrefixString: LPCWSTR, uUnique: c_int, lpTempFileName: LPWSTR) -> c_uint --- - GetCurrentProcess :: proc() -> HANDLE --- + RemoveDirectoryW :: proc(lpPathName: LPCWSTR) -> BOOL --- + SetFileAttributesW :: proc(lpFileName: LPCWSTR, dwFileAttributes: DWORD) -> BOOL --- + SetLastError :: proc(dwErrCode: DWORD) --- + GetCommTimeouts :: proc(handle: HANDLE, timeouts: ^COMMTIMEOUTS) -> BOOL --- + SetCommTimeouts :: proc(handle: HANDLE, timeouts: ^COMMTIMEOUTS) -> BOOL --- + ClearCommError :: proc(hFile: HANDLE, lpErrors: ^Com_Error, lpStat: ^COMSTAT) -> BOOL --- + GetCommState :: proc(handle: HANDLE, dcb: ^DCB) -> BOOL --- + SetCommState :: proc(handle: HANDLE, dcb: ^DCB) -> BOOL --- + SetCommMask :: proc(handle: HANDLE, dwEvtMap: DWORD) -> BOOL --- + GetCommMask :: proc(handle: HANDLE, lpEvtMask: LPDWORD) -> BOOL --- + WaitCommEvent :: proc(handle: HANDLE, lpEvtMask: LPDWORD, lpOverlapped: LPOVERLAPPED) -> BOOL --- + GetCommandLineW :: proc() -> LPCWSTR --- + GetTempPathW :: proc(nBufferLength: DWORD, lpBuffer: LPCWSTR) -> DWORD --- + GetTempFileNameW :: proc(lpPathName: LPCWSTR, lpPrefixString: LPCWSTR, uUnique: c_int, lpTempFileName: LPWSTR) -> c_uint --- + GetCurrentProcess :: proc() -> HANDLE --- GetCurrentProcessId :: proc() -> DWORD --- - GetCurrentThread :: proc() -> HANDLE --- - GetCurrentThreadId :: proc() -> DWORD --- + GetCurrentThread :: proc() -> HANDLE --- + GetCurrentThreadId :: proc() -> DWORD --- GetProcessTimes :: proc( hProcess: HANDLE, lpCreationTime: LPFILETIME, @@ -136,7 +148,7 @@ foreign kernel32 { lpUserTime: LPFILETIME, ) -> BOOL --- GetStdHandle :: proc(which: DWORD) -> HANDLE --- - ExitProcess :: proc(uExitCode: c_uint) -> ! --- + ExitProcess :: proc(uExitCode: c_uint) -> ! --- DeviceIoControl :: proc( hDevice: HANDLE, dwIoControlCode: DWORD, @@ -164,15 +176,15 @@ foreign kernel32 { dwCreationFlags: DWORD, lpThreadId: LPDWORD, ) -> HANDLE --- - SwitchToThread :: proc() -> BOOL --- - ResumeThread :: proc(thread: HANDLE) -> DWORD --- - GetThreadPriority :: proc(thread: HANDLE) -> c_int --- - SetThreadPriority :: proc(thread: HANDLE, priority: c_int) -> BOOL --- + SwitchToThread :: proc() -> BOOL --- + ResumeThread :: proc(thread: HANDLE) -> DWORD --- + GetThreadPriority :: proc(thread: HANDLE) -> c_int --- + SetThreadPriority :: proc(thread: HANDLE, priority: c_int) -> BOOL --- GetThreadDescription :: proc(hThread: HANDLE, ppszThreadDescription: ^PCWSTR) -> HRESULT --- SetThreadDescription :: proc(hThread: HANDLE, lpThreadDescription: PCWSTR) -> HRESULT --- - GetExitCodeThread :: proc(thread: HANDLE, exit_code: ^DWORD) -> BOOL --- - TerminateThread :: proc(thread: HANDLE, exit_code: DWORD) -> BOOL --- - SuspendThread :: proc(hThread: HANDLE) -> DWORD --- + GetExitCodeThread :: proc(thread: HANDLE, exit_code: ^DWORD) -> BOOL --- + TerminateThread :: proc(thread: HANDLE, exit_code: DWORD) -> BOOL --- + SuspendThread :: proc(hThread: HANDLE) -> DWORD --- GetProcessAffinityMask :: proc( hProcess: HANDLE, @@ -237,17 +249,17 @@ foreign kernel32 { nsize: DWORD, args: rawptr, ) -> DWORD --- - TlsAlloc :: proc() -> DWORD --- - TlsFree :: proc(dwTlsIndex: DWORD) -> BOOL --- - TlsGetValue :: proc(dwTlsIndex: DWORD) -> LPVOID --- - TlsSetValue :: proc(dwTlsIndex: DWORD, lpTlsvalue: LPVOID) -> BOOL --- - GetLastError :: proc() -> DWORD --- + TlsAlloc :: proc() -> DWORD --- + TlsFree :: proc(dwTlsIndex: DWORD) -> BOOL --- + TlsGetValue :: proc(dwTlsIndex: DWORD) -> LPVOID --- + TlsSetValue :: proc(dwTlsIndex: DWORD, lpTlsvalue: LPVOID) -> BOOL --- + GetLastError :: proc() -> DWORD --- QueryPerformanceFrequency :: proc(lpFrequency: ^LARGE_INTEGER) -> BOOL --- - QueryPerformanceCounter :: proc(lpPerformanceCount: ^LARGE_INTEGER) -> BOOL --- - GetExitCodeProcess :: proc(hProcess: HANDLE, lpExitCode: LPDWORD) -> BOOL --- - TerminateProcess :: proc(hProcess: HANDLE, uExitCode: UINT) -> BOOL --- - OpenProcess :: proc(dwDesiredAccess: DWORD, bInheritHandle: BOOL, dwProcessId: DWORD) -> HANDLE --- - OpenThread :: proc(dwDesiredAccess: DWORD, bInheritHandle: BOOL, dwThreadId: DWORD) -> HANDLE --- + QueryPerformanceCounter :: proc(lpPerformanceCount: ^LARGE_INTEGER) -> BOOL --- + GetExitCodeProcess :: proc(hProcess: HANDLE, lpExitCode: LPDWORD) -> BOOL --- + TerminateProcess :: proc(hProcess: HANDLE, uExitCode: UINT) -> BOOL --- + OpenProcess :: proc(dwDesiredAccess: DWORD, bInheritHandle: BOOL, dwProcessId: DWORD) -> HANDLE --- + OpenThread :: proc(dwDesiredAccess: DWORD, bInheritHandle: BOOL, dwThreadId: DWORD) -> HANDLE --- GetThreadContext :: proc( hThread: HANDLE, lpContext: LPCONTEXT, @@ -366,14 +378,14 @@ foreign kernel32 { ) -> BOOL --- CompareFileTime :: proc(lpFileTime1: LPFILETIME, lpFileTime2: LPFILETIME) -> LONG --- - FindFirstFileW :: proc(fileName: LPCWSTR, findFileData: LPWIN32_FIND_DATAW) -> HANDLE --- - FindNextFileW :: proc(findFile: HANDLE, findFileData: LPWIN32_FIND_DATAW) -> BOOL --- - FindClose :: proc(findFile: HANDLE) -> BOOL --- - GetModuleHandleW :: proc(lpModuleName: LPCWSTR) -> HMODULE --- - GetModuleHandleA :: proc(lpModuleName: LPCSTR) -> HMODULE --- - GetSystemTimeAsFileTime :: proc(lpSystemTimeAsFileTime: LPFILETIME) --- - GetSystemTimePreciseAsFileTime :: proc(lpSystemTimeAsFileTime: LPFILETIME) --- - FileTimeToSystemTime :: proc(lpFileTime: ^FILETIME, lpSystemTime: ^SYSTEMTIME) -> BOOL --- + FindFirstFileW :: proc(fileName: LPCWSTR, findFileData: LPWIN32_FIND_DATAW) -> HANDLE --- + FindNextFileW :: proc(findFile: HANDLE, findFileData: LPWIN32_FIND_DATAW) -> BOOL --- + FindClose :: proc(findFile: HANDLE) -> BOOL --- + GetModuleHandleW :: proc(lpModuleName: LPCWSTR) -> HMODULE --- + GetModuleHandleA :: proc(lpModuleName: LPCSTR) -> HMODULE --- + GetSystemTimeAsFileTime :: proc(lpSystemTimeAsFileTime: LPFILETIME) --- + GetSystemTimePreciseAsFileTime :: proc(lpSystemTimeAsFileTime: LPFILETIME) --- + FileTimeToSystemTime :: proc(lpFileTime: ^FILETIME, lpSystemTime: ^SYSTEMTIME) -> BOOL --- SystemTimeToTzSpecificLocalTime :: proc( lpTimeZoneInformation: ^TIME_ZONE_INFORMATION, lpUniversalTime: ^SYSTEMTIME, @@ -428,7 +440,7 @@ foreign kernel32 { lpTotalBytesAvail: ^u32, lpBytesLeftThisMessage: ^u32, ) -> BOOL --- - CancelIo :: proc(handle: HANDLE) -> BOOL --- + CancelIo :: proc(handle: HANDLE) -> BOOL --- CancelIoEx :: proc(hFile: HANDLE, lpOverlapped: LPOVERLAPPED) -> BOOL --- GetOverlappedResult :: proc( hFile: HANDLE, @@ -437,19 +449,19 @@ foreign kernel32 { bWait: BOOL, ) -> BOOL --- GetProcessHeap :: proc() -> HANDLE --- - HeapAlloc :: proc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID --- - HeapReAlloc :: proc(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID, dwBytes: SIZE_T) -> LPVOID --- - HeapFree :: proc(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL --- + HeapAlloc :: proc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID --- + HeapReAlloc :: proc(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID, dwBytes: SIZE_T) -> LPVOID --- + HeapFree :: proc(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL --- - LocalAlloc :: proc(flags: UINT, bytes: SIZE_T) -> LPVOID --- + LocalAlloc :: proc(flags: UINT, bytes: SIZE_T) -> LPVOID --- LocalReAlloc :: proc(mem: LPVOID, bytes: SIZE_T, flags: UINT) -> LPVOID --- - LocalFree :: proc(mem: LPVOID) -> LPVOID --- + LocalFree :: proc(mem: LPVOID) -> LPVOID --- - GlobalAlloc :: proc(flags: UINT, bytes: SIZE_T) -> LPVOID --- + GlobalAlloc :: proc(flags: UINT, bytes: SIZE_T) -> LPVOID --- GlobalReAlloc :: proc(mem: LPVOID, bytes: SIZE_T, flags: UINT) -> LPVOID --- - GlobalFree :: proc(mem: LPVOID) -> LPVOID --- + GlobalFree :: proc(mem: LPVOID) -> LPVOID --- - GlobalLock :: proc(hMem: HGLOBAL) -> LPVOID --- + GlobalLock :: proc(hMem: HGLOBAL) -> LPVOID --- GlobalUnlock :: proc(hMem: HGLOBAL) -> BOOL --- ReadDirectoryChangesW :: proc( @@ -462,21 +474,32 @@ foreign kernel32 { lpOverlapped: LPOVERLAPPED, lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE, ) -> BOOL --- + ReadDirectoryChangesExW :: proc( + hDirectory: HANDLE, + lpBuffer: LPVOID, + nBufferLength: DWORD, + bWatchSubtree: BOOL, + dwNotifyFilter: DWORD, + lpBytesReturned: LPDWORD, + lpOverlapped: LPOVERLAPPED, + lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE, + ReadDirectoryNotifyInformationClass: READ_DIRECTORY_NOTIFY_INFORMATION_CLASS, + ) -> BOOL --- FindFirstChangeNotificationW :: proc( lpPathName: LPWSTR, bWatchSubtree: BOOL, dwNotifyFilter: DWORD, ) -> HANDLE --- - FindNextChangeNotification :: proc(hChangeHandle: HANDLE) -> BOOL --- + FindNextChangeNotification :: proc(hChangeHandle: HANDLE) -> BOOL --- FindCloseChangeNotification :: proc(hChangeHandle: HANDLE) -> BOOL --- InitializeSRWLock :: proc(SRWLock: ^SRWLOCK) --- AcquireSRWLockExclusive :: proc(SRWLock: ^SRWLOCK) --- TryAcquireSRWLockExclusive :: proc(SRWLock: ^SRWLOCK) -> BOOLEAN --- ReleaseSRWLockExclusive :: proc(SRWLock: ^SRWLOCK) --- - AcquireSRWLockShared :: proc(SRWLock: ^SRWLOCK) --- - TryAcquireSRWLockShared :: proc(SRWLock: ^SRWLOCK) -> BOOLEAN --- - ReleaseSRWLockShared :: proc(SRWLock: ^SRWLOCK) --- + AcquireSRWLockShared :: proc(SRWLock: ^SRWLOCK) --- + TryAcquireSRWLockShared :: proc(SRWLock: ^SRWLOCK) -> BOOLEAN --- + ReleaseSRWLockShared :: proc(SRWLock: ^SRWLOCK) --- InitializeConditionVariable :: proc(ConditionVariable: ^CONDITION_VARIABLE) --- WakeConditionVariable :: proc(ConditionVariable: ^CONDITION_VARIABLE) --- @@ -485,42 +508,42 @@ foreign kernel32 { SleepConditionVariableSRW :: proc(ConditionVariable: ^CONDITION_VARIABLE, SRWLock: ^SRWLOCK, dwMilliseconds: DWORD, Flags: LONG) -> BOOL --- - GetFileType :: proc(file_handle: HANDLE) -> DWORD --- - SetFilePointer :: proc(file_handle: HANDLE, distance_to_move: LONG, distance_to_move_high: ^LONG, move_method: DWORD) -> DWORD --- - GetFileSizeEx :: proc(file_handle: HANDLE, file_size: ^LARGE_INTEGER) -> BOOL --- - GetFileAttributesW :: proc(lpFileName: LPCWSTR) -> DWORD --- - GetFileAttributesExW :: proc(lpFileName: LPCWSTR, fInfoLevelId: GET_FILEEX_INFO_LEVELS, lpFileInformation: LPVOID) -> BOOL --- - GetSystemInfo :: proc(system_info: ^SYSTEM_INFO) --- - GetVersionExW :: proc(osvi: ^OSVERSIONINFOEXW) --- - GetSystemDirectoryW :: proc(lpBuffer: LPWSTR, uSize: UINT) -> UINT --- - GetWindowsDirectoryW :: proc(lpBuffer: LPWSTR, uSize: UINT) -> UINT --- - GetSystemDefaultLangID :: proc() -> LANGID --- - GetSystemDefaultLCID :: proc() -> LCID --- + GetFileType :: proc(file_handle: HANDLE) -> DWORD --- + SetFilePointer :: proc(file_handle: HANDLE, distance_to_move: LONG, distance_to_move_high: ^LONG, move_method: DWORD) -> DWORD --- + GetFileSizeEx :: proc(file_handle: HANDLE, file_size: ^LARGE_INTEGER) -> BOOL --- + GetFileAttributesW :: proc(lpFileName: LPCWSTR) -> DWORD --- + GetFileAttributesExW :: proc(lpFileName: LPCWSTR, fInfoLevelId: GET_FILEEX_INFO_LEVELS, lpFileInformation: LPVOID) -> BOOL --- + GetSystemInfo :: proc(system_info: ^SYSTEM_INFO) --- + GetVersionExW :: proc(osvi: ^OSVERSIONINFOEXW) --- + GetSystemDirectoryW :: proc(lpBuffer: LPWSTR, uSize: UINT) -> UINT --- + GetWindowsDirectoryW :: proc(lpBuffer: LPWSTR, uSize: UINT) -> UINT --- + GetSystemDefaultLangID :: proc() -> LANGID --- + GetSystemDefaultLCID :: proc() -> LCID --- GetSystemDefaultLocaleName :: proc(lpLocaleName: LPWSTR, cchLocaleName: INT) -> INT --- - LCIDToLocaleName :: proc(Locale: LCID, lpName: LPWSTR, cchName: INT, dwFlags: DWORD) -> INT --- - LocaleNameToLCID :: proc(lpName: LPCWSTR, dwFlags: DWORD) -> LCID --- - SetDllDirectoryW :: proc(lpPathName: LPCWSTR) -> BOOL --- - AddDllDirectory :: proc(NewDirectory: PCWSTR) -> rawptr --- - RemoveDllDirectory :: proc(Cookie: rawptr) -> BOOL --- - LoadLibraryW :: proc(c_str: LPCWSTR) -> HMODULE --- - LoadLibraryExW :: proc(c_str: LPCWSTR, hFile: HANDLE, dwFlags: LoadLibraryEx_Flags) -> HMODULE --- - FreeLibrary :: proc(h: HMODULE) -> BOOL --- - FreeLibraryAndExitThread :: proc(hLibModule: HMODULE, dwExitCode: DWORD) -> VOID --- - GetProcAddress :: proc(h: HMODULE, c_str: LPCSTR) -> rawptr --- + LCIDToLocaleName :: proc(Locale: LCID, lpName: LPWSTR, cchName: INT, dwFlags: DWORD) -> INT --- + LocaleNameToLCID :: proc(lpName: LPCWSTR, dwFlags: DWORD) -> LCID --- + SetDllDirectoryW :: proc(lpPathName: LPCWSTR) -> BOOL --- + AddDllDirectory :: proc(NewDirectory: PCWSTR) -> rawptr --- + RemoveDllDirectory :: proc(Cookie: rawptr) -> BOOL --- + LoadLibraryW :: proc(c_str: LPCWSTR) -> HMODULE --- + LoadLibraryExW :: proc(c_str: LPCWSTR, hFile: HANDLE, dwFlags: LoadLibraryEx_Flags) -> HMODULE --- + FreeLibrary :: proc(h: HMODULE) -> BOOL --- + FreeLibraryAndExitThread :: proc(hLibModule: HMODULE, dwExitCode: DWORD) -> VOID --- + GetProcAddress :: proc(h: HMODULE, c_str: LPCSTR) -> rawptr --- - LoadResource :: proc(hModule: HMODULE, hResInfo: HRSRC) -> HGLOBAL --- - FreeResource :: proc(hResData: HGLOBAL) -> BOOL --- - LockResource :: proc(hResData: HGLOBAL) -> LPVOID --- - SizeofResource :: proc(hModule: HMODULE, hResInfo: HRSRC) -> DWORD --- - FindResourceW :: proc(hModule: HMODULE, lpName: LPCWSTR, lpType: LPCWSTR) -> HRSRC --- - FindResourceExW :: proc(hModule: HMODULE, lpType: LPCWSTR, lpName: LPCWSTR, wLanguage: LANGID) -> HRSRC --- - EnumResourceNamesW :: proc(hModule: HMODULE, lpType: LPCWSTR, lpEnumFunc: ENUMRESNAMEPROCW, lParam: LONG_PTR) -> BOOL --- - EnumResourceNamesExW :: proc(hModule: HMODULE, lpType: LPCWSTR, lpEnumFunc: ENUMRESNAMEPROCW, lParam: LONG_PTR, dwFlags: DWORD, LangId: LANGID) -> BOOL --- - EnumResourceTypesExW :: proc(hModule: HMODULE, lpEnumFunc: ENUMRESTYPEPROCW, lParam: LONG_PTR, dwFlags: DWORD, LangId: LANGID) -> BOOL --- - EnumResourceLanguagesExW :: proc(hModule: HMODULE, lpType: LPCWSTR, lpName: LPCWSTR, lpEnumFunc: ENUMRESLANGPROCW, lParam: LONG_PTR, dwFlags: DWORD, LangId: LANGID) -> BOOL --- - LookupIconIdFromDirectory :: proc(presbits: PBYTE, fIcon: BOOL) -> INT --- + LoadResource :: proc(hModule: HMODULE, hResInfo: HRSRC) -> HGLOBAL --- + FreeResource :: proc(hResData: HGLOBAL) -> BOOL --- + LockResource :: proc(hResData: HGLOBAL) -> LPVOID --- + SizeofResource :: proc(hModule: HMODULE, hResInfo: HRSRC) -> DWORD --- + FindResourceW :: proc(hModule: HMODULE, lpName: LPCWSTR, lpType: LPCWSTR) -> HRSRC --- + FindResourceExW :: proc(hModule: HMODULE, lpType: LPCWSTR, lpName: LPCWSTR, wLanguage: LANGID) -> HRSRC --- + EnumResourceNamesW :: proc(hModule: HMODULE, lpType: LPCWSTR, lpEnumFunc: ENUMRESNAMEPROCW, lParam: LONG_PTR) -> BOOL --- + EnumResourceNamesExW :: proc(hModule: HMODULE, lpType: LPCWSTR, lpEnumFunc: ENUMRESNAMEPROCW, lParam: LONG_PTR, dwFlags: DWORD, LangId: LANGID) -> BOOL --- + EnumResourceTypesExW :: proc(hModule: HMODULE, lpEnumFunc: ENUMRESTYPEPROCW, lParam: LONG_PTR, dwFlags: DWORD, LangId: LANGID) -> BOOL --- + EnumResourceLanguagesExW :: proc(hModule: HMODULE, lpType: LPCWSTR, lpName: LPCWSTR, lpEnumFunc: ENUMRESLANGPROCW, lParam: LONG_PTR, dwFlags: DWORD, LangId: LANGID) -> BOOL --- + LookupIconIdFromDirectory :: proc(presbits: PBYTE, fIcon: BOOL) -> INT --- LookupIconIdFromDirectoryEx :: proc(presbits: PBYTE, fIcon: BOOL, cxDesired: INT, cyDesired: INT, Flags: UINT) -> INT --- - CreateIconFromResourceEx :: proc(presbits: PBYTE, dwResSize: DWORD, fIcon: BOOL, dwVer: DWORD, cxDesired: INT, cyDesired: INT, Flags: UINT) -> HICON --- + CreateIconFromResourceEx :: proc(presbits: PBYTE, dwResSize: DWORD, fIcon: BOOL, dwVer: DWORD, cxDesired: INT, cyDesired: INT, Flags: UINT) -> HICON --- GetFullPathNameW :: proc(filename: LPCWSTR, buffer_length: DWORD, buffer: LPCWSTR, file_part: ^LPCWSTR) -> DWORD --- GetLongPathNameW :: proc(short, long: LPCWSTR, len: DWORD) -> DWORD --- @@ -533,21 +556,21 @@ foreign kernel32 { CreatePipe :: proc(hReadPipe, hWritePipe: ^HANDLE, lpPipeAttributes: LPSECURITY_ATTRIBUTES, nSize: DWORD) -> BOOL --- - ConnectNamedPipe :: proc(hNamedPipe: HANDLE, lpOverlapped: LPOVERLAPPED) -> BOOL --- + ConnectNamedPipe :: proc(hNamedPipe: HANDLE, lpOverlapped: LPOVERLAPPED) -> BOOL --- DisconnectNamedPipe :: proc(hNamedPipe: HANDLE) -> BOOL --- - WaitNamedPipeW :: proc(lpNamedPipeName: LPCWSTR, nTimeOut: DWORD) -> BOOL --- + WaitNamedPipeW :: proc(lpNamedPipeName: LPCWSTR, nTimeOut: DWORD) -> BOOL --- - AllocConsole :: proc() -> BOOL --- - AttachConsole :: proc(dwProcessId: DWORD) -> BOOL --- - SetConsoleCtrlHandler :: proc(HandlerRoutine: PHANDLER_ROUTINE, Add: BOOL) -> BOOL --- - GenerateConsoleCtrlEvent :: proc(dwCtrlEvent: DWORD, dwProcessGroupId: DWORD) -> BOOL --- - FreeConsole :: proc() -> BOOL --- - GetConsoleWindow :: proc() -> HWND --- + AllocConsole :: proc() -> BOOL --- + AttachConsole :: proc(dwProcessId: DWORD) -> BOOL --- + SetConsoleCtrlHandler :: proc(HandlerRoutine: PHANDLER_ROUTINE, Add: BOOL) -> BOOL --- + GenerateConsoleCtrlEvent :: proc(dwCtrlEvent: DWORD, dwProcessGroupId: DWORD) -> BOOL --- + FreeConsole :: proc() -> BOOL --- + GetConsoleWindow :: proc() -> HWND --- GetConsoleScreenBufferInfo :: proc(hConsoleOutput: HANDLE, lpConsoleScreenBufferInfo: PCONSOLE_SCREEN_BUFFER_INFO) -> BOOL --- SetConsoleScreenBufferSize :: proc(hConsoleOutput: HANDLE, dwSize: COORD) -> BOOL --- - SetConsoleWindowInfo :: proc(hConsoleOutput: HANDLE, bAbsolute: BOOL, lpConsoleWindow: ^SMALL_RECT) -> BOOL --- - GetConsoleCursorInfo :: proc(hConsoleOutput: HANDLE, lpConsoleCursorInfo: PCONSOLE_CURSOR_INFO) -> BOOL --- - SetConsoleCursorInfo :: proc(hConsoleOutput: HANDLE, lpConsoleCursorInfo: PCONSOLE_CURSOR_INFO) -> BOOL --- + SetConsoleWindowInfo :: proc(hConsoleOutput: HANDLE, bAbsolute: BOOL, lpConsoleWindow: ^SMALL_RECT) -> BOOL --- + GetConsoleCursorInfo :: proc(hConsoleOutput: HANDLE, lpConsoleCursorInfo: PCONSOLE_CURSOR_INFO) -> BOOL --- + SetConsoleCursorInfo :: proc(hConsoleOutput: HANDLE, lpConsoleCursorInfo: PCONSOLE_CURSOR_INFO) -> BOOL --- GetDiskFreeSpaceExW :: proc( lpDirectoryName: LPCWSTR, @@ -561,20 +584,33 @@ foreign kernel32 { // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setfilecompletionnotificationmodes) SetFileCompletionNotificationModes :: proc(FileHandle: HANDLE, Flags: u8) -> BOOL --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ioapiset/nf-ioapiset-createiocompletionport) - CreateIoCompletionPort :: proc(FileHandle: HANDLE, ExistingCompletionPort: HANDLE, CompletionKey: ULONG_PTR, NumberOfConcurrentThreads: DWORD) -> HANDLE --- + CreateIoCompletionPort :: proc(FileHandle: HANDLE, ExistingCompletionPort: HANDLE, CompletionKey: ULONG_PTR, NumberOfConcurrentThreads: DWORD) -> HANDLE --- //[MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ioapiset/nf-ioapiset-getqueuedcompletionstatus) - GetQueuedCompletionStatus :: proc(CompletionPort: HANDLE, lpNumberOfBytesTransferred: ^DWORD, lpCompletionKey: PULONG_PTR, lpOverlapped: ^^OVERLAPPED, dwMilliseconds: DWORD) -> BOOL --- + GetQueuedCompletionStatus :: proc(CompletionPort: HANDLE, lpNumberOfBytesTransferred: ^DWORD, lpCompletionKey: PULONG_PTR, lpOverlapped: ^^OVERLAPPED, dwMilliseconds: DWORD) -> BOOL --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ioapiset/nf-ioapiset-getqueuedcompletionstatusex) - GetQueuedCompletionStatusEx :: proc(CompletionPort: HANDLE, lpCompletionPortEntries: ^OVERLAPPED_ENTRY, ulCount: c_ulong, ulNumEntriesRemoved: ^c_ulong, dwMilliseconds: DWORD, fAlertable: BOOL) -> BOOL --- + GetQueuedCompletionStatusEx :: proc(CompletionPort: HANDLE, lpCompletionPortEntries: ^OVERLAPPED_ENTRY, ulCount: c_ulong, ulNumEntriesRemoved: ^c_ulong, dwMilliseconds: DWORD, fAlertable: BOOL) -> BOOL --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ioapiset/nf-ioapiset-postqueuedcompletionstatus) - PostQueuedCompletionStatus :: proc(CompletionPort: HANDLE, dwNumberOfBytesTransferred: DWORD, dwCompletionKey: c_ulong, lpOverlapped: ^OVERLAPPED) -> BOOL --- + PostQueuedCompletionStatus :: proc(CompletionPort: HANDLE, dwNumberOfBytesTransferred: DWORD, dwCompletionKey: ULONG_PTR, lpOverlapped: ^OVERLAPPED) -> BOOL --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-gethandleinformation) - GetHandleInformation :: proc(hObject: HANDLE, lpdwFlags: ^DWORD) -> BOOL --- + GetHandleInformation :: proc(hObject: HANDLE, lpdwFlags: ^DWORD) -> BOOL --- RtlCaptureStackBackTrace :: proc(FramesToSkip: ULONG, FramesToCapture: ULONG, BackTrace: [^]PVOID, BackTraceHash: PULONG) -> USHORT --- RtlNtStatusToDosError :: proc(status: NTSTATUS) -> ULONG --- GetSystemPowerStatus :: proc(lpSystemPowerStatus: ^SYSTEM_POWER_STATUS) -> BOOL --- + + RegisterWaitForSingleObject :: proc( + phNewWaitObject: PHANDLE, + hObject: HANDLE, + Callback: WAITORTIMERCALLBACK, + Context: PVOID, + dwMilliseconds: ULONG, + dwFlags: ULONG, + ) -> BOOL --- + + UnregisterWaitEx :: proc(WaitHandle: HANDLE, CompletionEvent: HANDLE) -> BOOL --- + + QueueUserAPC :: proc(pfnAPC: PAPCFUNC, hThread: HANDLE, dwData: ULONG_PTR) -> DWORD --- } DEBUG_PROCESS :: 0x00000001 @@ -625,44 +661,44 @@ THREAD_PRIORITY_IDLE :: THREAD_BASE_PRIORITY_IDLE THREAD_MODE_BACKGROUND_BEGIN :: 0x00010000 THREAD_MODE_BACKGROUND_END :: 0x00020000 -PROCESS_ALL_ACCESS :: 0x000F0000 | SYNCHRONIZE | 0xFFFF -PROCESS_CREATE_PROCESS :: 0x0080 -PROCESS_CREATE_THREAD :: 0x0002 -PROCESS_DUP_HANDLE :: 0x0040 -PROCESS_QUERY_INFORMATION :: 0x0400 +PROCESS_ALL_ACCESS :: 0x000F0000 | SYNCHRONIZE | 0xFFFF +PROCESS_CREATE_PROCESS :: 0x0080 +PROCESS_CREATE_THREAD :: 0x0002 +PROCESS_DUP_HANDLE :: 0x0040 +PROCESS_QUERY_INFORMATION :: 0x0400 PROCESS_QUERY_LIMITED_INFORMATION :: 0x1000 -PROCESS_SET_INFORMATION :: 0x0200 -PROCESS_SET_QUOTA :: 0x0100 -PROCESS_SUSPEND_RESUME :: 0x0800 -PROCESS_TERMINATE :: 0x0001 -PROCESS_VM_OPERATION :: 0x0008 -PROCESS_VM_READ :: 0x0010 -PROCESS_VM_WRITE :: 0x0020 +PROCESS_SET_INFORMATION :: 0x0200 +PROCESS_SET_QUOTA :: 0x0100 +PROCESS_SUSPEND_RESUME :: 0x0800 +PROCESS_TERMINATE :: 0x0001 +PROCESS_VM_OPERATION :: 0x0008 +PROCESS_VM_READ :: 0x0010 +PROCESS_VM_WRITE :: 0x0020 THREAD_ALL_ACCESS :: \ - THREAD_DIRECT_IMPERSONATION | - THREAD_GET_CONTEXT | - THREAD_IMPERSONATE | - THREAD_QUERY_INFORMATION | + THREAD_DIRECT_IMPERSONATION | + THREAD_GET_CONTEXT | + THREAD_IMPERSONATE | + THREAD_QUERY_INFORMATION | THREAD_QUERY_LIMITED_INFORMATION | - THREAD_SET_CONTEXT | - THREAD_SET_INFORMATION | - THREAD_SET_LIMITED_INFORMATION | - THREAD_SET_THREAD_TOKEN | - THREAD_SUSPEND_RESUME | - THREAD_TERMINATE | + THREAD_SET_CONTEXT | + THREAD_SET_INFORMATION | + THREAD_SET_LIMITED_INFORMATION | + THREAD_SET_THREAD_TOKEN | + THREAD_SUSPEND_RESUME | + THREAD_TERMINATE | SYNCHRONIZE -THREAD_DIRECT_IMPERSONATION :: 0x0200 -THREAD_GET_CONTEXT :: 0x0008 -THREAD_IMPERSONATE :: 0x0100 -THREAD_QUERY_INFORMATION :: 0x0040 +THREAD_DIRECT_IMPERSONATION :: 0x0200 +THREAD_GET_CONTEXT :: 0x0008 +THREAD_IMPERSONATE :: 0x0100 +THREAD_QUERY_INFORMATION :: 0x0040 THREAD_QUERY_LIMITED_INFORMATION :: 0x0800 -THREAD_SET_CONTEXT :: 0x0010 -THREAD_SET_INFORMATION :: 0x0020 -THREAD_SET_LIMITED_INFORMATION :: 0x0400 -THREAD_SET_THREAD_TOKEN :: 0x0080 -THREAD_SUSPEND_RESUME :: 0x0002 -THREAD_TERMINATE :: 0x0001 +THREAD_SET_CONTEXT :: 0x0010 +THREAD_SET_INFORMATION :: 0x0020 +THREAD_SET_LIMITED_INFORMATION :: 0x0400 +THREAD_SET_THREAD_TOKEN :: 0x0080 +THREAD_SUSPEND_RESUME :: 0x0002 +THREAD_TERMINATE :: 0x0001 COPY_FILE_FAIL_IF_EXISTS :: 0x00000001 COPY_FILE_RESTARTABLE :: 0x00000002 @@ -701,7 +737,7 @@ FILE_MAP_TARGETS_INVALID :: DWORD(0x40000000) FILE_MAP_LARGE_PAGES :: DWORD(0x20000000) LOCKFILE_FAIL_IMMEDIATELY :: DWORD (0x00000001) -LOCKFILE_EXCLUSIVE_LOCK :: DWORD(0x00000002) +LOCKFILE_EXCLUSIVE_LOCK :: DWORD(0x00000002) // Flags for `SetFileCompletionNotificationModes`. FILE_SKIP_COMPLETION_PORT_ON_SUCCESS :: 0x1 @@ -720,16 +756,16 @@ PAGE_NOCACHE :: 0x200 PAGE_WRITECOMBINE :: 0x400 MEMORY_BASIC_INFORMATION :: struct { - BaseAddress: PVOID, - AllocationBase: PVOID, + BaseAddress: PVOID, + AllocationBase: PVOID, AllocationProtect: DWORD, - PartitionId: WORD, - RegionSize: SIZE_T, - State: DWORD, - Protect: DWORD, - Type: DWORD, + PartitionId: WORD, + RegionSize: SIZE_T, + State: DWORD, + Protect: DWORD, + Type: DWORD, } -PMEMORY_BASIC_INFORMATION :: ^MEMORY_BASIC_INFORMATION +PMEMORY_BASIC_INFORMATION :: ^MEMORY_BASIC_INFORMATION LPMEMORY_BASIC_INFORMATION :: ^MEMORY_BASIC_INFORMATION MEM_COMMIT :: 0x1000 @@ -747,97 +783,97 @@ MEM_4MB_PAGES :: 0x80000000 @(default_calling_convention="system") foreign kernel32 { VirtualAlloc :: proc( - lpAddress: LPVOID, - dwSize: SIZE_T, + lpAddress: LPVOID, + dwSize: SIZE_T, flAllocationType: DWORD, - flProtect: DWORD, + flProtect: DWORD, ) -> LPVOID --- VirtualProtect :: proc( - lpAddress: LPVOID, - dwSize: SIZE_T, - flNewProtect: DWORD, + lpAddress: LPVOID, + dwSize: SIZE_T, + flNewProtect: DWORD, lpflOldProtect: PDWORD, ) -> BOOL --- VirtualFree :: proc( - lpAddress: LPVOID, - dwSize: SIZE_T, + lpAddress: LPVOID, + dwSize: SIZE_T, dwFreeType: DWORD, ) -> BOOL --- VirtualQuery :: proc( lpAddress: LPCVOID, - lpBuffer: PMEMORY_BASIC_INFORMATION, - dwLength: SIZE_T, + lpBuffer: PMEMORY_BASIC_INFORMATION, + dwLength: SIZE_T, ) -> SIZE_T --- VirtualAllocEx :: proc( - hProcess: HANDLE, - lpAddress: LPVOID, - dwSize: SIZE_T, + hProcess: HANDLE, + lpAddress: LPVOID, + dwSize: SIZE_T, flAllocationType: DWORD, - flProtect: DWORD, + flProtect: DWORD, ) -> LPVOID --- VirtualFreeEx :: proc( - hProcess: HANDLE, - lpAddress: LPVOID, - dwSize: SIZE_T, + hProcess: HANDLE, + lpAddress: LPVOID, + dwSize: SIZE_T, dwFreeType: DWORD, ) -> BOOL --- VirtualProtectEx :: proc( - hProcess: HANDLE, - lpAddress: LPVOID, - dwSize: SIZE_T, - flNewProtect: DWORD, + hProcess: HANDLE, + lpAddress: LPVOID, + dwSize: SIZE_T, + flNewProtect: DWORD, lpflOldProtect: PDWORD, ) -> BOOL --- VirtualQueryEx :: proc( - hProcess: HANDLE, + hProcess: HANDLE, lpAddress: LPCVOID, - lpBuffer: PMEMORY_BASIC_INFORMATION, - dwLength: SIZE_T, + lpBuffer: PMEMORY_BASIC_INFORMATION, + dwLength: SIZE_T, ) -> SIZE_T --- ReadProcessMemory :: proc( - hProcess: HANDLE, - lpBaseAddress: LPCVOID, - lpBuffer: LPVOID, - nSize: SIZE_T, + hProcess: HANDLE, + lpBaseAddress: LPCVOID, + lpBuffer: LPVOID, + nSize: SIZE_T, lpNumberOfBytesRead: ^SIZE_T, ) -> BOOL --- WriteProcessMemory :: proc( - hProcess: HANDLE, - lpBaseAddress: LPVOID, - lpBuffer: LPCVOID, - nSize: SIZE_T, + hProcess: HANDLE, + lpBaseAddress: LPVOID, + lpBuffer: LPCVOID, + nSize: SIZE_T, lpNumberOfBytesWritten: ^SIZE_T, ) -> BOOL --- CreateFileMappingW :: proc( - hFile: HANDLE, + hFile: HANDLE, lpFileMappingAttributes: LPSECURITY_ATTRIBUTES, - flProtect: DWORD, - dwMaximumSizeHigh: DWORD, - dwMaximumSizeLow: DWORD, - lpName: LPCWSTR, + flProtect: DWORD, + dwMaximumSizeHigh: DWORD, + dwMaximumSizeLow: DWORD, + lpName: LPCWSTR, ) -> HANDLE --- OpenFileMappingW :: proc( dwDesiredAccess: DWORD, - bInheritHandle: BOOL, - lpName: LPCWSTR, + bInheritHandle: BOOL, + lpName: LPCWSTR, ) -> HANDLE --- MapViewOfFile :: proc( - hFileMappingObject: HANDLE, - dwDesiredAccess: DWORD, - dwFileOffsetHigh: DWORD, - dwFileOffsetLow: DWORD, + hFileMappingObject: HANDLE, + dwDesiredAccess: DWORD, + dwFileOffsetHigh: DWORD, + dwFileOffsetLow: DWORD, dwNumberOfBytesToMap: SIZE_T, ) -> LPVOID --- MapViewOfFileEx :: proc( - hFileMappingObject: HANDLE, - dwDesiredAccess: DWORD, - dwFileOffsetHigh: DWORD, - dwFileOffsetLow: DWORD, + hFileMappingObject: HANDLE, + dwDesiredAccess: DWORD, + dwFileOffsetHigh: DWORD, + dwFileOffsetLow: DWORD, dwNumberOfBytesToMap: SIZE_T, - lpBaseAddress: LPVOID, + lpBaseAddress: LPVOID, ) -> LPVOID --- FlushViewOfFile :: proc( - lpBaseAddress: LPCVOID, + lpBaseAddress: LPCVOID, dwNumberOfBytesToFlush: SIZE_T, ) -> BOOL --- UnmapViewOfFile :: proc( @@ -845,36 +881,36 @@ foreign kernel32 { ) -> BOOL --- GetLargePageMinimum :: proc() -> SIZE_T --- GetProcessWorkingSetSizeEx :: proc( - hProcess: HANDLE, + hProcess: HANDLE, lpMinimumWorkingSetSize: PSIZE_T, lpMaximumWorkingSetSize: PSIZE_T, - Flags: PDWORD, + Flags: PDWORD, ) -> BOOL --- SetProcessWorkingSetSizeEx :: proc( - hProcess: HANDLE, + hProcess: HANDLE, dwMinimumWorkingSetSize: SIZE_T, dwMaximumWorkingSetSize: SIZE_T, - Flags: DWORD, + Flags: DWORD, ) -> BOOL --- VirtualLock :: proc( lpAddress: LPVOID, - dwSize: SIZE_T, + dwSize: SIZE_T, ) -> BOOL --- VirtualUnlock :: proc( lpAddress: LPVOID, - dwSize: SIZE_T, + dwSize: SIZE_T, ) -> BOOL --- GetWriteWatch :: proc( - dwFlags: DWORD, - lpBaseAddress: PVOID, - dwRegionSize: SIZE_T, - lpAddresses: ^PVOID, - lpdwCount: ^ULONG_PTR, + dwFlags: DWORD, + lpBaseAddress: PVOID, + dwRegionSize: SIZE_T, + lpAddresses: ^PVOID, + lpdwCount: ^ULONG_PTR, lpdwGranularity: LPDWORD, ) -> UINT --- ResetWriteWatch :: proc( lpBaseAddress: LPVOID, - dwRegionSize: SIZE_T, + dwRegionSize: SIZE_T, ) -> UINT --- } @@ -907,27 +943,27 @@ foreign kernel32 { GetSystemFileCacheSize :: proc( lpMinimumFileCacheSize: PSIZE_T, lpMaximumFileCacheSize: PSIZE_T, - lpFlags: PDWORD, + lpFlags: PDWORD, ) -> BOOL --- SetSystemFileCacheSize :: proc( MinimumFileCacheSize: SIZE_T, MaximumFileCacheSize: SIZE_T, - Flags: DWORD, + Flags: DWORD, ) -> BOOL --- CreateFileMappingNumaW :: proc( - hFile: HANDLE, + hFile: HANDLE, lpFileMappingAttributes: LPSECURITY_ATTRIBUTES, - flProtect: DWORD, - dwMaximumSizeHigh: DWORD, - dwMaximumSizeLow: DWORD, - lpName: LPCWSTR, - nndPreferred: DWORD, + flProtect: DWORD, + dwMaximumSizeHigh: DWORD, + dwMaximumSizeLow: DWORD, + lpName: LPCWSTR, + nndPreferred: DWORD, ) -> HANDLE --- } WIN32_MEMORY_RANGE_ENTRY :: struct { VirtualAddress: PVOID, - NumberOfBytes: SIZE_T, + NumberOfBytes: SIZE_T, } PWIN32_MEMORY_RANGE_ENTRY :: ^WIN32_MEMORY_RANGE_ENTRY @@ -935,56 +971,56 @@ PWIN32_MEMORY_RANGE_ENTRY :: ^WIN32_MEMORY_RANGE_ENTRY @(default_calling_convention="system") foreign kernel32 { PrefetchVirtualMemory :: proc( - hProcess: HANDLE, - NumberOfEntries: ULONG_PTR, + hProcess: HANDLE, + NumberOfEntries: ULONG_PTR, VirtualAddresses: PWIN32_MEMORY_RANGE_ENTRY, - Flags: ULONG, + Flags: ULONG, ) -> BOOL --- CreateFileMappingFromApp :: proc( - hFile: HANDLE, + hFile: HANDLE, SecurityAttributes: PSECURITY_ATTRIBUTES, - PageProtection: ULONG, - MaximumSize: ULONG64, - Name: PCWSTR, + PageProtection: ULONG, + MaximumSize: ULONG64, + Name: PCWSTR, ) -> HANDLE --- MapViewOfFileFromApp :: proc( hFileMappingObject: HANDLE, - DesiredAccess: ULONG, - FileOffset: ULONG64, + DesiredAccess: ULONG, + FileOffset: ULONG64, NumberOfBytesToMap: SIZE_T, ) -> PVOID --- UnmapViewOfFileEx :: proc( BaseAddress: PVOID, - UnmapFlags: ULONG, + UnmapFlags: ULONG, ) -> BOOL --- AllocateUserPhysicalPages :: proc( - hProcess: HANDLE, + hProcess: HANDLE, NumberOfPages: PULONG_PTR, - PageArray: PULONG_PTR, + PageArray: PULONG_PTR, ) -> BOOL --- FreeUserPhysicalPages :: proc( - hProcess: HANDLE, + hProcess: HANDLE, NumberOfPages: PULONG_PTR, - PageArray: PULONG_PTR, + PageArray: PULONG_PTR, ) -> BOOL --- MapUserPhysicalPages :: proc( VirtualAddress: PVOID, - NumberOfPages: ULONG_PTR, - PageArray: PULONG_PTR, + NumberOfPages: ULONG_PTR, + PageArray: PULONG_PTR, ) -> BOOL --- AllocateUserPhysicalPagesNuma :: proc( - hProcess: HANDLE, + hProcess: HANDLE, NumberOfPages: PULONG_PTR, - PageArray: PULONG_PTR, - nndPreferred: DWORD, + PageArray: PULONG_PTR, + nndPreferred: DWORD, ) -> BOOL --- VirtualAllocExNuma :: proc( - hProcess: HANDLE, - lpAddress: LPVOID, - dwSize: SIZE_T, + hProcess: HANDLE, + lpAddress: LPVOID, + dwSize: SIZE_T, flAllocationType: DWORD, - flProtect: DWORD, - nndPreferred: DWORD, + flProtect: DWORD, + nndPreferred: DWORD, ) -> LPVOID --- } @@ -992,28 +1028,20 @@ MEHC_PATROL_SCRUBBER_PRESENT :: ULONG(0x1) @(default_calling_convention="system") foreign kernel32 { - GetMemoryErrorHandlingCapabilities :: proc( - Capabilities: PULONG, - ) -> BOOL --- + GetMemoryErrorHandlingCapabilities :: proc(Capabilities: PULONG) -> BOOL --- } @(default_calling_convention="system") foreign kernel32 { - GlobalMemoryStatusEx :: proc( - lpBuffer: ^MEMORYSTATUSEX, - ) -> BOOL --- + GlobalMemoryStatusEx :: proc(lpBuffer: ^MEMORYSTATUSEX) -> BOOL --- } PBAD_MEMORY_CALLBACK_ROUTINE :: #type proc "system" () @(default_calling_convention="system") foreign kernel32 { - RegisterBadMemoryNotification :: proc( - Callback: PBAD_MEMORY_CALLBACK_ROUTINE, - ) -> PVOID --- - UnregisterBadMemoryNotification :: proc( - RegistrationHandle: PVOID, - ) -> BOOL --- + RegisterBadMemoryNotification :: proc(Callback: PBAD_MEMORY_CALLBACK_ROUTINE) -> PVOID --- + UnregisterBadMemoryNotification :: proc(RegistrationHandle: PVOID) -> BOOL --- } OFFER_PRIORITY :: enum c_int { @@ -1031,33 +1059,33 @@ VmOfferPriorityNormal :: OFFER_PRIORITY.VmOfferPriorityNormal foreign kernel32 { OfferVirtualMemory :: proc( VirtualAddress: PVOID, - Size: SIZE_T, - Priority: OFFER_PRIORITY, + Size: SIZE_T, + Priority: OFFER_PRIORITY, ) -> DWORD --- ReclaimVirtualMemory :: proc( VirtualAddress: PVOID, - Size: SIZE_T, + Size: SIZE_T, ) -> DWORD --- DiscardVirtualMemory :: proc( VirtualAddress: PVOID, - Size: SIZE_T, + Size: SIZE_T, ) -> DWORD --- VirtualAllocFromApp :: proc( - BaseAddress: PVOID, - Size: SIZE_T, + BaseAddress: PVOID, + Size: SIZE_T, AllocationType: ULONG, - Protection: ULONG, + Protection: ULONG, ) -> PVOID --- VirtualProtectFromApp :: proc( - Address: PVOID, - Size: SIZE_T, + Address: PVOID, + Size: SIZE_T, NewProtection: ULONG, OldProtection: PULONG, ) -> BOOL --- OpenFileMappingFromApp :: proc( DesiredAccess: ULONG, InheritHandle: BOOL, - Name: PCWSTR, + Name: PCWSTR, ) -> HANDLE --- } @@ -1067,54 +1095,48 @@ WIN32_MEMORY_INFORMATION_CLASS :: enum c_int { MemoryRegionInfo :: WIN32_MEMORY_INFORMATION_CLASS.MemoryRegionInfo WIN32_MEMORY_REGION_INFORMATION :: struct { - AllocationBase: PVOID, + AllocationBase: PVOID, AllocationProtect: ULONG, - u: WIN32_MEMORY_REGION_INFORMATION_u, + using DUMMYUNIONNAME: struct #raw_union { + _: [1]u32, + Flags: ULONG, + using DUMMYSTRUCTNAME: bit_field ULONG { + Private: ULONG | 1, + MappedDataFile: ULONG | 1, + MappedImage: ULONG | 1, + MappedPageFile: ULONG | 1, + MappedPhysical: ULONG | 1, + DirectMapped: ULONG | 1, + Reserved: ULONG | 26, + }, + }, RegionSize: SIZE_T, CommitSize: SIZE_T, } -WIN32_MEMORY_REGION_INFORMATION_u :: struct #raw_union { - u: [1]u32, - Flags: ULONG, - s: WIN32_MEMORY_REGION_INFORMATION_u_s, -} -WIN32_MEMORY_REGION_INFORMATION_u_s :: struct { - Bitfield: ULONG, -} -WIN32_MEMORY_REGION_INFORMATION_u_s_Bitfield :: distinct ULONG -/*bit_field #align(align_of(ULONG)) { - Private : 1-0, - MappedDataFile : 2-1, - MappedImage : 3-2, - MappedPageFile : 4-3, - MappedPhysical : 5-4, - DirectMapped : 6-5, - Reserved : 32-6, -}*/ @(default_calling_convention="system") foreign one_core { QueryVirtualMemoryInformation :: proc( - Process: HANDLE, - VirtualAddress: PVOID, + Process: HANDLE, + VirtualAddress: PVOID, MemoryInformationClass: WIN32_MEMORY_INFORMATION_CLASS, - MemoryInformation: PVOID, - MemoryInformationSize: SIZE_T, - ReturnSize: PSIZE_T, + MemoryInformation: PVOID, + MemoryInformationSize: SIZE_T, + ReturnSize: PSIZE_T, ) -> BOOL --- MapViewOfFileNuma2 :: proc( FileMappingHandle: HANDLE, - ProcessHandle: HANDLE, - Offset: ULONG64, - BaseAddress: PVOID, - ViewSize: SIZE_T, - AllocationType: ULONG, - PageProtection: ULONG, - PreferredNode: ULONG, + ProcessHandle: HANDLE, + Offset: ULONG64, + BaseAddress: PVOID, + ViewSize: SIZE_T, + AllocationType: ULONG, + PageProtection: ULONG, + PreferredNode: ULONG, ) -> PVOID --- GetCommPorts :: proc( - lpPortNumbers: PULONG, - uPortNumbersCount: ULONG, + lpPortNumbers: PULONG, + uPortNumbersCount: ULONG, puPortNumbersFound: PULONG, ) -> ULONG --- } @@ -1124,12 +1146,12 @@ NUMA_NO_PREFERRED_NODE :: 0xffffffff MapViewOfFile2 :: #force_inline proc "system" ( FileMappingHandle: HANDLE, - ProcessHandle: HANDLE, - Offset: ULONG64, - BaseAddress: PVOID, - ViewSize: SIZE_T, - AllocationType: ULONG, - PageProtection: ULONG, + ProcessHandle: HANDLE, + Offset: ULONG64, + BaseAddress: PVOID, + ViewSize: SIZE_T, + AllocationType: ULONG, + PageProtection: ULONG, ) -> PVOID { return MapViewOfFileNuma2( FileMappingHandle, @@ -1147,8 +1169,8 @@ MapViewOfFile2 :: #force_inline proc "system" ( foreign kernel32 { UnmapViewOfFile2 :: proc( ProcessHandle: HANDLE, - BaseAddress: PVOID, - UnmapFlags: ULONG, + BaseAddress: PVOID, + UnmapFlags: ULONG, ) -> BOOL --- } @@ -1159,7 +1181,7 @@ foreign kernel32 { OSMinorVersion: DWORD, SpMajorVersion: DWORD, SpMinorVersion: DWORD, - product_type: ^Windows_Product_Type, + product_type: ^Windows_Product_Type, ) -> BOOL --- } @@ -1173,10 +1195,10 @@ LPFIBER_START_ROUTINE :: #type proc "system" (lpFiberParameter: LPVOID) @(default_calling_convention = "system") foreign kernel32 { - CreateFiber :: proc(dwStackSize: SIZE_T, lpStartAddress: LPFIBER_START_ROUTINE, lpParameter: LPVOID) -> LPVOID --- - DeleteFiber :: proc(lpFiber: LPVOID) --- + CreateFiber :: proc(dwStackSize: SIZE_T, lpStartAddress: LPFIBER_START_ROUTINE, lpParameter: LPVOID) -> LPVOID --- + DeleteFiber :: proc(lpFiber: LPVOID) --- ConvertThreadToFiber :: proc(lpParameter: LPVOID) -> LPVOID --- - SwitchToFiber :: proc(lpFiber: LPVOID) --- + SwitchToFiber :: proc(lpFiber: LPVOID) --- } LOGICAL_PROCESSOR_RELATIONSHIP :: enum c_int { @@ -1199,11 +1221,11 @@ PROCESSOR_CACHE_TYPE :: enum c_int { } CACHE_DESCRIPTOR :: struct { - Level: BYTE, + Level: BYTE, Associativity: BYTE, - LineSize: WORD, - Size: DWORD, - Type: PROCESSOR_CACHE_TYPE, + LineSize: WORD, + Size: DWORD, + Type: PROCESSOR_CACHE_TYPE, } ProcessorCore :: struct { @@ -1212,17 +1234,16 @@ ProcessorCore :: struct { NumaNode :: struct { NodeNumber: DWORD, } -DUMMYUNIONNAME_u :: struct #raw_union { - Core: ProcessorCore, - Node: NumaNode, - Cache: CACHE_DESCRIPTOR, - Reserved: [2]ULONGLONG, -} SYSTEM_LOGICAL_PROCESSOR_INFORMATION :: struct { ProcessorMask: ULONG_PTR, - Relationship: LOGICAL_PROCESSOR_RELATIONSHIP, - using DummyUnion: DUMMYUNIONNAME_u, + Relationship: LOGICAL_PROCESSOR_RELATIONSHIP, + using DUMMYUNIONNAME: struct #raw_union { + ProcessorCore: ProcessorCore `raw_union_tag:"Relationship=RelationProcessorCore"`, + NumaNode: NumaNode `raw_union_tag:"Relationship=RelationNumaNode"`, + Cache: CACHE_DESCRIPTOR `raw_union_tag:"Relationship=RelationCache"`, + Reserved: [2]ULONGLONG, + }, } SYSTEM_POWER_STATUS :: struct { @@ -1294,6 +1315,6 @@ ACTCTX_FLAG_HMODULE_VALID :: 0x080 @(default_calling_convention="system") foreign kernel32 { - CreateActCtxW :: proc(pActCtx: ^ACTCTXW) -> HANDLE --- + CreateActCtxW :: proc(pActCtx: ^ACTCTXW) -> HANDLE --- ActivateActCtx :: proc(hActCtx: HANDLE, lpCookie: ^ULONG_PTR) -> BOOL --- } diff --git a/core/sys/windows/key_codes.odin b/core/sys/windows/key_codes.odin index 0991ca4b3..a2910ecd1 100644 --- a/core/sys/windows/key_codes.odin +++ b/core/sys/windows/key_codes.odin @@ -3,11 +3,11 @@ package sys_windows // https://docs.microsoft.com/en-us/windows/win32/inputdev/about-keyboard-input KF_EXTENDED :: 0x0100 -KF_DLGMODE :: 0x0800 +KF_DLGMODE :: 0x0800 KF_MENUMODE :: 0x1000 -KF_ALTDOWN :: 0x2000 -KF_REPEAT :: 0x4000 -KF_UP :: 0x8000 +KF_ALTDOWN :: 0x2000 +KF_REPEAT :: 0x4000 +KF_UP :: 0x8000 // https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes // Virtual Keys, Standard Set diff --git a/core/sys/windows/mswsock.odin b/core/sys/windows/mswsock.odin new file mode 100644 index 000000000..9019fc821 --- /dev/null +++ b/core/sys/windows/mswsock.odin @@ -0,0 +1,40 @@ +#+build windows +package sys_windows + +foreign import mswsock "system:mswsock.lib" + +foreign mswsock { + TransmitFile :: proc( + hSocket: SOCKET, + hFile: HANDLE, + nNumberOfBytesToWrite: DWORD, + nNumberOfBytesPerSend: DWORD, + lpOverlapped: LPOVERLAPPED, + lpTransmitBuffers: rawptr, + dwReserved: DWORD, + ) -> BOOL --- + + AcceptEx :: proc( + sListenSocket: SOCKET, + sAcceptSocket: SOCKET, + lpOutputBuffer: PVOID, + dwReceiveDataLength: DWORD, + dwLocalAddressLength: DWORD, + dwRemoteAddressLength: DWORD, + lpdwBytesReceived: LPDWORD, + lpOverlapped: LPOVERLAPPED, + ) -> BOOL --- + + GetAcceptExSockaddrs :: proc( + lpOutputBuffer: PVOID, + dwReceiveDataLength: DWORD, + dwLocalAddressLength: DWORD, + dwRemoteAddressLength: DWORD, + LocalSockaddr: ^^sockaddr, + LocalSockaddrLength: LPINT, + RemoteSockaddr: ^^sockaddr, + RemoteSockaddrLength: LPINT, + ) --- +} + +SO_UPDATE_CONNECT_CONTEXT :: 0x7010 \ No newline at end of file diff --git a/core/sys/windows/netapi32.odin b/core/sys/windows/netapi32.odin index 9442193ca..759c5847a 100644 --- a/core/sys/windows/netapi32.odin +++ b/core/sys/windows/netapi32.odin @@ -7,32 +7,32 @@ foreign import netapi32 "system:Netapi32.lib" foreign netapi32 { NetUserAdd :: proc( servername: wstring, - level: DWORD, - user_info: ^USER_INFO_1, // Perhaps make this a #raw_union with USER_INFO1..4 when we need the other levels. - parm_err: ^DWORD, + level: DWORD, + user_info: ^USER_INFO_1, // Perhaps make this a #raw_union with USER_INFO1..4 when we need the other levels. + parm_err: ^DWORD, ) -> NET_API_STATUS --- NetUserDel :: proc( servername: wstring, - username: wstring, + username: wstring, ) -> NET_API_STATUS --- NetUserGetInfo :: proc( servername: wstring, - username: wstring, - level: DWORD, - user_info: ^USER_INFO_1, + username: wstring, + level: DWORD, + user_info: ^USER_INFO_1, ) -> NET_API_STATUS --- NetLocalGroupAddMembers :: proc( - servername: wstring, - groupname: wstring, - level: DWORD, + servername: wstring, + groupname: wstring, + level: DWORD, group_members_info: ^LOCALGROUP_MEMBERS_INFO_0, // Actually a variably sized array of these. - totalentries: DWORD, + totalentries: DWORD, ) -> NET_API_STATUS --- NetLocalGroupDelMembers :: proc( - servername: wstring, - groupname: wstring, - level: DWORD, + servername: wstring, + groupname: wstring, + level: DWORD, group_members_info: ^LOCALGROUP_MEMBERS_INFO_0, // Actually a variably sized array of these. - totalentries: DWORD, + totalentries: DWORD, ) -> NET_API_STATUS --- } \ No newline at end of file diff --git a/core/sys/windows/ntdll.odin b/core/sys/windows/ntdll.odin index 747130749..8362bb9df 100644 --- a/core/sys/windows/ntdll.odin +++ b/core/sys/windows/ntdll.odin @@ -36,6 +36,20 @@ foreign ntdll_lib { QueryFlags: ULONG, FileName : PUNICODE_STRING, ) -> NTSTATUS --- + + NtCreateFile :: proc( + FileHandle: PHANDLE, + DesiredAccess: ACCESS_MASK, + ObjectAttributes: POBJECT_ATTRIBUTES, + IoStatusBlock: PIO_STATUS_BLOCK, + AllocationSize: PLARGE_INTEGER, + FileAttributes: ULONG, + ShareAccess: ULONG, + CreateDisposition: ULONG, + CreateOptions: ULONG, + EaBuffer: PVOID, + EaLength: ULONG, + ) -> NTSTATUS --- } @@ -256,4 +270,13 @@ RTL_DRIVE_LETTER_CURDIR :: struct { LIST_ENTRY :: struct { Flink: ^LIST_ENTRY, Blink: ^LIST_ENTRY, -} \ No newline at end of file +} + +FILE_SUPERSEDE :: 0x00000000 +FILE_OPEN :: 0x00000001 +FILE_CREATE :: 0x00000002 +FILE_OPEN_IF :: 0x00000003 +FILE_OVERWRITE :: 0x00000004 +FILE_OVERWRITE_IF :: 0x00000005 + +FILE_NON_DIRECTORY_FILE :: 0x00000040 diff --git a/core/sys/windows/ole32.odin b/core/sys/windows/ole32.odin index 32cb6fd60..12cf40b81 100644 --- a/core/sys/windows/ole32.odin +++ b/core/sys/windows/ole32.odin @@ -41,32 +41,32 @@ LPUNKNOWN :: ^IUnknown @(default_calling_convention="system") foreign Ole32 { - CoInitialize :: proc(reserved: rawptr = nil) -> HRESULT --- + CoInitialize :: proc(reserved: rawptr = nil) -> HRESULT --- CoInitializeEx :: proc(reserved: rawptr = nil, co_init: COINIT = .APARTMENTTHREADED) -> HRESULT --- CoUninitialize :: proc() --- CoCreateInstance :: proc( - rclsid: REFCLSID, - pUnkOuter: LPUNKNOWN, + rclsid: REFCLSID, + pUnkOuter: LPUNKNOWN, dwClsContext: DWORD, - riid: REFIID, - ppv: ^LPVOID, + riid: REFIID, + ppv: ^LPVOID, ) -> HRESULT --- - CoTaskMemAlloc :: proc(cb: SIZE_T) -> rawptr --- + CoTaskMemAlloc :: proc(cb: SIZE_T) -> rawptr --- CoTaskMemRealloc :: proc(pv: rawptr, cb: SIZE_T) -> rawptr --- - CoTaskMemFree :: proc(pv: rawptr) --- + CoTaskMemFree :: proc(pv: rawptr) --- - CLSIDFromProgID :: proc(lpszProgID: LPCOLESTR, lpclsid: LPCLSID) -> HRESULT --- + CLSIDFromProgID :: proc(lpszProgID: LPCOLESTR, lpclsid: LPCLSID) -> HRESULT --- CLSIDFromProgIDEx :: proc(lpszProgID: LPCOLESTR, lpclsid: LPCLSID) -> HRESULT --- - CLSIDFromString :: proc(lpsz: LPOLESTR, pclsid: LPCLSID) -> HRESULT --- - IIDFromString :: proc(lpsz: LPOLESTR, lpiid: LPIID) -> HRESULT --- - ProgIDFromCLSID :: proc(clsid: REFCLSID, lplpszProgID: ^LPOLESTR) -> HRESULT --- - StringFromCLSID :: proc(rclsid: REFCLSID, lplpsz: ^LPOLESTR) -> HRESULT --- - StringFromGUID2 :: proc(rclsid: REFCLSID, lplpsz: LPOLESTR, cchMax: INT) -> INT --- - StringFromIID :: proc(rclsid: REFIID, lplpsz: ^LPOLESTR) -> HRESULT --- + CLSIDFromString :: proc(lpsz: LPOLESTR, pclsid: LPCLSID) -> HRESULT --- + IIDFromString :: proc(lpsz: LPOLESTR, lpiid: LPIID) -> HRESULT --- + ProgIDFromCLSID :: proc(clsid: REFCLSID, lplpszProgID: ^LPOLESTR) -> HRESULT --- + StringFromCLSID :: proc(rclsid: REFCLSID, lplpsz: ^LPOLESTR) -> HRESULT --- + StringFromGUID2 :: proc(rclsid: REFCLSID, lplpsz: LPOLESTR, cchMax: INT) -> INT --- + StringFromIID :: proc(rclsid: REFIID, lplpsz: ^LPOLESTR) -> HRESULT --- - PropVariantClear :: proc(pvar: ^PROPVARIANT) -> HRESULT --- - PropVariantCopy :: proc(pvarDest: ^PROPVARIANT, pvarSrc: ^PROPVARIANT) -> HRESULT --- + PropVariantClear :: proc(pvar: ^PROPVARIANT) -> HRESULT --- + PropVariantCopy :: proc(pvarDest: ^PROPVARIANT, pvarSrc: ^PROPVARIANT) -> HRESULT --- FreePropVariantArray :: proc(cVariants: ULONG, rgvars: ^PROPVARIANT) -> HRESULT --- } diff --git a/core/sys/windows/shcore.odin b/core/sys/windows/shcore.odin index 08a76ebe6..c7d784fe8 100644 --- a/core/sys/windows/shcore.odin +++ b/core/sys/windows/shcore.odin @@ -8,18 +8,18 @@ foreign import shcore "system:Shcore.lib" foreign shcore { GetProcessDpiAwareness :: proc(hprocess: HANDLE, value: ^PROCESS_DPI_AWARENESS) -> HRESULT --- SetProcessDpiAwareness :: proc(value: PROCESS_DPI_AWARENESS) -> HRESULT --- - GetDpiForMonitor :: proc(hmonitor: HMONITOR, dpiType: MONITOR_DPI_TYPE, dpiX: ^UINT, dpiY: ^UINT) -> HRESULT --- + GetDpiForMonitor :: proc(hmonitor: HMONITOR, dpiType: MONITOR_DPI_TYPE, dpiX: ^UINT, dpiY: ^UINT) -> HRESULT --- } PROCESS_DPI_AWARENESS :: enum DWORD { - PROCESS_DPI_UNAWARE = 0, - PROCESS_SYSTEM_DPI_AWARE = 1, + PROCESS_DPI_UNAWARE = 0, + PROCESS_SYSTEM_DPI_AWARE = 1, PROCESS_PER_MONITOR_DPI_AWARE = 2, } MONITOR_DPI_TYPE :: enum DWORD { MDT_EFFECTIVE_DPI = 0, - MDT_ANGULAR_DPI = 1, - MDT_RAW_DPI = 2, + MDT_ANGULAR_DPI = 1, + MDT_RAW_DPI = 2, MDT_DEFAULT, } diff --git a/core/sys/windows/shell32.odin b/core/sys/windows/shell32.odin index 54cee718c..c7d83f9f6 100644 --- a/core/sys/windows/shell32.odin +++ b/core/sys/windows/shell32.odin @@ -22,29 +22,29 @@ foreign shell32 { ) -> c_int --- SHFileOperationW :: proc(lpFileOp: LPSHFILEOPSTRUCTW) -> c_int --- SHGetFolderPathW :: proc(hwnd: HWND, csidl: c_int, hToken: HANDLE, dwFlags: DWORD, pszPath: LPWSTR) -> HRESULT --- - SHAppBarMessage :: proc(dwMessage: DWORD, pData: PAPPBARDATA) -> UINT_PTR --- + SHAppBarMessage :: proc(dwMessage: DWORD, pData: PAPPBARDATA) -> UINT_PTR --- Shell_NotifyIconW :: proc(dwMessage: DWORD, lpData: ^NOTIFYICONDATAW) -> BOOL --- - SHChangeNotify :: proc(wEventId: LONG, uFlags: UINT, dwItem1: LPCVOID, dwItem2: LPCVOID) --- + SHChangeNotify :: proc(wEventId: LONG, uFlags: UINT, dwItem1: LPCVOID, dwItem2: LPCVOID) --- SHGetKnownFolderIDList :: proc(rfid: REFKNOWNFOLDERID, dwFlags: /* KNOWN_FOLDER_FLAG */ DWORD, hToken: HANDLE, ppidl: rawptr) -> HRESULT --- - SHSetKnownFolderPath :: proc(rfid: REFKNOWNFOLDERID, dwFlags: /* KNOWN_FOLDER_FLAG */ DWORD, hToken: HANDLE, pszPath: PCWSTR ) -> HRESULT --- - SHGetKnownFolderPath :: proc(rfid: REFKNOWNFOLDERID, dwFlags: /* KNOWN_FOLDER_FLAG */ DWORD, hToken: HANDLE, ppszPath: ^LPWSTR) -> HRESULT --- + SHSetKnownFolderPath :: proc(rfid: REFKNOWNFOLDERID, dwFlags: /* KNOWN_FOLDER_FLAG */ DWORD, hToken: HANDLE, pszPath: PCWSTR ) -> HRESULT --- + SHGetKnownFolderPath :: proc(rfid: REFKNOWNFOLDERID, dwFlags: /* KNOWN_FOLDER_FLAG */ DWORD, hToken: HANDLE, ppszPath: ^LPWSTR) -> HRESULT --- - ExtractIconExW :: proc(pszFile: LPCWSTR, nIconIndex: INT, phiconLarge: ^HICON, phiconSmall: ^HICON, nIcons: UINT) -> UINT --- + ExtractIconExW :: proc(pszFile: LPCWSTR, nIconIndex: INT, phiconLarge: ^HICON, phiconSmall: ^HICON, nIcons: UINT) -> UINT --- DragAcceptFiles :: proc(hWnd: HWND, fAccept: BOOL) --- - DragQueryPoint :: proc(hDrop: HDROP, ppt: ^POINT) -> BOOL --- - DragQueryFileW :: proc(hDrop: HDROP, iFile: UINT, lpszFile: LPWSTR, cch: UINT) -> UINT --- - DragFinish :: proc(hDrop: HDROP) --- // @New + DragQueryPoint :: proc(hDrop: HDROP, ppt: ^POINT) -> BOOL --- + DragQueryFileW :: proc(hDrop: HDROP, iFile: UINT, lpszFile: LPWSTR, cch: UINT) -> UINT --- + DragFinish :: proc(hDrop: HDROP) --- // @New } APPBARDATA :: struct { - cbSize: DWORD, - hWnd: HWND, + cbSize: DWORD, + hWnd: HWND, uCallbackMessage: UINT, - uEdge: UINT, - rc: RECT, - lParam: LPARAM, + uEdge: UINT, + rc: RECT, + lParam: LPARAM, } PAPPBARDATA :: ^APPBARDATA diff --git a/core/sys/windows/tlhelp.odin b/core/sys/windows/tlhelp.odin index 006c9c330..b23b4b06a 100644 --- a/core/sys/windows/tlhelp.odin +++ b/core/sys/windows/tlhelp.odin @@ -5,22 +5,22 @@ foreign import kernel32 "system:Kernel32.lib" @(default_calling_convention="system") foreign kernel32 { - CreateToolhelp32Snapshot :: proc (dwFlags: DWORD, th32ProcessID: DWORD) -> HANDLE --- - Process32FirstW :: proc (hSnapshot: HANDLE, lppe: LPPROCESSENTRY32W) -> BOOL --- - Process32NextW :: proc (hSnapshot: HANDLE, lppe: LPPROCESSENTRY32W) -> BOOL --- - Thread32First :: proc (hSnapshot: HANDLE, lpte: LPTHREADENTRY32) -> BOOL --- - Thread32Next :: proc (hSnapshot: HANDLE, lpte: LPTHREADENTRY32) -> BOOL --- - Module32FirstW :: proc (hSnapshot: HANDLE, lpme: LPMODULEENTRY32W) -> BOOL --- - Module32NextW :: proc (hSnapshot: HANDLE, lpme: LPMODULEENTRY32W) -> BOOL --- - Heap32ListFirst :: proc (hSnapshot: HANDLE, lphl: LPHEAPLIST32) -> BOOL --- - Heap32ListNext :: proc (hSnapshot: HANDLE, lphl: LPHEAPLIST32) -> BOOL --- - Heap32First :: proc (lphe: LPHEAPENTRY32, th32ProcessID: DWORD, th32HeapID: ULONG_PTR) -> BOOL --- - Heap32Next :: proc (lphe: LPHEAPENTRY32) -> BOOL --- - Toolhelp32ReadProcessMemory :: proc ( - th32ProcessID: DWORD, - lpBaseAddress: LPCVOID, - lpBuffer: LPVOID, - cbRead: SIZE_T, + CreateToolhelp32Snapshot :: proc(dwFlags: DWORD, th32ProcessID: DWORD) -> HANDLE --- + Process32FirstW :: proc(hSnapshot: HANDLE, lppe: LPPROCESSENTRY32W) -> BOOL --- + Process32NextW :: proc(hSnapshot: HANDLE, lppe: LPPROCESSENTRY32W) -> BOOL --- + Thread32First :: proc(hSnapshot: HANDLE, lpte: LPTHREADENTRY32) -> BOOL --- + Thread32Next :: proc(hSnapshot: HANDLE, lpte: LPTHREADENTRY32) -> BOOL --- + Module32FirstW :: proc(hSnapshot: HANDLE, lpme: LPMODULEENTRY32W) -> BOOL --- + Module32NextW :: proc(hSnapshot: HANDLE, lpme: LPMODULEENTRY32W) -> BOOL --- + Heap32ListFirst :: proc(hSnapshot: HANDLE, lphl: LPHEAPLIST32) -> BOOL --- + Heap32ListNext :: proc(hSnapshot: HANDLE, lphl: LPHEAPLIST32) -> BOOL --- + Heap32First :: proc(lphe: LPHEAPENTRY32, th32ProcessID: DWORD, th32HeapID: ULONG_PTR) -> BOOL --- + Heap32Next :: proc(lphe: LPHEAPENTRY32) -> BOOL --- + Toolhelp32ReadProcessMemory :: proc( + th32ProcessID: DWORD, + lpBaseAddress: LPCVOID, + lpBuffer: LPVOID, + cbRead: SIZE_T, lpNumberOfBytesRead: ^SIZE_T, ) -> BOOL --- } @@ -36,66 +36,66 @@ TH32CS_SNAPMODULE32 :: 0x00000010 TH32CS_SNAPALL :: TH32CS_SNAPHEAPLIST | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD | TH32CS_SNAPMODULE PROCESSENTRY32W :: struct { - dwSize: DWORD, - cntUsage: DWORD, - th32ProcessID: DWORD, - th32DefaultHeapID: ULONG_PTR, - th32ModuleID: DWORD, - cntThreads: DWORD, + dwSize: DWORD, + cntUsage: DWORD, + th32ProcessID: DWORD, + th32DefaultHeapID: ULONG_PTR, + th32ModuleID: DWORD, + cntThreads: DWORD, th32ParentProcessID: DWORD, - pcPriClassBase: LONG, - dwFlags: DWORD, - szExeFile: [MAX_PATH]WCHAR, + pcPriClassBase: LONG, + dwFlags: DWORD, + szExeFile: [MAX_PATH]WCHAR, } LPPROCESSENTRY32W :: ^PROCESSENTRY32W THREADENTRY32 :: struct { - dwSize: DWORD, - cntUsage: DWORD, - th32ThreadID: DWORD, + dwSize: DWORD, + cntUsage: DWORD, + th32ThreadID: DWORD, th32OwnerProcessID: DWORD, - tpBasePri: LONG, - tpDeltaPri: LONG, - dwFlags: DWORD, + tpBasePri: LONG, + tpDeltaPri: LONG, + dwFlags: DWORD, } LPTHREADENTRY32 :: ^THREADENTRY32 MODULEENTRY32W :: struct { - dwSize: DWORD, - th32ModuleID: DWORD, + dwSize: DWORD, + th32ModuleID: DWORD, th32ProcessID: DWORD, - GlblcntUsage: DWORD, - ProccntUsage: DWORD, - modBaseAddr: ^BYTE, - modBaseSize: DWORD, - hModule: HMODULE, - szModule: [MAX_MODULE_NAME32 + 1]WCHAR, - szExePath: [MAX_PATH]WCHAR, + GlblcntUsage: DWORD, + ProccntUsage: DWORD, + modBaseAddr: ^BYTE, + modBaseSize: DWORD, + hModule: HMODULE, + szModule: [MAX_MODULE_NAME32 + 1]WCHAR, + szExePath: [MAX_PATH]WCHAR, } LPMODULEENTRY32W :: ^MODULEENTRY32W HEAPLIST32 :: struct { - dwSize: SIZE_T, + dwSize: SIZE_T, th32ProcessID: DWORD, - th32HeapID: ULONG_PTR, - dwFlags: DWORD, + th32HeapID: ULONG_PTR, + dwFlags: DWORD, } LPHEAPLIST32 :: ^HEAPLIST32 HEAPENTRY32 :: struct { - dwSize: SIZE_T, - hHandle: HANDLE, - dwAddress: ULONG_PTR, - dwBlockSize: SIZE_T, - dwFlags: DWORD, - dwLockCount: DWORD, - dwResvd: DWORD, + dwSize: SIZE_T, + hHandle: HANDLE, + dwAddress: ULONG_PTR, + dwBlockSize: SIZE_T, + dwFlags: DWORD, + dwLockCount: DWORD, + dwResvd: DWORD, th32ProcessID: DWORD, - th32HeapID: ULONG_PTR, + th32HeapID: ULONG_PTR, } LPHEAPENTRY32 :: ^HEAPENTRY32 diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index 904970589..f9e9764e2 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -15,75 +15,75 @@ c_ushort :: c.ushort size_t :: c.size_t wchar_t :: c.wchar_t -DWORD :: c_ulong -DWORDLONG :: c.ulonglong -QWORD :: c.ulonglong -HANDLE :: distinct LPVOID -PHANDLE :: ^HANDLE -HINSTANCE :: HANDLE -HMODULE :: distinct HINSTANCE -HRESULT :: distinct LONG -HWND :: distinct HANDLE -HDC :: distinct HANDLE -HMONITOR :: distinct HANDLE -HICON :: distinct HANDLE -HCURSOR :: distinct HANDLE -HMENU :: distinct HANDLE -HBRUSH :: distinct HANDLE -HPEN :: distinct HANDLE -HGDIOBJ :: distinct HANDLE -HBITMAP :: distinct HANDLE -HPALETTE :: distinct HANDLE -HGLOBAL :: distinct HANDLE -HHOOK :: distinct HANDLE -HWINEVENTHOOK :: distinct HANDLE -HKEY :: distinct HANDLE -HDESK :: distinct HANDLE -HFONT :: distinct HANDLE -HRGN :: distinct HANDLE -HRSRC :: distinct HANDLE -HWINSTA :: distinct HANDLE -HACCEL :: distinct HANDLE -BOOL :: distinct b32 -BYTE :: distinct u8 -BOOLEAN :: distinct b8 -GROUP :: distinct c_uint -LARGE_INTEGER :: distinct c_longlong -ULARGE_INTEGER :: distinct c_ulonglong +DWORD :: c_ulong +DWORDLONG :: c.ulonglong +QWORD :: c.ulonglong +HANDLE :: distinct LPVOID +PHANDLE :: ^HANDLE +HINSTANCE :: HANDLE +HMODULE :: distinct HINSTANCE +HRESULT :: distinct LONG +HWND :: distinct HANDLE +HDC :: distinct HANDLE +HMONITOR :: distinct HANDLE +HICON :: distinct HANDLE +HCURSOR :: distinct HANDLE +HMENU :: distinct HANDLE +HBRUSH :: distinct HANDLE +HPEN :: distinct HANDLE +HGDIOBJ :: distinct HANDLE +HBITMAP :: distinct HANDLE +HPALETTE :: distinct HANDLE +HGLOBAL :: distinct HANDLE +HHOOK :: distinct HANDLE +HWINEVENTHOOK :: distinct HANDLE +HKEY :: distinct HANDLE +HDESK :: distinct HANDLE +HFONT :: distinct HANDLE +HRGN :: distinct HANDLE +HRSRC :: distinct HANDLE +HWINSTA :: distinct HANDLE +HACCEL :: distinct HANDLE +BOOL :: distinct b32 +BYTE :: distinct u8 +BOOLEAN :: distinct b8 +GROUP :: distinct c_uint +LARGE_INTEGER :: distinct c_longlong +ULARGE_INTEGER :: distinct c_ulonglong PULARGE_INTEGER :: ^ULARGE_INTEGER -LONG :: c_long -UINT :: c_uint -INT :: c_int -SHORT :: c_short -USHORT :: c_ushort -WCHAR :: wchar_t -SIZE_T :: uint -PSIZE_T :: ^SIZE_T -WORD :: u16 -CHAR :: c_char -ULONG_PTR :: uint -PULONG_PTR :: ^ULONG_PTR -LPULONG_PTR :: ^ULONG_PTR -DWORD_PTR :: ULONG_PTR -LONG_PTR :: int -INT_PTR :: int -UINT_PTR :: uintptr -ULONG :: c_ulong -ULONGLONG :: c_ulonglong -LONGLONG :: c_longlong -UCHAR :: BYTE -NTSTATUS :: c.long -COLORREF :: DWORD -LPCOLORREF :: ^COLORREF -LPARAM :: LONG_PTR -WPARAM :: UINT_PTR -LRESULT :: LONG_PTR -LPRECT :: ^RECT -LPPOINT :: ^POINT -LSTATUS :: LONG -PHKEY :: ^HKEY -PUSHORT :: ^USHORT -PCHAR :: ^CHAR +LONG :: c_long +UINT :: c_uint +INT :: c_int +SHORT :: c_short +USHORT :: c_ushort +WCHAR :: wchar_t +SIZE_T :: uint +PSIZE_T :: ^SIZE_T +WORD :: u16 +CHAR :: c_char +ULONG_PTR :: uint +PULONG_PTR :: ^ULONG_PTR +LPULONG_PTR :: ^ULONG_PTR +DWORD_PTR :: ULONG_PTR +LONG_PTR :: int +INT_PTR :: int +UINT_PTR :: uintptr +ULONG :: c_ulong +ULONGLONG :: c_ulonglong +LONGLONG :: c_longlong +UCHAR :: BYTE +NTSTATUS :: c.long +COLORREF :: DWORD +LPCOLORREF :: ^COLORREF +LPARAM :: LONG_PTR +WPARAM :: UINT_PTR +LRESULT :: LONG_PTR +LPRECT :: ^RECT +LPPOINT :: ^POINT +LSTATUS :: LONG +PHKEY :: ^HKEY +PUSHORT :: ^USHORT +PCHAR :: ^CHAR UINT8 :: u8 UINT16 :: u16 @@ -101,68 +101,86 @@ LONG32 :: i32 ULONG64 :: u64 LONG64 :: i64 -DWORD64 :: u64 +DWORD64 :: u64 PDWORD64 :: ^DWORD64 PDWORD_PTR :: ^DWORD_PTR -ATOM :: distinct WORD +ATOM :: distinct WORD wstring :: cstring16 PWSTR :: cstring16 -PBYTE :: ^BYTE -LPBYTE :: ^BYTE -PBOOL :: ^BOOL -LPBOOL :: ^BOOL -LPCSTR :: cstring -LPCWSTR :: wstring -LPCTSTR :: wstring -LPDWORD :: ^DWORD -PCSTR :: cstring -PCWSTR :: wstring -PDWORD :: ^DWORD -LPHANDLE :: ^HANDLE -LPOVERLAPPED :: ^OVERLAPPED +PBYTE :: ^BYTE +LPBYTE :: ^BYTE +PBOOL :: ^BOOL +LPBOOL :: ^BOOL +LPCSTR :: cstring +LPCWSTR :: wstring +LPCTSTR :: wstring +LPDWORD :: ^DWORD +PCSTR :: cstring +PCWSTR :: wstring +PDWORD :: ^DWORD +LPHANDLE :: ^HANDLE +LPOVERLAPPED :: ^OVERLAPPED LPPROCESS_INFORMATION :: ^PROCESS_INFORMATION -PSECURITY_ATTRIBUTES :: ^SECURITY_ATTRIBUTES +PSECURITY_ATTRIBUTES :: ^SECURITY_ATTRIBUTES LPSECURITY_ATTRIBUTES :: ^SECURITY_ATTRIBUTES -LPSTARTUPINFOW :: ^STARTUPINFOW -LPTRACKMOUSEEVENT :: ^TRACKMOUSEEVENT -VOID :: rawptr -PVOID :: rawptr -LPVOID :: rawptr -PINT :: ^INT -LPINT :: ^INT -PUINT :: ^UINT -LPUINT :: ^UINT -LPWCH :: ^WCHAR -LPWORD :: ^WORD -PULONG :: ^ULONG -LPWIN32_FIND_DATAW :: ^WIN32_FIND_DATAW -LPWSADATA :: ^WSADATA -LPWSAPROTOCOL_INFO :: ^WSAPROTOCOL_INFO -LPSTR :: ^CHAR -LPWSTR :: ^WCHAR -OLECHAR :: WCHAR -BSTR :: ^OLECHAR -LPOLESTR :: cstring16 -LPCOLESTR :: LPCSTR -LPFILETIME :: ^FILETIME -LPWSABUF :: ^WSABUF -LPWSAOVERLAPPED :: distinct rawptr -LPWSAOVERLAPPED_COMPLETION_ROUTINE :: distinct rawptr -LPCVOID :: rawptr -SCODE :: LONG -PSCODE :: ^SCODE +LPSTARTUPINFOW :: ^STARTUPINFOW +LPTRACKMOUSEEVENT :: ^TRACKMOUSEEVENT +VOID :: rawptr +PVOID :: rawptr +LPVOID :: rawptr +PINT :: ^INT +LPINT :: ^INT +PUINT :: ^UINT +LPUINT :: ^UINT +LPWCH :: ^WCHAR +LPWORD :: ^WORD +PULONG :: ^ULONG +LPWIN32_FIND_DATAW :: ^WIN32_FIND_DATAW +LPWSADATA :: ^WSADATA +LPWSAPROTOCOL_INFO :: ^WSAPROTOCOL_INFO +LPSTR :: ^CHAR +LPWSTR :: ^WCHAR +OLECHAR :: WCHAR +BSTR :: ^OLECHAR -PACCESS_TOKEN :: PVOID +LPOLESTR :: cstring16 +LPCOLESTR :: LPCSTR +LPFILETIME :: ^FILETIME +LPWSABUF :: ^WSABUF + +WSAEVENT :: HANDLE + +WSAOVERLAPPED :: struct { + Internal: DWORD, + InternalHigh: DWORD, + Offset: DWORD, + OffsetHigh: DWORD, + hEvent: WSAEVENT, +} + +LPWSAOVERLAPPED :: ^WSAOVERLAPPED +LPWSAOVERLAPPED_COMPLETION_ROUTINE :: #type proc "system" ( + dwError: DWORD, + cbTransferred: DWORD, + lpOverlapped: LPWSAOVERLAPPED, + dwFlags: DWORD, +) + +LPCVOID :: rawptr +SCODE :: LONG +PSCODE :: ^SCODE + +PACCESS_TOKEN :: PVOID PSECURITY_DESCRIPTOR :: PVOID -PSID :: PVOID -PCLAIMS_BLOB :: PVOID +PSID :: PVOID +PCLAIMS_BLOB :: PVOID PCONDITION_VARIABLE :: ^CONDITION_VARIABLE -PLARGE_INTEGER :: ^LARGE_INTEGER -PSRWLOCK :: ^SRWLOCK +PLARGE_INTEGER :: ^LARGE_INTEGER +PSRWLOCK :: ^SRWLOCK CREATE_WAITABLE_TIMER_MANUAL_RESET :: 0x00000001 CREATE_WAITABLE_TIMER_HIGH_RESOLUTION :: 0x00000002 @@ -183,28 +201,28 @@ LPSIZE :: ^SIZE MAXLONG :: 0x7fffffff -FILE_ATTRIBUTE_READONLY: DWORD : 0x00000001 -FILE_ATTRIBUTE_HIDDEN: DWORD : 0x00000002 -FILE_ATTRIBUTE_SYSTEM: DWORD : 0x00000004 -FILE_ATTRIBUTE_DIRECTORY: DWORD : 0x00000010 -FILE_ATTRIBUTE_ARCHIVE: DWORD : 0x00000020 -FILE_ATTRIBUTE_DEVICE: DWORD : 0x00000040 -FILE_ATTRIBUTE_NORMAL: DWORD : 0x00000080 -FILE_ATTRIBUTE_TEMPORARY: DWORD : 0x00000100 -FILE_ATTRIBUTE_SPARSE_FILE: DWORD : 0x00000200 -FILE_ATTRIBUTE_REPARSE_Point: DWORD : 0x00000400 -FILE_ATTRIBUTE_REPARSE_POINT: DWORD : 0x00000400 -FILE_ATTRIBUTE_COMPRESSED: DWORD : 0x00000800 -FILE_ATTRIBUTE_OFFLINE: DWORD : 0x00001000 -FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: DWORD : 0x00002000 -FILE_ATTRIBUTE_ENCRYPTED: DWORD : 0x00004000 +FILE_ATTRIBUTE_READONLY : DWORD : 0x00000001 +FILE_ATTRIBUTE_HIDDEN : DWORD : 0x00000002 +FILE_ATTRIBUTE_SYSTEM : DWORD : 0x00000004 +FILE_ATTRIBUTE_DIRECTORY : DWORD : 0x00000010 +FILE_ATTRIBUTE_ARCHIVE : DWORD : 0x00000020 +FILE_ATTRIBUTE_DEVICE : DWORD : 0x00000040 +FILE_ATTRIBUTE_NORMAL : DWORD : 0x00000080 +FILE_ATTRIBUTE_TEMPORARY : DWORD : 0x00000100 +FILE_ATTRIBUTE_SPARSE_FILE : DWORD : 0x00000200 +FILE_ATTRIBUTE_REPARSE_Point : DWORD : 0x00000400 +FILE_ATTRIBUTE_REPARSE_POINT : DWORD : 0x00000400 +FILE_ATTRIBUTE_COMPRESSED : DWORD : 0x00000800 +FILE_ATTRIBUTE_OFFLINE : DWORD : 0x00001000 +FILE_ATTRIBUTE_NOT_CONTENT_INDEXED : DWORD : 0x00002000 +FILE_ATTRIBUTE_ENCRYPTED : DWORD : 0x00004000 -FILE_SHARE_READ: DWORD : 0x00000001 -FILE_SHARE_WRITE: DWORD : 0x00000002 -FILE_SHARE_DELETE: DWORD : 0x00000004 -FILE_GENERIC_ALL: DWORD : 0x10000000 -FILE_GENERIC_EXECUTE: DWORD : 0x20000000 -FILE_GENERIC_READ: DWORD : 0x80000000 +FILE_SHARE_READ : DWORD : 0x00000001 +FILE_SHARE_WRITE : DWORD : 0x00000002 +FILE_SHARE_DELETE : DWORD : 0x00000004 +FILE_GENERIC_ALL : DWORD : 0x10000000 +FILE_GENERIC_EXECUTE : DWORD : 0x20000000 +FILE_GENERIC_READ : DWORD : 0x80000000 FILE_ALL_ACCESS :: STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF FILE_ACTION_ADDED :: 0x00000001 @@ -222,11 +240,11 @@ FILE_NOTIFY_CHANGE_LAST_ACCESS :: 0x00000020 FILE_NOTIFY_CHANGE_CREATION :: 0x00000040 FILE_NOTIFY_CHANGE_SECURITY :: 0x00000100 -CREATE_NEW: DWORD : 1 -CREATE_ALWAYS: DWORD : 2 -OPEN_ALWAYS: DWORD : 4 -OPEN_EXISTING: DWORD : 3 -TRUNCATE_EXISTING: DWORD : 5 +CREATE_NEW : DWORD : 1 +CREATE_ALWAYS : DWORD : 2 +OPEN_ALWAYS : DWORD : 4 +OPEN_EXISTING : DWORD : 3 +TRUNCATE_EXISTING : DWORD : 5 FILE_READ_DATA : DWORD : 0x00000001 FILE_LIST_DIRECTORY : DWORD : 0x00000001 @@ -248,11 +266,12 @@ GENERIC_WRITE : DWORD : 0x40000000 GENERIC_EXECUTE : DWORD : 0x20000000 GENERIC_ALL : DWORD : 0x10000000 -FILE_GENERIC_WRITE: DWORD : STANDARD_RIGHTS_WRITE | - FILE_WRITE_DATA | +FILE_GENERIC_WRITE : DWORD : \ + STANDARD_RIGHTS_WRITE | + FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | - FILE_WRITE_EA | - FILE_APPEND_DATA | + FILE_WRITE_EA | + FILE_APPEND_DATA | SYNCHRONIZE SECURITY_SQOS_PRESENT: DWORD : 0x00100000 @@ -274,7 +293,7 @@ PROTECTED_SACL_SECURITY_INFORMATION :: 0x40000000 UNPROTECTED_DACL_SECURITY_INFORMATION :: 0x20000000 UNPROTECTED_SACL_SECURITY_INFORMATION :: 0x10000000 -GET_FILEEX_INFO_LEVELS :: distinct i32 +GET_FILEEX_INFO_LEVELS :: distinct c_int GetFileExInfoStandard: GET_FILEEX_INFO_LEVELS : 0 GetFileExMaxInfoLevel: GET_FILEEX_INFO_LEVELS : 1 @@ -297,13 +316,13 @@ POWER_REQUEST_CONTEXT_DETAILED_STRING :: DIAGNOSTIC_REASON_DETAILED_STRING REASON_CONTEXT :: struct { Version: ULONG, - Flags: DWORD, + Flags: DWORD, Reason: struct #raw_union { Detailed: struct { LocalizedReasonModule: HMODULE, - LocalizedReasonId: ULONG, - ReasonStringCount: ULONG, - ReasonStrings: ^LPWSTR, + LocalizedReasonId: ULONG, + ReasonStringCount: ULONG, + ReasonStrings: [^]LPWSTR `fmt:"v,ReasonStringCount"`, }, SimpleReasonString: LPWSTR, }, @@ -324,9 +343,9 @@ RRF_RT_ANY :: 0x0000ffff RRF_NOEXPAND :: 0x10000000 RRF_ZEROONFAILURE :: 0x20000000 -ACCESS_MASK :: DWORD +ACCESS_MASK :: DWORD PACCESS_MASK :: ^ACCESS_MASK -REGSAM :: ACCESS_MASK +REGSAM :: ACCESS_MASK // Reserved Key Handles. HKEY_CLASSES_ROOT :: HKEY(uintptr(0x80000000)) @@ -368,12 +387,13 @@ KEY_WOW64_RES :: 0x0300 KEY_READ :: (STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY) & (~SYNCHRONIZE) KEY_WRITE :: (STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & (~SYNCHRONIZE) KEY_EXECUTE :: (KEY_READ) & (~SYNCHRONIZE) -KEY_ALL_ACCESS :: (STANDARD_RIGHTS_ALL | - KEY_QUERY_VALUE | - KEY_SET_VALUE | - KEY_CREATE_SUB_KEY | +KEY_ALL_ACCESS :: ( + STANDARD_RIGHTS_ALL | + KEY_QUERY_VALUE | + KEY_SET_VALUE | + KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | - KEY_NOTIFY | + KEY_NOTIFY | KEY_CREATE_LINK) & (~SYNCHRONIZE) // Open/Create Options @@ -385,17 +405,19 @@ REG_OPTION_BACKUP_RESTORE :: 0x00000004 REG_OPTION_OPEN_LINK :: 0x00000008 REG_OPTION_DONT_VIRTUALIZE :: 0x00000010 -REG_LEGAL_OPTION :: REG_OPTION_RESERVED | - REG_OPTION_NON_VOLATILE | - REG_OPTION_VOLATILE | - REG_OPTION_CREATE_LINK | +REG_LEGAL_OPTION :: \ + REG_OPTION_RESERVED | + REG_OPTION_NON_VOLATILE | + REG_OPTION_VOLATILE | + REG_OPTION_CREATE_LINK | REG_OPTION_BACKUP_RESTORE | - REG_OPTION_OPEN_LINK | + REG_OPTION_OPEN_LINK | REG_OPTION_DONT_VIRTUALIZE -REG_OPEN_LEGAL_OPTION :: REG_OPTION_RESERVED | +REG_OPEN_LEGAL_OPTION :: \ + REG_OPTION_RESERVED | REG_OPTION_BACKUP_RESTORE | - REG_OPTION_OPEN_LINK | + REG_OPTION_OPEN_LINK | REG_OPTION_DONT_VIRTUALIZE // Key creation/open disposition @@ -437,10 +459,11 @@ REG_NOTIFY_CHANGE_LAST_SET :: 0x00000004 REG_NOTIFY_CHANGE_SECURITY :: 0x00000008 REG_NOTIFY_THREAD_AGNOSTIC :: 0x10000000 -REG_LEGAL_CHANGE_FILTER :: REG_NOTIFY_CHANGE_NAME | +REG_LEGAL_CHANGE_FILTER :: \ + REG_NOTIFY_CHANGE_NAME | REG_NOTIFY_CHANGE_ATTRIBUTES | - REG_NOTIFY_CHANGE_LAST_SET | - REG_NOTIFY_CHANGE_SECURITY | + REG_NOTIFY_CHANGE_LAST_SET | + REG_NOTIFY_CHANGE_SECURITY | REG_NOTIFY_THREAD_AGNOSTIC // Predefined Value Types. @@ -461,9 +484,9 @@ REG_QWORD_LITTLE_ENDIAN :: 11 BSMINFO :: struct { cbSize: UINT, - hdesk: HDESK, - hwnd: HWND, - luid: LUID, + hdesk: HDESK, + hwnd: HWND, + luid: LUID, } PBSMINFO :: ^BSMINFO @@ -545,37 +568,37 @@ COLOR_BTNHILIGHT :: COLOR_BTNHIGHLIGHT // Common Control Notification Code Ranges NM_FIRST :: 0 -NM_LAST :: ~DWORD(99 - 1) -LVN_FIRST :: ~DWORD(100 - 1) -LVN_LAST :: ~DWORD(199 - 1) -HDN_FIRST :: ~DWORD(300 - 1) -HDN_LAST :: ~DWORD(399 - 1) -TVN_FIRST :: ~DWORD(400 - 1) -TVN_LAST :: ~DWORD(499 - 1) -TTN_FIRST :: ~DWORD(520 - 1) -TTN_LAST :: ~DWORD(549 - 1) -TCN_FIRST :: ~DWORD(550 - 1) -TCN_LAST :: ~DWORD(580 - 1) -CDN_FIRST :: ~DWORD(601 - 1) -CDN_LAST :: ~DWORD(699 - 1) -TBN_FIRST :: ~DWORD(700 - 1) -TBN_LAST :: ~DWORD(720 - 1) -UDN_FIRST :: ~DWORD(721 - 1) -UDN_LAST :: ~DWORD(740 - 1) -MCN_FIRST :: ~DWORD(750 - 1) -MCN_LAST :: ~DWORD(759 - 1) -DTN_FIRST :: ~DWORD(760 - 1) -DTN_LAST :: ~DWORD(799 - 1) -CBEN_FIRST :: ~DWORD(800 - 1) -CBEN_LAST :: ~DWORD(830 - 1) -RBN_FIRST :: ~DWORD(831 - 1) -RBN_LAST :: ~DWORD(859 - 1) -IPN_FIRST :: ~DWORD(860 - 1) -IPN_LAST :: ~DWORD(879 - 1) -SBN_FIRST :: ~DWORD(880 - 1) -SBN_LAST :: ~DWORD(899 - 1) -PGN_FIRST :: ~DWORD(900 - 1) -PGN_LAST :: ~DWORD(950 - 1) +NM_LAST :: ~DWORD( 99 - 1) +LVN_FIRST :: ~DWORD( 100 - 1) +LVN_LAST :: ~DWORD( 199 - 1) +HDN_FIRST :: ~DWORD( 300 - 1) +HDN_LAST :: ~DWORD( 399 - 1) +TVN_FIRST :: ~DWORD( 400 - 1) +TVN_LAST :: ~DWORD( 499 - 1) +TTN_FIRST :: ~DWORD( 520 - 1) +TTN_LAST :: ~DWORD( 549 - 1) +TCN_FIRST :: ~DWORD( 550 - 1) +TCN_LAST :: ~DWORD( 580 - 1) +CDN_FIRST :: ~DWORD( 601 - 1) +CDN_LAST :: ~DWORD( 699 - 1) +TBN_FIRST :: ~DWORD( 700 - 1) +TBN_LAST :: ~DWORD( 720 - 1) +UDN_FIRST :: ~DWORD( 721 - 1) +UDN_LAST :: ~DWORD( 740 - 1) +MCN_FIRST :: ~DWORD( 750 - 1) +MCN_LAST :: ~DWORD( 759 - 1) +DTN_FIRST :: ~DWORD( 760 - 1) +DTN_LAST :: ~DWORD( 799 - 1) +CBEN_FIRST :: ~DWORD( 800 - 1) +CBEN_LAST :: ~DWORD( 830 - 1) +RBN_FIRST :: ~DWORD( 831 - 1) +RBN_LAST :: ~DWORD( 859 - 1) +IPN_FIRST :: ~DWORD( 860 - 1) +IPN_LAST :: ~DWORD( 879 - 1) +SBN_FIRST :: ~DWORD( 880 - 1) +SBN_LAST :: ~DWORD( 899 - 1) +PGN_FIRST :: ~DWORD( 900 - 1) +PGN_LAST :: ~DWORD( 950 - 1) WMN_FIRST :: ~DWORD(1000 - 1) WMN_LAST :: ~DWORD(1200 - 1) BCN_FIRST :: ~DWORD(1250 - 1) @@ -1255,61 +1278,61 @@ HOOKPROC :: #type proc "system" (code: c_int, wParam: WPARAM, lParam: LPARAM) -> WINEVENTPROC :: #type proc "system" ( hWinEventHook: HWINEVENTHOOK, - event: DWORD, - hwnd: HWND, - idObject, idChild: LONG, + event: DWORD, + hwnd: HWND, + idObject, idChild: LONG, idEventThread, dwmsEventTime: DWORD, ) CWPRETSTRUCT :: struct { lResult: LRESULT, - lParam: LPARAM, - wParam: WPARAM, + lParam: LPARAM, + wParam: WPARAM, message: UINT, - hwnd: HWND, + hwnd: HWND, } MSLLHOOKSTRUCT :: struct { - pt: POINT, - mouseData: DWORD, - flags: DWORD, - time: DWORD, + pt: POINT, + mouseData: DWORD, + flags: DWORD, + time: DWORD, dwExtraInfo: ULONG_PTR, } KBDLLHOOKSTRUCT :: struct { - vkCode: DWORD, - scanCode: DWORD, - flags: DWORD, - time: DWORD, + vkCode: DWORD, + scanCode: DWORD, + flags: DWORD, + time: DWORD, dwExtraInfo: ULONG_PTR, } MOUSEINPUT :: struct { - dx: LONG, - dy: LONG, - mouseData: DWORD, - dwFlags: DWORD, - time: DWORD, + dx: LONG, + dy: LONG, + mouseData: DWORD, + dwFlags: DWORD, + time: DWORD, dwExtraInfo: ULONG_PTR, } KEYBDINPUT :: struct { - wVk: WORD, - wScan: WORD, - dwFlags: DWORD, - time: DWORD, + wVk: WORD, + wScan: WORD, + dwFlags: DWORD, + time: DWORD, dwExtraInfo: ULONG_PTR, } HARDWAREINPUT :: struct { - uMsg: DWORD, + uMsg: DWORD, wParamL: WORD, wParamH: WORD, } INPUT_TYPE :: enum DWORD { - MOUSE = 0, + MOUSE = 0, KEYBOARD = 1, HARDWARE = 2, } @@ -1317,128 +1340,128 @@ INPUT_TYPE :: enum DWORD { INPUT :: struct { type: INPUT_TYPE, using _: struct #raw_union { - mi: MOUSEINPUT, - ki: KEYBDINPUT, - hi: HARDWAREINPUT, + mi: MOUSEINPUT `raw_union_tag:"type=MOUSE"`, + ki: KEYBDINPUT `raw_union_tag:"type=KEYBOARD"`, + hi: HARDWAREINPUT `raw_union_tag:"type=HARDWARE"`, }, } -MOUSEEVENTF_MOVE :: 0x0001 -MOUSEEVENTF_LEFTDOWN :: 0x0002 -MOUSEEVENTF_LEFTUP :: 0x0004 -MOUSEEVENTF_RIGHTDOWN :: 0x0008 -MOUSEEVENTF_RIGHTUP :: 0x0010 -MOUSEEVENTF_MIDDLEDOWN :: 0x0020 -MOUSEEVENTF_MIDDLEUP :: 0x0040 -MOUSEEVENTF_XDOWN :: 0x0080 -MOUSEEVENTF_XUP :: 0x0100 -MOUSEEVENTF_WHEEL :: 0x0800 -MOUSEEVENTF_HWHEEL :: 0x1000 +MOUSEEVENTF_MOVE :: 0x0001 +MOUSEEVENTF_LEFTDOWN :: 0x0002 +MOUSEEVENTF_LEFTUP :: 0x0004 +MOUSEEVENTF_RIGHTDOWN :: 0x0008 +MOUSEEVENTF_RIGHTUP :: 0x0010 +MOUSEEVENTF_MIDDLEDOWN :: 0x0020 +MOUSEEVENTF_MIDDLEUP :: 0x0040 +MOUSEEVENTF_XDOWN :: 0x0080 +MOUSEEVENTF_XUP :: 0x0100 +MOUSEEVENTF_WHEEL :: 0x0800 +MOUSEEVENTF_HWHEEL :: 0x1000 MOUSEEVENTF_MOVE_NOCOALESCE :: 0x2000 -MOUSEEVENTF_VIRTUALDESK :: 0x4000 -MOUSEEVENTF_ABSOLUTE :: 0x8000 +MOUSEEVENTF_VIRTUALDESK :: 0x4000 +MOUSEEVENTF_ABSOLUTE :: 0x8000 WNDCLASSA :: struct { - style: UINT, - lpfnWndProc: WNDPROC, - cbClsExtra: c_int, - cbWndExtra: c_int, - hInstance: HINSTANCE, - hIcon: HICON, - hCursor: HCURSOR, + style: UINT, + lpfnWndProc: WNDPROC, + cbClsExtra: c_int, + cbWndExtra: c_int, + hInstance: HINSTANCE, + hIcon: HICON, + hCursor: HCURSOR, hbrBackground: HBRUSH, - lpszMenuName: LPCSTR, + lpszMenuName: LPCSTR, lpszClassName: LPCSTR, } WNDCLASSW :: struct { - style: UINT, - lpfnWndProc: WNDPROC, - cbClsExtra: c_int, - cbWndExtra: c_int, - hInstance: HINSTANCE, - hIcon: HICON, - hCursor: HCURSOR, + style: UINT, + lpfnWndProc: WNDPROC, + cbClsExtra: c_int, + cbWndExtra: c_int, + hInstance: HINSTANCE, + hIcon: HICON, + hCursor: HCURSOR, hbrBackground: HBRUSH, - lpszMenuName: LPCWSTR, + lpszMenuName: LPCWSTR, lpszClassName: LPCWSTR, } WNDCLASSEXA :: struct { - cbSize: UINT, - style: UINT, - lpfnWndProc: WNDPROC, - cbClsExtra: c_int, - cbWndExtra: c_int, - hInstance: HINSTANCE, - hIcon: HICON, - hCursor: HCURSOR, + cbSize: UINT, + style: UINT, + lpfnWndProc: WNDPROC, + cbClsExtra: c_int, + cbWndExtra: c_int, + hInstance: HINSTANCE, + hIcon: HICON, + hCursor: HCURSOR, hbrBackground: HBRUSH, - lpszMenuName: LPCSTR, + lpszMenuName: LPCSTR, lpszClassName: LPCSTR, - hIconSm: HICON, + hIconSm: HICON, } WNDCLASSEXW :: struct { - cbSize: UINT, - style: UINT, - lpfnWndProc: WNDPROC, - cbClsExtra: c_int, - cbWndExtra: c_int, - hInstance: HINSTANCE, - hIcon: HICON, - hCursor: HCURSOR, + cbSize: UINT, + style: UINT, + lpfnWndProc: WNDPROC, + cbClsExtra: c_int, + cbWndExtra: c_int, + hInstance: HINSTANCE, + hIcon: HICON, + hCursor: HCURSOR, hbrBackground: HBRUSH, - lpszMenuName: LPCWSTR, + lpszMenuName: LPCWSTR, lpszClassName: LPCWSTR, - hIconSm: HICON, + hIconSm: HICON, } MSG :: struct { - hwnd: HWND, + hwnd: HWND, message: UINT, - wParam: WPARAM, - lParam: LPARAM, - time: DWORD, - pt: POINT, + wParam: WPARAM, + lParam: LPARAM, + time: DWORD, + pt: POINT, } LPMSG :: ^MSG NOTIFYICONDATAW :: struct { - cbSize: DWORD, - hWnd: HWND, - uID: UINT, - uFlags: UINT, + cbSize: DWORD, + hWnd: HWND, + uID: UINT, + uFlags: UINT, uCallbackMessage: UINT, - hIcon: HICON, - szTip: [128]WCHAR, - dwState: DWORD, - dwStateMask: DWORD, - szInfo: [256]WCHAR, + hIcon: HICON, + szTip: [128]WCHAR, + dwState: DWORD, + dwStateMask: DWORD, + szInfo: [256]WCHAR, using _: struct #raw_union { uTimeout: UINT, uVersion: UINT, }, - szInfoTitle: [64]WCHAR, - dwInfoFlags: DWORD, - guidItem: GUID, + szInfoTitle: [64]WCHAR, + dwInfoFlags: DWORD, + guidItem: GUID, hBalloonIcon: HICON, } -NIF_MESSAGE :: 0x00000001 -NIF_ICON :: 0x00000002 -NIF_TIP :: 0x00000004 -NIF_STATE :: 0x00000008 -NIF_INFO :: 0x00000010 -NIF_GUID :: 0x00000020 +NIF_MESSAGE :: 0x00000001 +NIF_ICON :: 0x00000002 +NIF_TIP :: 0x00000004 +NIF_STATE :: 0x00000008 +NIF_INFO :: 0x00000010 +NIF_GUID :: 0x00000020 NIF_REALTIME :: 0x00000040 -NIF_SHOWTIP :: 0x00000080 +NIF_SHOWTIP :: 0x00000080 -NIM_ADD :: 0x00000000 -NIM_MODIFY :: 0x00000001 -NIM_DELETE :: 0x00000002 -NIM_SETFOCUS :: 0x00000003 +NIM_ADD :: 0x00000000 +NIM_MODIFY :: 0x00000001 +NIM_DELETE :: 0x00000002 +NIM_SETFOCUS :: 0x00000003 NIM_SETVERSION :: 0x00000004 // Menu flags for Add/Check/EnableMenuItem() @@ -1448,37 +1471,37 @@ MF_APPEND :: 0x00000100 MF_DELETE :: 0x00000200 MF_REMOVE :: 0x00001000 -MF_BYCOMMAND :: 0x00000000 +MF_BYCOMMAND :: 0x00000000 MF_BYPOSITION :: 0x00000400 MF_SEPARATOR :: 0x00000800 -MF_ENABLED :: 0x00000000 -MF_GRAYED :: 0x00000001 +MF_ENABLED :: 0x00000000 +MF_GRAYED :: 0x00000001 MF_DISABLED :: 0x00000002 -MF_UNCHECKED :: 0x00000000 -MF_CHECKED :: 0x00000008 +MF_UNCHECKED :: 0x00000000 +MF_CHECKED :: 0x00000008 MF_USECHECKBITMAPS :: 0x00000200 -MF_STRING :: 0x00000000 -MF_BITMAP :: 0x00000004 +MF_STRING :: 0x00000000 +MF_BITMAP :: 0x00000004 MF_OWNERDRAW :: 0x00000100 -MF_POPUP :: 0x00000010 +MF_POPUP :: 0x00000010 MF_MENUBARBREAK :: 0x00000020 -MF_MENUBREAK :: 0x00000040 +MF_MENUBREAK :: 0x00000040 MF_UNHILITE :: 0x00000000 -MF_HILITE :: 0x00000080 +MF_HILITE :: 0x00000080 -MF_DEFAULT :: 0x00001000 -MF_SYSMENU :: 0x00002000 -MF_HELP :: 0x00004000 +MF_DEFAULT :: 0x00001000 +MF_SYSMENU :: 0x00002000 +MF_HELP :: 0x00004000 MF_RIGHTJUSTIFY :: 0x00004000 MF_MOUSESELECT :: 0x00008000 -MF_END :: 0x00000080 // Obsolete -- only used by old RES files +MF_END :: 0x00000080 // Obsolete -- only used by old RES files // Menu flags for Add/Check/EnableMenuItem() MFS_GRAYED :: 0x00000003 @@ -1491,27 +1514,27 @@ MFS_UNHILITE :: MF_UNHILITE MFS_DEFAULT :: MF_DEFAULT // Flags for TrackPopupMenu -TPM_LEFTBUTTON :: 0x0000 -TPM_RIGHTBUTTON :: 0x0002 -TPM_LEFTALIGN :: 0x0000 -TPM_CENTERALIGN :: 0x0004 -TPM_RIGHTALIGN :: 0x0008 -TPM_TOPALIGN :: 0x0000 +TPM_LEFTBUTTON :: 0x0000 +TPM_RIGHTBUTTON :: 0x0002 +TPM_LEFTALIGN :: 0x0000 +TPM_CENTERALIGN :: 0x0004 +TPM_RIGHTALIGN :: 0x0008 +TPM_TOPALIGN :: 0x0000 TPM_VCENTERALIGN :: 0x0010 -TPM_BOTTOMALIGN :: 0x0020 +TPM_BOTTOMALIGN :: 0x0020 -TPM_HORIZONTAL :: 0x0000 /* Horz alignment matters more */ -TPM_VERTICAL :: 0x0040 /* Vert alignment matters more */ -TPM_NONOTIFY :: 0x0080 /* Don't send any notification msgs */ -TPM_RETURNCMD :: 0x0100 -TPM_RECURSE :: 0x0001 +TPM_HORIZONTAL :: 0x0000 /* Horz alignment matters more */ +TPM_VERTICAL :: 0x0040 /* Vert alignment matters more */ +TPM_NONOTIFY :: 0x0080 /* Don't send any notification msgs */ +TPM_RETURNCMD :: 0x0100 +TPM_RECURSE :: 0x0001 TPM_HORPOSANIMATION :: 0x0400 TPM_HORNEGANIMATION :: 0x0800 TPM_VERPOSANIMATION :: 0x1000 TPM_VERNEGANIMATION :: 0x2000 -TPM_NOANIMATION :: 0x4000 -TPM_LAYOUTRTL :: 0x8000 -TPM_WORKAREA :: 0x10000 +TPM_NOANIMATION :: 0x4000 +TPM_LAYOUTRTL :: 0x8000 +TPM_WORKAREA :: 0x10000 // WM_NCHITTEST and MOUSEHOOKSTRUCT Mouse Position Codes HTERROR :: -2 @@ -1545,42 +1568,42 @@ HTCLOSE :: 20 HTHELP :: 21 TEXTMETRICW :: struct { - tmHeight: LONG, - tmAscent: LONG, - tmDescent: LONG, - tmInternalLeading: LONG, - tmExternalLeading: LONG, - tmAveCharWidth: LONG, - tmMaxCharWidth: LONG, - tmWeight: LONG, - tmOverhang: LONG, + tmHeight: LONG, + tmAscent: LONG, + tmDescent: LONG, + tmInternalLeading: LONG, + tmExternalLeading: LONG, + tmAveCharWidth: LONG, + tmMaxCharWidth: LONG, + tmWeight: LONG, + tmOverhang: LONG, tmDigitizedAspectX: LONG, tmDigitizedAspectY: LONG, - tmFirstChar: WCHAR, - tmLastChar: WCHAR, - tmDefaultChar: WCHAR, - tmBreakChar: WCHAR, - tmItalic: BYTE, - tmUnderlined: BYTE, - tmStruckOut: BYTE, - tmPitchAndFamily: BYTE, - tmCharSet: BYTE, + tmFirstChar: WCHAR, + tmLastChar: WCHAR, + tmDefaultChar: WCHAR, + tmBreakChar: WCHAR, + tmItalic: BYTE, + tmUnderlined: BYTE, + tmStruckOut: BYTE, + tmPitchAndFamily: BYTE, + tmCharSet: BYTE, } LPTEXTMETRICW :: ^TEXTMETRICW PAINTSTRUCT :: struct { - hdc: HDC, - fErase: BOOL, - rcPaint: RECT, - fRestore: BOOL, - fIncUpdate: BOOL, + hdc: HDC, + fErase: BOOL, + rcPaint: RECT, + fRestore: BOOL, + fIncUpdate: BOOL, rgbReserved: [32]BYTE, } TRACKMOUSEEVENT :: struct { - cbSize: DWORD, - dwFlags: DWORD, - hwndTrack: HWND, + cbSize: DWORD, + dwFlags: DWORD, + hwndTrack: HWND, dwHoverTime: DWORD, } @@ -1640,16 +1663,16 @@ MAX_LINKID_TEXT :: 48 L_MAX_URL_LENGTH :: 2048 + 32 + len("://") LITEM :: struct { - mask: UINT, - iLink: c_int, - state: UINT, + mask: UINT, + iLink: c_int, + state: UINT, stateMask: UINT, - szID: [MAX_LINKID_TEXT]WCHAR, - szUrl: [L_MAX_URL_LENGTH]WCHAR, + szID: [MAX_LINKID_TEXT]WCHAR, + szUrl: [L_MAX_URL_LENGTH]WCHAR, } NMLINK :: struct { - hdr: NMHDR, + hdr: NMHDR, item: LITEM, } @@ -1660,12 +1683,12 @@ NMHDR :: struct { } NMCUSTOMDRAW :: struct { - hdr: NMHDR, + hdr: NMHDR, dwDrawStage: DWORD, - hdc: HDC, - rc: RECT, - dwItemSpec: DWORD_PTR, - uItemState: UINT, + hdc: HDC, + rc: RECT, + dwItemSpec: DWORD_PTR, + uItemState: UINT, lItemlParam: LPARAM, } @@ -1701,14 +1724,14 @@ NM_TVSTATEIMAGECHANGING :: NM_OUTOFMEMORY-23 // uses NMTVSTATEIMAGECHANGING stru PCZZWSTR :: cstring16 SHFILEOPSTRUCTW :: struct { - hwnd: HWND, - wFunc: UINT, - pFrom: PCZZWSTR, - pTo: PCZZWSTR, - fFlags: FILEOP_FLAGS, + hwnd: HWND, + wFunc: UINT, + pFrom: PCZZWSTR, + pTo: PCZZWSTR, + fFlags: FILEOP_FLAGS, fAnyOperationsAborted: BOOL, - hNameMappings: LPVOID, - lpszProgressTitle: PCWSTR, // only used if FOF_SIMPLEPROGRESS + hNameMappings: LPVOID, + lpszProgressTitle: PCWSTR, // only used if FOF_SIMPLEPROGRESS } LPSHFILEOPSTRUCTW :: ^SHFILEOPSTRUCTW @@ -1741,7 +1764,7 @@ FOF_NO_UI :: (FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FILEOP_FLAGS :: WORD DEVMODEW :: struct { - dmDeviceName: [32]wchar_t, + dmDeviceName: [32]wchar_t, dmSpecVersion: WORD, dmDriverVersion: WORD, dmSize: WORD, @@ -1887,7 +1910,7 @@ WS_MINIMIZE : UINT : 0x2000_0000 WS_MINIMIZEBOX : UINT : 0x0002_0000 WS_OVERLAPPED : UINT : 0x0000_0000 WS_OVERLAPPEDWINDOW : UINT : WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX -WS_POPUP : UINT : 0x8000_0000 +WS_POPUP : UINT : 0x8000_0000 WS_POPUPWINDOW : UINT : WS_POPUP | WS_BORDER | WS_SYSMENU WS_SIZEBOX : UINT : 0x0004_0000 WS_SYSMENU : UINT : 0x0008_0000 @@ -2227,24 +2250,24 @@ SEE_MASK_FLAG_LOG_USAGE :: 0x04000000 SEE_MASK_FLAG_HINST_IS_SITE :: 0x08000000 SHELLEXECUTEINFOW :: struct { - cbSize: DWORD, // in, required, sizeof of this structure - fMask: ULONG, // in, SEE_MASK_XXX values - hwnd: HWND, // in, optional - lpVerb: LPCWSTR, // in, optional when unspecified the default verb is choosen - lpFile: LPCWSTR, // in, either this value or lpIDList must be specified - lpParameters: LPCWSTR, // in, optional - lpDirectory: LPCWSTR, // in, optional - nShow: c.int, // in, required - hInstApp: HINSTANCE, // out when SEE_MASK_NOCLOSEPROCESS is specified - lpIDList: rawptr, // in, valid when SEE_MASK_IDLIST is specified, PCIDLIST_ABSOLUTE, for use with SEE_MASK_IDLIST & SEE_MASK_INVOKEIDLIST - lpClass: LPCWSTR, // in, valid when SEE_MASK_CLASSNAME is specified - hkeyClass: HKEY, // in, valid when SEE_MASK_CLASSKEY is specified - dwHotKey: DWORD, // in, valid when SEE_MASK_HOTKEY is specified - DUMMYUNIONNAME: struct #raw_union { - hIcon: HANDLE, // not used - hMonitor: HANDLE, // in, valid when SEE_MASK_HMONITOR specified + cbSize: DWORD, // in, required, sizeof of this structure + fMask: ULONG, // in, SEE_MASK_XXX values + hwnd: HWND, // in, optional + lpVerb: LPCWSTR, // in, optional when unspecified the default verb is choosen + lpFile: LPCWSTR, // in, either this value or lpIDList must be specified + lpParameters: LPCWSTR, // in, optional + lpDirectory: LPCWSTR, // in, optional + nShow: c_int, // in, required + hInstApp: HINSTANCE, // out when SEE_MASK_NOCLOSEPROCESS is specified + lpIDList: rawptr, // in, valid when SEE_MASK_IDLIST is specified, PCIDLIST_ABSOLUTE, for use with SEE_MASK_IDLIST & SEE_MASK_INVOKEIDLIST + lpClass: LPCWSTR, // in, valid when SEE_MASK_CLASSNAME is specified + hkeyClass: HKEY, // in, valid when SEE_MASK_CLASSKEY is specified + dwHotKey: DWORD, // in, valid when SEE_MASK_HOTKEY is specified + using DUMMYUNIONNAME: struct #raw_union { + hIcon: HANDLE, // not used + hMonitor: HANDLE, // in, valid when SEE_MASK_HMONITOR specified }, - hProcess: HANDLE, // out, valid when SEE_MASK_NOCLOSEPROCESS specified + hProcess: HANDLE, // out, valid when SEE_MASK_NOCLOSEPROCESS specified } LPSHELLEXECUTEINFOW :: ^SHELLEXECUTEINFOW @@ -2291,9 +2314,9 @@ WA_CLICKACTIVE :: 2 // Struct pointed to by WM_GETMINMAXINFO lParam MINMAXINFO :: struct { - ptReserved: POINT, - ptMaxSize: POINT, - ptMaxPosition: POINT, + ptReserved: POINT, + ptMaxSize: POINT, + ptMaxPosition: POINT, ptMinTrackSize: POINT, ptMaxTrackSize: POINT, } @@ -2514,53 +2537,53 @@ STOCK_LAST :: 19 CLR_INVALID :: 0xFFFFFFFF RGBQUAD :: struct { - rgbBlue: BYTE, - rgbGreen: BYTE, - rgbRed: BYTE, + rgbBlue: BYTE, + rgbGreen: BYTE, + rgbRed: BYTE, rgbReserved: BYTE, } PIXELFORMATDESCRIPTOR :: struct { - nSize: WORD, - nVersion: WORD, - dwFlags: DWORD, - iPixelType: BYTE, - cColorBits: BYTE, - cRedBits: BYTE, - cRedShift: BYTE, - cGreenBits: BYTE, - cGreenShift: BYTE, - cBlueBits: BYTE, - cBlueShift: BYTE, - cAlphaBits: BYTE, - cAlphaShift: BYTE, - cAccumBits: BYTE, - cAccumRedBits: BYTE, + nSize: WORD, + nVersion: WORD, + dwFlags: DWORD, + iPixelType: BYTE, + cColorBits: BYTE, + cRedBits: BYTE, + cRedShift: BYTE, + cGreenBits: BYTE, + cGreenShift: BYTE, + cBlueBits: BYTE, + cBlueShift: BYTE, + cAlphaBits: BYTE, + cAlphaShift: BYTE, + cAccumBits: BYTE, + cAccumRedBits: BYTE, cAccumGreenBits: BYTE, - cAccumBlueBits: BYTE, + cAccumBlueBits: BYTE, cAccumAlphaBits: BYTE, - cDepthBits: BYTE, - cStencilBits: BYTE, - cAuxBuffers: BYTE, - iLayerType: BYTE, - bReserved: BYTE, - dwLayerMask: DWORD, - dwVisibleMask: DWORD, - dwDamageMask: DWORD, + cDepthBits: BYTE, + cStencilBits: BYTE, + cAuxBuffers: BYTE, + iLayerType: BYTE, + bReserved: BYTE, + dwLayerMask: DWORD, + dwVisibleMask: DWORD, + dwDamageMask: DWORD, } BITMAPINFOHEADER :: struct { - biSize: DWORD, - biWidth: LONG, - biHeight: LONG, - biPlanes: WORD, - biBitCount: WORD, - biCompression: DWORD, - biSizeImage: DWORD, + biSize: DWORD, + biWidth: LONG, + biHeight: LONG, + biPlanes: WORD, + biBitCount: WORD, + biCompression: DWORD, + biSizeImage: DWORD, biXPelsPerMeter: LONG, biYPelsPerMeter: LONG, - biClrUsed: DWORD, - biClrImportant: DWORD, + biClrUsed: DWORD, + biClrImportant: DWORD, } BITMAPINFO :: struct { @@ -2668,64 +2691,66 @@ CONDITION_VARIABLE_INIT :: CONDITION_VARIABLE{} SRWLOCK_INIT :: SRWLOCK{} // Flags in STARTUPINFOW.dwFlags. -STARTF_USESHOWWINDOW: DWORD : 0x00000001 -STARTF_USESIZE: DWORD : 0x00000002 -STARTF_USEPOSITION: DWORD : 0x00000004 -STARTF_USECOUNTCHARS: DWORD : 0x00000008 -STARTF_USEFILLATTRIBUTE: DWORD : 0x00000010 -STARTF_RUNFULLSCREEN: DWORD : 0x00000020 // ignored for non-x86 platforms -STARTF_FORCEONFEEDBACK: DWORD : 0x00000040 -STARTF_FORCEOFFFEEDBACK: DWORD : 0x00000080 -STARTF_USESTDHANDLES: DWORD : 0x00000100 +STARTF_USESHOWWINDOW : DWORD : 0x00000001 +STARTF_USESIZE : DWORD : 0x00000002 +STARTF_USEPOSITION : DWORD : 0x00000004 +STARTF_USECOUNTCHARS : DWORD : 0x00000008 +STARTF_USEFILLATTRIBUTE : DWORD : 0x00000010 +STARTF_RUNFULLSCREEN : DWORD : 0x00000020 // ignored for non-x86 platforms +STARTF_FORCEONFEEDBACK : DWORD : 0x00000040 +STARTF_FORCEOFFFEEDBACK : DWORD : 0x00000080 +STARTF_USESTDHANDLES : DWORD : 0x00000100 // WINVER >= 0x400 -STARTF_USEHOTKEY: DWORD : 0x00000200 -STARTF_TITLEISLINKNAME: DWORD : 0x00000800 -STARTF_TITLEISAPPID: DWORD : 0x00001000 -STARTF_PREVENTPINNING: DWORD : 0x00002000 +STARTF_USEHOTKEY : DWORD : 0x00000200 +STARTF_TITLEISLINKNAME : DWORD : 0x00000800 +STARTF_TITLEISAPPID : DWORD : 0x00001000 +STARTF_PREVENTPINNING : DWORD : 0x00002000 // WINVER >= 0x600 -STARTF_UNTRUSTEDSOURCE: DWORD : 0x00008000 +STARTF_UNTRUSTEDSOURCE : DWORD : 0x00008000 VOLUME_NAME_DOS: DWORD : 0x0 -MOVEFILE_COPY_ALLOWED: DWORD: 0x2 -MOVEFILE_CREATE_HARDLINK: DWORD: 0x10 -MOVEFILE_DELAY_UNTIL_REBOOT: DWORD: 0x4 -MOVEFILE_FAIL_IF_NOT_TRACKABLE: DWORD: 0x20 -MOVEFILE_REPLACE_EXISTING: DWORD : 0x1 -MOVEFILE_WRITE_THROUGH: DWORD: 0x8 +MOVEFILE_COPY_ALLOWED : DWORD : 0x2 +MOVEFILE_CREATE_HARDLINK : DWORD : 0x10 +MOVEFILE_DELAY_UNTIL_REBOOT : DWORD : 0x4 +MOVEFILE_FAIL_IF_NOT_TRACKABLE : DWORD : 0x20 +MOVEFILE_REPLACE_EXISTING : DWORD : 0x1 +MOVEFILE_WRITE_THROUGH : DWORD : 0x8 -FILE_BEGIN: DWORD : 0 -FILE_CURRENT: DWORD : 1 -FILE_END: DWORD : 2 +FILE_BEGIN : DWORD : 0 +FILE_CURRENT : DWORD : 1 +FILE_END : DWORD : 2 -WAIT_OBJECT_0: DWORD : 0x00000000 -WAIT_TIMEOUT: DWORD : 258 -WAIT_FAILED: DWORD : 0xFFFFFFFF +WAIT_OBJECT_0 : DWORD : 0x00000000 +WAIT_TIMEOUT : DWORD : 258 +WAIT_FAILED : DWORD : 0xFFFFFFFF -FILE_FLAG_WRITE_THROUGH: DWORD : 0x80000000 -FILE_FLAG_OVERLAPPED: DWORD : 0x40000000 -FILE_FLAG_NO_BUFFERING: DWORD : 0x20000000 -FILE_FLAG_RANDOM_ACCESS: DWORD : 0x10000000 -FILE_FLAG_SEQUENTIAL_SCAN: DWORD : 0x08000000 -FILE_FLAG_DELETE_ON_CLOSE: DWORD : 0x04000000 -FILE_FLAG_BACKUP_SEMANTICS: DWORD : 0x02000000 -FILE_FLAG_POSIX_SEMANTICS: DWORD : 0x01000000 -FILE_FLAG_SESSION_AWARE: DWORD : 0x00800000 -FILE_FLAG_OPEN_REPARSE_POINT: DWORD : 0x00200000 -FILE_FLAG_OPEN_NO_RECALL: DWORD : 0x00100000 -FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD : 0x00080000 +WAIT_IO_COMPLETION: DWORD : 0x000000C0 -PIPE_ACCESS_INBOUND: DWORD : 0x00000001 -PIPE_ACCESS_OUTBOUND: DWORD : 0x00000002 -PIPE_ACCESS_DUPLEX: DWORD : 0x00000003 -PIPE_WAIT: DWORD : 0x00000000 -PIPE_TYPE_BYTE: DWORD : 0x00000000 -PIPE_TYPE_MESSAGE: DWORD : 0x00000004 -PIPE_REJECT_REMOTE_CLIENTS: DWORD : 0x00000008 -PIPE_READMODE_BYTE: DWORD : 0x00000000 -PIPE_READMODE_MESSAGE: DWORD : 0x00000002 -PIPE_ACCEPT_REMOTE_CLIENTS: DWORD : 0x00000000 +FILE_FLAG_WRITE_THROUGH : DWORD : 0x80000000 +FILE_FLAG_OVERLAPPED : DWORD : 0x40000000 +FILE_FLAG_NO_BUFFERING : DWORD : 0x20000000 +FILE_FLAG_RANDOM_ACCESS : DWORD : 0x10000000 +FILE_FLAG_SEQUENTIAL_SCAN : DWORD : 0x08000000 +FILE_FLAG_DELETE_ON_CLOSE : DWORD : 0x04000000 +FILE_FLAG_BACKUP_SEMANTICS : DWORD : 0x02000000 +FILE_FLAG_POSIX_SEMANTICS : DWORD : 0x01000000 +FILE_FLAG_SESSION_AWARE : DWORD : 0x00800000 +FILE_FLAG_OPEN_REPARSE_POINT : DWORD : 0x00200000 +FILE_FLAG_OPEN_NO_RECALL : DWORD : 0x00100000 +FILE_FLAG_FIRST_PIPE_INSTANCE : DWORD : 0x00080000 + +PIPE_ACCESS_INBOUND : DWORD : 0x00000001 +PIPE_ACCESS_OUTBOUND : DWORD : 0x00000002 +PIPE_ACCESS_DUPLEX : DWORD : 0x00000003 +PIPE_WAIT : DWORD : 0x00000000 +PIPE_TYPE_BYTE : DWORD : 0x00000000 +PIPE_TYPE_MESSAGE : DWORD : 0x00000004 +PIPE_REJECT_REMOTE_CLIENTS : DWORD : 0x00000008 +PIPE_READMODE_BYTE : DWORD : 0x00000000 +PIPE_READMODE_MESSAGE : DWORD : 0x00000002 +PIPE_ACCEPT_REMOTE_CLIENTS : DWORD : 0x00000000 FD_SETSIZE :: 64 @@ -2739,10 +2764,10 @@ HANDLE_FLAG_INHERIT: DWORD : 0x00000001 HANDLE_FLAG_PROTECT_FROM_CLOSE :: 0x00000002 GENERIC_MAPPING :: struct { - GenericRead: ACCESS_MASK, - GenericWrite: ACCESS_MASK, + GenericRead: ACCESS_MASK, + GenericWrite: ACCESS_MASK, GenericExecute: ACCESS_MASK, - GenericAll: ACCESS_MASK, + GenericAll: ACCESS_MASK, } PGENERIC_MAPPING :: ^GENERIC_MAPPING @@ -2758,14 +2783,14 @@ ANYSIZE_ARRAY :: 1 PLUID_AND_ATTRIBUTES :: ^LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES :: struct { - Luid: LUID, + Luid: LUID, Attributes: DWORD, } PRIVILEGE_SET :: struct { PrivilegeCount: DWORD, - Control: DWORD, - Privilege: [ANYSIZE_ARRAY]LUID_AND_ATTRIBUTES, + Control: DWORD, + Privilege: [ANYSIZE_ARRAY]LUID_AND_ATTRIBUTES `fmt:"v,PrivilegeCount"`, } PPRIVILEGE_SET :: ^PRIVILEGE_SET @@ -2780,7 +2805,8 @@ TOKEN_ADJUST_GROUPS :: 0x0040 TOKEN_ADJUST_DEFAULT :: 0x0080 TOKEN_ADJUST_SESSIONID :: 0x0100 -TOKEN_ALL_ACCESS_P :: STANDARD_RIGHTS_REQUIRED | TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE | TOKEN_IMPERSONATE | TOKEN_QUERY |\ +TOKEN_ALL_ACCESS_P :: \ + STANDARD_RIGHTS_REQUIRED | TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE | TOKEN_IMPERSONATE | TOKEN_QUERY | TOKEN_QUERY_SOURCE | TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT TOKEN_ALL_ACCESS :: TOKEN_ALL_ACCESS_P | TOKEN_ADJUST_SESSIONID @@ -2803,8 +2829,8 @@ CP_UTF8 :: 65001 // UTF-8 translation LCID :: DWORD LANGID :: WORD -LANG_NEUTRAL :: 0x00 -LANG_INVARIANT :: 0x7f +LANG_NEUTRAL :: 0x00 +LANG_INVARIANT :: 0x7f SUBLANG_NEUTRAL :: 0x00 // language neutral SUBLANG_DEFAULT :: 0x01 // user default @@ -2815,7 +2841,7 @@ WC_ERR_INVALID_CHARS :: 128 MAX_PATH :: 0x00000104 MAX_PATH_WIDE :: 0x8000 -INVALID_FILE_ATTRIBUTES :: DWORD(0xffff_ffff) +INVALID_FILE_ATTRIBUTES :: DWORD(0xffff_ffff) FILE_TYPE_DISK :: 0x0001 FILE_TYPE_CHAR :: 0x0002 @@ -2826,33 +2852,33 @@ POINT :: struct {x, y: LONG} PWINDOWPOS :: ^WINDOWPOS WINDOWPOS :: struct { - hwnd: HWND, + hwnd: HWND, hwndInsertAfter: HWND, - x: c_int, - y: c_int, - cx: c_int, - cy: c_int, + x: c_int, + y: c_int, + cx: c_int, + cy: c_int, flags: UINT, } when size_of(uintptr) == 4 { WSADATA :: struct { - wVersion: WORD, - wHighVersion: WORD, - szDescription: [WSADESCRIPTION_LEN + 1]u8, + wVersion: WORD, + wHighVersion: WORD, + szDescription: [WSADESCRIPTION_LEN + 1]u8, szSystemStatus: [WSASYS_STATUS_LEN + 1]u8, - iMaxSockets: u16, - iMaxUdpDg: u16, - lpVendorInfo: ^u8, + iMaxSockets: u16, + iMaxUdpDg: u16, + lpVendorInfo: [^]u8, } } else when size_of(uintptr) == 8 { WSADATA :: struct { - wVersion: WORD, - wHighVersion: WORD, - iMaxSockets: u16, - iMaxUdpDg: u16, - lpVendorInfo: ^u8, - szDescription: [WSADESCRIPTION_LEN + 1]u8, + wVersion: WORD, + wHighVersion: WORD, + iMaxSockets: u16, + iMaxUdpDg: u16, + lpVendorInfo: ^u8, + szDescription: [WSADESCRIPTION_LEN + 1]u8, szSystemStatus: [WSASYS_STATUS_LEN + 1]u8, } } else { @@ -2861,71 +2887,71 @@ when size_of(uintptr) == 4 { WSABUF :: struct { len: ULONG, - buf: ^CHAR, + buf: [^]CHAR `fmt"q,len"`, } WSAPROTOCOL_INFO :: struct { - dwServiceFlags1: DWORD, - dwServiceFlags2: DWORD, - dwServiceFlags3: DWORD, - dwServiceFlags4: DWORD, - dwProviderFlags: DWORD, - ProviderId: GUID, - dwCatalogEntryId: DWORD, - ProtocolChain: WSAPROTOCOLCHAIN, - iVersion: c_int, - iAddressFamily: c_int, - iMaxSockAddr: c_int, - iMinSockAddr: c_int, - iSocketType: c_int, - iProtocol: c_int, + dwServiceFlags1: DWORD, + dwServiceFlags2: DWORD, + dwServiceFlags3: DWORD, + dwServiceFlags4: DWORD, + dwProviderFlags: DWORD, + ProviderId: GUID, + dwCatalogEntryId: DWORD, + ProtocolChain: WSAPROTOCOLCHAIN, + iVersion: c_int, + iAddressFamily: c_int, + iMaxSockAddr: c_int, + iMinSockAddr: c_int, + iSocketType: c_int, + iProtocol: c_int, iProtocolMaxOffset: c_int, - iNetworkByteOrder: c_int, - iSecurityScheme: c_int, - dwMessageSize: DWORD, + iNetworkByteOrder: c_int, + iSecurityScheme: c_int, + dwMessageSize: DWORD, dwProviderReserved: DWORD, - szProtocol: [WSAPROTOCOL_LEN + 1]u16, + szProtocol: [WSAPROTOCOL_LEN + 1]u16, } WIN32_FILE_ATTRIBUTE_DATA :: struct { dwFileAttributes: DWORD, - ftCreationTime: FILETIME, + ftCreationTime: FILETIME, ftLastAccessTime: FILETIME, - ftLastWriteTime: FILETIME, - nFileSizeHigh: DWORD, - nFileSizeLow: DWORD, + ftLastWriteTime: FILETIME, + nFileSizeHigh: DWORD, + nFileSizeLow: DWORD, } FILE_INFO_BY_HANDLE_CLASS :: enum c_int { - FileBasicInfo = 0, - FileStandardInfo = 1, - FileNameInfo = 2, - FileRenameInfo = 3, - FileDispositionInfo = 4, - FileAllocationInfo = 5, - FileEndOfFileInfo = 6, - FileStreamInfo = 7, - FileCompressionInfo = 8, - FileAttributeTagInfo = 9, - FileIdBothDirectoryInfo = 10, // 0xA + FileBasicInfo = 0, + FileStandardInfo = 1, + FileNameInfo = 2, + FileRenameInfo = 3, + FileDispositionInfo = 4, + FileAllocationInfo = 5, + FileEndOfFileInfo = 6, + FileStreamInfo = 7, + FileCompressionInfo = 8, + FileAttributeTagInfo = 9, + FileIdBothDirectoryInfo = 10, // 0xA FileIdBothDirectoryRestartInfo = 11, // 0xB - FileIoPriorityHintInfo = 12, // 0xC - FileRemoteProtocolInfo = 13, // 0xD - FileFullDirectoryInfo = 14, // 0xE - FileFullDirectoryRestartInfo = 15, // 0xF - FileStorageInfo = 16, // 0x10 - FileAlignmentInfo = 17, // 0x11 - FileIdInfo = 18, // 0x12 - FileIdExtdDirectoryInfo = 19, // 0x13 + FileIoPriorityHintInfo = 12, // 0xC + FileRemoteProtocolInfo = 13, // 0xD + FileFullDirectoryInfo = 14, // 0xE + FileFullDirectoryRestartInfo = 15, // 0xF + FileStorageInfo = 16, // 0x10 + FileAlignmentInfo = 17, // 0x11 + FileIdInfo = 18, // 0x12 + FileIdExtdDirectoryInfo = 19, // 0x13 FileIdExtdDirectoryRestartInfo = 20, // 0x14 MaximumFileInfoByHandlesClass, } FILE_BASIC_INFO :: struct { - CreationTime: LARGE_INTEGER, + CreationTime: LARGE_INTEGER, LastAccessTime: LARGE_INTEGER, - LastWriteTime: LARGE_INTEGER, - ChangeTime: LARGE_INTEGER, + LastWriteTime: LARGE_INTEGER, + ChangeTime: LARGE_INTEGER, FileAttributes: DWORD, } @@ -2941,39 +2967,39 @@ FILE_NOTIFY_INFORMATION :: struct { } REPARSE_DATA_BUFFER :: struct { - ReparseTag: c_uint, + ReparseTag: c_uint, ReparseDataLength: c_ushort, - Reserved: c_ushort, - rest: [0]byte, + Reserved: c_ushort, + rest: [0]byte, } SYMBOLIC_LINK_REPARSE_BUFFER :: struct { SubstituteNameOffset: c_ushort, SubstituteNameLength: c_ushort, - PrintNameOffset: c_ushort, - PrintNameLength: c_ushort, - Flags: c_ulong, - PathBuffer: WCHAR, + PrintNameOffset: c_ushort, + PrintNameLength: c_ushort, + Flags: c_ulong, + PathBuffer: WCHAR, } MOUNT_POINT_REPARSE_BUFFER :: struct { SubstituteNameOffset: c_ushort, SubstituteNameLength: c_ushort, - PrintNameOffset: c_ushort, - PrintNameLength: c_ushort, - PathBuffer: WCHAR, + PrintNameOffset: c_ushort, + PrintNameLength: c_ushort, + PathBuffer: WCHAR, } LPPROGRESS_ROUTINE :: #type proc "system" ( - TotalFileSize: LARGE_INTEGER, - TotalBytesTransferred: LARGE_INTEGER, - StreamSize: LARGE_INTEGER, + TotalFileSize: LARGE_INTEGER, + TotalBytesTransferred: LARGE_INTEGER, + StreamSize: LARGE_INTEGER, StreamBytesTransferred: LARGE_INTEGER, - dwStreamNumber: DWORD, - dwCallbackReason: DWORD, - hSourceFile: HANDLE, - hDestinationFile: HANDLE, - lpData: LPVOID, + dwStreamNumber: DWORD, + dwCallbackReason: DWORD, + hSourceFile: HANDLE, + hDestinationFile: HANDLE, + lpData: LPVOID, ) -> DWORD CONDITION_VARIABLE :: struct { @@ -2984,21 +3010,21 @@ SRWLOCK :: struct { } CRITICAL_SECTION :: struct { CriticalSectionDebug: LPVOID, - LockCount: LONG, - RecursionCount: LONG, - OwningThread: HANDLE, - LockSemaphore: HANDLE, - SpinCount: ULONG_PTR, + LockCount: LONG, + RecursionCount: LONG, + OwningThread: HANDLE, + LockSemaphore: HANDLE, + SpinCount: ULONG_PTR, } REPARSE_MOUNTPOINT_DATA_BUFFER :: struct { - ReparseTag: DWORD, - ReparseDataLength: DWORD, - Reserved: WORD, - ReparseTargetLength: WORD, + ReparseTag: DWORD, + ReparseDataLength: DWORD, + Reserved: WORD, + ReparseTargetLength: WORD, ReparseTargetMaximumLength: WORD, - Reserved1: WORD, - ReparseTarget: WCHAR, + Reserved1: WORD, + ReparseTarget: WCHAR, } GUID :: struct { @@ -3021,12 +3047,12 @@ LPGUID :: ^GUID LPCGUID :: ^GUID REFIID :: ^GUID -REFGUID :: GUID -IID :: GUID -LPIID :: ^IID -CLSID :: GUID +REFGUID :: GUID +IID :: GUID +LPIID :: ^IID +CLSID :: GUID REFCLSID :: ^CLSID -LPCLSID :: ^CLSID +LPCLSID :: ^CLSID CLSCTX_INPROC_SERVER :: 0x1 CLSCTX_INPROC_HANDLER :: 0x2 @@ -3059,46 +3085,46 @@ CLSCTX_PS_DLL :: 0x80000000 CLSCTX_ALL :: CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER WSAPROTOCOLCHAIN :: struct { - ChainLen: c_int, - ChainEntries: [MAX_PROTOCOL_CHAIN]DWORD, + ChainLen: c_int, + ChainEntries: [MAX_PROTOCOL_CHAIN]DWORD `fmt:"v,ChainLen"`, } SECURITY_ATTRIBUTES :: struct { - nLength: DWORD, + nLength: DWORD, lpSecurityDescriptor: LPVOID, - bInheritHandle: BOOL, + bInheritHandle: BOOL, } PROCESS_INFORMATION :: struct { - hProcess: HANDLE, - hThread: HANDLE, + hProcess: HANDLE, + hThread: HANDLE, dwProcessId: DWORD, - dwThreadId: DWORD, + dwThreadId: DWORD, } STARTUPINFOW :: struct { - cb: DWORD, - lpReserved: LPWSTR, - lpDesktop: LPWSTR, - lpTitle: LPWSTR, - dwX: DWORD, - dwY: DWORD, - dwXSize: DWORD, - dwYSize: DWORD, - dwXCountChars: DWORD, - dwYCountChars: DWORD, + cb: DWORD, + lpReserved: LPWSTR, + lpDesktop: LPWSTR, + lpTitle: LPWSTR, + dwX: DWORD, + dwY: DWORD, + dwXSize: DWORD, + dwYSize: DWORD, + dwXCountChars: DWORD, + dwYCountChars: DWORD, dwFillAttribute: DWORD, - dwFlags: DWORD, - wShowWindow: WORD, - cbReserved2: WORD, - lpReserved2: LPBYTE, - hStdInput: HANDLE, - hStdOutput: HANDLE, - hStdError: HANDLE, + dwFlags: DWORD, + wShowWindow: WORD, + cbReserved2: WORD, + lpReserved2: LPBYTE, + hStdInput: HANDLE, + hStdOutput: HANDLE, + hStdError: HANDLE, } FILETIME :: struct { - dwLowDateTime: DWORD, + dwLowDateTime: DWORD, dwHighDateTime: DWORD, } @@ -3115,6 +3141,7 @@ OBJECT_ATTRIBUTES :: struct { SecurityDescriptor: rawptr, SecurityQualityOfService: rawptr, } +POBJECT_ATTRIBUTES :: ^OBJECT_ATTRIBUTES PUNICODE_STRING :: ^UNICODE_STRING UNICODE_STRING :: struct { @@ -3124,10 +3151,15 @@ UNICODE_STRING :: struct { } OVERLAPPED :: struct { - Internal: ^c_ulong, + Internal: ^c_ulong, InternalHigh: ^c_ulong, - Offset: DWORD, - OffsetHigh: DWORD, + using _: struct #raw_union { + using _: struct { + Offset: DWORD, + OffsetHigh: DWORD, + }, + OffsetFull: u64, // Convenience field to set Offset and OffsetHigh with one value. + }, hEvent: HANDLE, } @@ -3139,11 +3171,18 @@ OVERLAPPED_ENTRY :: struct { } LPOVERLAPPED_COMPLETION_ROUTINE :: #type proc "system" ( - dwErrorCode: DWORD, + dwErrorCode: DWORD, dwNumberOfBytesTransfered: DWORD, - lpOverlapped: LPOVERLAPPED, + lpOverlapped: LPOVERLAPPED, ) +READ_DIRECTORY_NOTIFY_INFORMATION_CLASS :: enum c_int { + ReadDirectoryNotifyInformation = 1, + ReadDirectoryNotifyExtendedInformation, + ReadDirectoryNotifyFullInformation, + ReadDirectoryNotifyMaximumInformation, +} + ADDRESS_MODE :: enum c_int { AddrMode1616, AddrMode1632, @@ -3164,7 +3203,7 @@ fd_set :: struct { } timeval :: struct { - tv_sec: c_long, + tv_sec: c_long, tv_usec: c_long, } @@ -3199,145 +3238,145 @@ STATUS_PRIVILEGED_INSTRUCTION :: 0xC0000096 EXCEPTION_RECORD :: struct { - ExceptionCode: DWORD, - ExceptionFlags: DWORD, - ExceptionRecord: ^EXCEPTION_RECORD, - ExceptionAddress: LPVOID, - NumberParameters: DWORD, - ExceptionInformation: [EXCEPTION_MAXIMUM_PARAMETERS]LPVOID, + ExceptionCode: DWORD, + ExceptionFlags: DWORD, + ExceptionRecord: ^EXCEPTION_RECORD, + ExceptionAddress: LPVOID, + NumberParameters: DWORD, + ExceptionInformation: [EXCEPTION_MAXIMUM_PARAMETERS]LPVOID `fmt:"v,NumberParameters"`, } CONTEXT :: struct { - P1Home: DWORD64, - P2Home: DWORD64, - P3Home: DWORD64, - P4Home: DWORD64, - P5Home: DWORD64, - P6Home: DWORD64, + P1Home: DWORD64, + P2Home: DWORD64, + P3Home: DWORD64, + P4Home: DWORD64, + P5Home: DWORD64, + P6Home: DWORD64, ContextFlags: DWORD, - MxCsr: DWORD, - SegCs: WORD, - SegDs: WORD, - SegEs: WORD, - SegFs: WORD, - SegGs: WORD, - SegSs: WORD, - EFlags: DWORD, - Dr0: DWORD64, - Dr1: DWORD64, - Dr2: DWORD64, - Dr3: DWORD64, - Dr6: DWORD64, - Dr7: DWORD64, - Rax: DWORD64, - Rcx: DWORD64, - Rdx: DWORD64, - Rbx: DWORD64, - Rsp: DWORD64, - Rbp: DWORD64, - Rsi: DWORD64, - Rdi: DWORD64, - R8: DWORD64, - R9: DWORD64, - R10: DWORD64, - R11: DWORD64, - R12: DWORD64, - R13: DWORD64, - R14: DWORD64, - R15: DWORD64, - Rip: DWORD64, - _: struct #raw_union { + MxCsr: DWORD, + SegCs: WORD, + SegDs: WORD, + SegEs: WORD, + SegFs: WORD, + SegGs: WORD, + SegSs: WORD, + EFlags: DWORD, + Dr0: DWORD64, + Dr1: DWORD64, + Dr2: DWORD64, + Dr3: DWORD64, + Dr6: DWORD64, + Dr7: DWORD64, + Rax: DWORD64, + Rcx: DWORD64, + Rdx: DWORD64, + Rbx: DWORD64, + Rsp: DWORD64, + Rbp: DWORD64, + Rsi: DWORD64, + Rdi: DWORD64, + R8: DWORD64, + R9: DWORD64, + R10: DWORD64, + R11: DWORD64, + R12: DWORD64, + R13: DWORD64, + R14: DWORD64, + R15: DWORD64, + Rip: DWORD64, + using _: struct #raw_union { FltSave: XMM_SAVE_AREA32, - Q: [16]NEON128, - D: [32]ULONGLONG, - _: struct { + Q: [16]NEON128, + D: [32]ULONGLONG, + using _: struct { Header: [2]M128A, Legacy: [8]M128A, - Xmm0: M128A, - Xmm1: M128A, - Xmm2: M128A, - Xmm3: M128A, - Xmm4: M128A, - Xmm5: M128A, - Xmm6: M128A, - Xmm7: M128A, - Xmm8: M128A, - Xmm9: M128A, - Xmm10: M128A, - Xmm11: M128A, - Xmm12: M128A, - Xmm13: M128A, - Xmm14: M128A, - Xmm15: M128A, + Xmm0: M128A, + Xmm1: M128A, + Xmm2: M128A, + Xmm3: M128A, + Xmm4: M128A, + Xmm5: M128A, + Xmm6: M128A, + Xmm7: M128A, + Xmm8: M128A, + Xmm9: M128A, + Xmm10: M128A, + Xmm11: M128A, + Xmm12: M128A, + Xmm13: M128A, + Xmm14: M128A, + Xmm15: M128A, }, S: [32]DWORD, }, - VectorRegister: [26]M128A, - VectorControl: DWORD64, - DebugControl: DWORD64, - LastBranchToRip: DWORD64, - LastBranchFromRip: DWORD64, - LastExceptionToRip: DWORD64, + VectorRegister: [26]M128A, + VectorControl: DWORD64, + DebugControl: DWORD64, + LastBranchToRip: DWORD64, + LastBranchFromRip: DWORD64, + LastExceptionToRip: DWORD64, LastExceptionFromRip: DWORD64, } -PCONTEXT :: ^CONTEXT +PCONTEXT :: ^CONTEXT LPCONTEXT :: ^CONTEXT when size_of(uintptr) == 32 { XSAVE_FORMAT :: struct #align(16) { - ControlWord: WORD, - StatusWord: WORD, - TagWord: BYTE, - Reserved1: BYTE, - ErrorOpcode: WORD, - ErrorOffset: DWORD, - ErrorSelector: WORD, - Reserved2: WORD, - DataOffset: DWORD, - DataSelector: WORD, - Reserved3: WORD, - MxCsr: DWORD, - MxCsr_Mask: DWORD, + ControlWord: WORD, + StatusWord: WORD, + TagWord: BYTE, + Reserved1: BYTE, + ErrorOpcode: WORD, + ErrorOffset: DWORD, + ErrorSelector: WORD, + Reserved2: WORD, + DataOffset: DWORD, + DataSelector: WORD, + Reserved3: WORD, + MxCsr: DWORD, + MxCsr_Mask: DWORD, FloatRegisters: [8]M128A, // 32-bit specific - XmmRegisters: [8]M128A, - Reserved4: [192]BYTE, - StackControl: [7]DWORD, - Cr0NpxState: DWORD, + XmmRegisters: [8]M128A, + Reserved4: [192]BYTE, + StackControl: [7]DWORD, + Cr0NpxState: DWORD, } } else { XSAVE_FORMAT :: struct #align(16) { - ControlWord: WORD, - StatusWord: WORD, - TagWord: BYTE, - Reserved1: BYTE, - ErrorOpcode: WORD, - ErrorOffset: DWORD, - ErrorSelector: WORD, - Reserved2: WORD, - DataOffset: DWORD, - DataSelector: WORD, - Reserved3: WORD, - MxCsr: DWORD, - MxCsr_Mask: DWORD, + ControlWord: WORD, + StatusWord: WORD, + TagWord: BYTE, + Reserved1: BYTE, + ErrorOpcode: WORD, + ErrorOffset: DWORD, + ErrorSelector: WORD, + Reserved2: WORD, + DataOffset: DWORD, + DataSelector: WORD, + Reserved3: WORD, + MxCsr: DWORD, + MxCsr_Mask: DWORD, FloatRegisters: [8]M128A, // 64-bit specific - XmmRegisters: [16]M128A, - Reserved4: [96]BYTE, + XmmRegisters: [16]M128A, + Reserved4: [96]BYTE, } } XMM_SAVE_AREA32 :: XSAVE_FORMAT M128A :: struct { - Low: ULONGLONG, + Low: ULONGLONG, High: LONGLONG, } NEON128 :: struct { - Low: ULONGLONG, + Low: ULONGLONG, High: LONGLONG, } @@ -3386,17 +3425,17 @@ FILE_ATTRIBUTE_TAG_INFO :: struct { } // getaddrinfo flags https://learn.microsoft.com/en-us/windows/win32/api/ws2def/ns-ws2def-addrinfoa -AI_PASSIVE :: 0x01 -AI_CANONNAME :: 0x02 -AI_NUMERICHOST :: 0x04 -AI_ALL :: 0x0100 -AI_ADDRCONFIG :: 0x0400 -AI_V4MAPPED :: 0x0800 -AI_NON_AUTHORITATIVE :: 0x04000 -AI_SECURE :: 0x08000 +AI_PASSIVE :: 0x01 +AI_CANONNAME :: 0x02 +AI_NUMERICHOST :: 0x04 +AI_ALL :: 0x0100 +AI_ADDRCONFIG :: 0x0400 +AI_V4MAPPED :: 0x0800 +AI_NON_AUTHORITATIVE :: 0x04000 +AI_SECURE :: 0x08000 AI_RETURN_PREFERRED_NAMES :: 0x010000 -AI_FQDN :: 0x00020000 -AI_FILESERVER :: 0x00040000 +AI_FQDN :: 0x00020000 +AI_FILESERVER :: 0x00040000 PADDRINFOEXW :: ^ADDRINFOEXW LPADDRINFOEXW :: ^ADDRINFOEXW @@ -3415,9 +3454,9 @@ ADDRINFOEXW :: struct { } LPLOOKUPSERVICE_COMPLETION_ROUTINE :: #type proc "system" ( - dwErrorCode: DWORD, + dwErrorCode: DWORD, dwNumberOfBytesTransfered: DWORD, - lpOverlapped: LPOVERLAPPED, + lpOverlapped: LPOVERLAPPED, ) @@ -3427,18 +3466,18 @@ SYSTEM_INFO :: struct { dwOemID: DWORD, using _: struct #raw_union { wProcessorArchitecture: WORD, - wReserved: WORD, // reserved + wReserved: WORD, // reserved }, }, - dwPageSize: DWORD, + dwPageSize: DWORD, lpMinimumApplicationAddress: LPVOID, lpMaximumApplicationAddress: LPVOID, - dwActiveProcessorMask: DWORD_PTR, - dwNumberOfProcessors: DWORD, - dwProcessorType: DWORD, - dwAllocationGranularity: DWORD, - wProcessorLevel: WORD, - wProcessorRevision: WORD, + dwActiveProcessorMask: DWORD_PTR, + dwNumberOfProcessors: DWORD, + dwProcessorType: DWORD, + dwAllocationGranularity: DWORD, + wProcessorLevel: WORD, + wProcessorRevision: WORD, } // https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ns-wdm-_osversioninfoexw @@ -3475,12 +3514,12 @@ LoadLibraryEx_Flags :: distinct bit_set[LoadLibraryEx_Flag] // https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-quota_limits // Used in LogonUserExW PQUOTA_LIMITS :: struct { - PagedPoolLimit: SIZE_T, - NonPagedPoolLimit: SIZE_T, + PagedPoolLimit: SIZE_T, + NonPagedPoolLimit: SIZE_T, MinimumWorkingSetSize: SIZE_T, MaximumWorkingSetSize: SIZE_T, - PagefileLimit: SIZE_T, - TimeLimit: LARGE_INTEGER, + PagefileLimit: SIZE_T, + TimeLimit: LARGE_INTEGER, } Logon32_Type :: enum DWORD { @@ -3505,14 +3544,14 @@ Logon32_Provider :: enum DWORD { // Used in LoadUserProfileW PROFILEINFOW :: struct { - dwSize: DWORD, - dwFlags: DWORD, - lpUserName: LPWSTR, + dwSize: DWORD, + dwFlags: DWORD, + lpUserName: LPWSTR, lpProfilePath: LPWSTR, lpDefaultPath: LPWSTR, - lpServerName: LPWSTR, - lpPolicyPath: LPWSTR, - hProfile: HANDLE, + lpServerName: LPWSTR, + lpPolicyPath: LPWSTR, + hProfile: HANDLE, } SECURITY_MAX_SID_SIZE :: 68 @@ -3569,14 +3608,14 @@ USER_INFO_FLAG :: enum DWORD { USER_INFO_FLAGS :: distinct bit_set[USER_INFO_FLAG] USER_INFO_1 :: struct #packed { - name: LPWSTR, - password: LPWSTR, // Max password length is defined in LM20_PWLEN. + name: LPWSTR, + password: LPWSTR, // Max password length is defined in LM20_PWLEN. password_age: DWORD, - priv: USER_PRIV, - home_dir: LPWSTR, - comment: LPWSTR, - flags: USER_INFO_FLAGS, - script_path: LPWSTR, + priv: USER_PRIV, + home_dir: LPWSTR, + comment: LPWSTR, + flags: USER_INFO_FLAGS, + script_path: LPWSTR, } // #assert(size_of(USER_INFO_1) == 50) @@ -3585,320 +3624,320 @@ LOCALGROUP_MEMBERS_INFO_0 :: struct #packed { } NET_API_STATUS :: enum DWORD { - Success = 0, - ERROR_ACCESS_DENIED = 5, - MemberInAlias = 1378, - NetNotStarted = 2102, - UnknownServer = 2103, - ShareMem = 2104, - NoNetworkResource = 2105, - RemoteOnly = 2106, - DevNotRedirected = 2107, - ServerNotStarted = 2114, - ItemNotFound = 2115, - UnknownDevDir = 2116, - RedirectedPath = 2117, - DuplicateShare = 2118, - NoRoom = 2119, - TooManyItems = 2121, - InvalidMaxUsers = 2122, - BufTooSmall = 2123, - RemoteErr = 2127, - LanmanIniError = 2131, - NetworkError = 2136, - WkstaInconsistentState = 2137, - WkstaNotStarted = 2138, - BrowserNotStarted = 2139, - InternalError = 2140, - BadTransactConfig = 2141, - InvalidAPI = 2142, - BadEventName = 2143, - DupNameReboot = 2144, - CfgCompNotFound = 2146, - CfgParamNotFound = 2147, - LineTooLong = 2149, - QNotFound = 2150, - JobNotFound = 2151, - DestNotFound = 2152, - DestExists = 2153, - QExists = 2154, - QNoRoom = 2155, - JobNoRoom = 2156, - DestNoRoom = 2157, - DestIdle = 2158, - DestInvalidOp = 2159, - ProcNoRespond = 2160, - SpoolerNotLoaded = 2161, - DestInvalidState = 2162, - QInvalidState = 2163, - JobInvalidState = 2164, - SpoolNoMemory = 2165, - DriverNotFound = 2166, - DataTypeInvalid = 2167, - ProcNotFound = 2168, - ServiceTableLocked = 2180, - ServiceTableFull = 2181, - ServiceInstalled = 2182, - ServiceEntryLocked = 2183, - ServiceNotInstalled = 2184, - BadServiceName = 2185, - ServiceCtlTimeout = 2186, - ServiceCtlBusy = 2187, - BadServiceProgName = 2188, - ServiceNotCtrl = 2189, - ServiceKillProc = 2190, - ServiceCtlNotValid = 2191, - NotInDispatchTbl = 2192, - BadControlRecv = 2193, - ServiceNotStarting = 2194, - AlreadyLoggedOn = 2200, - NotLoggedOn = 2201, - BadUsername = 2202, - BadPassword = 2203, - UnableToAddName_W = 2204, - UnableToAddName_F = 2205, - UnableToDelName_W = 2206, - UnableToDelName_F = 2207, - LogonsPaused = 2209, - LogonServerConflict = 2210, - LogonNoUserPath = 2211, - LogonScriptError = 2212, - StandaloneLogon = 2214, - LogonServerNotFound = 2215, - LogonDomainExists = 2216, - NonValidatedLogon = 2217, - ACFNotFound = 2219, - GroupNotFound = 2220, - UserNotFound = 2221, - ResourceNotFound = 2222, - GroupExists = 2223, - UserExists = 2224, - ResourceExists = 2225, - NotPrimary = 2226, - ACFNotLoaded = 2227, - ACFNoRoom = 2228, - ACFFileIOFail = 2229, - ACFTooManyLists = 2230, - UserLogon = 2231, - ACFNoParent = 2232, - CanNotGrowSegment = 2233, - SpeGroupOp = 2234, - NotInCache = 2235, - UserInGroup = 2236, - UserNotInGroup = 2237, - AccountUndefined = 2238, - AccountExpired = 2239, - InvalidWorkstation = 2240, - InvalidLogonHours = 2241, - PasswordExpired = 2242, - PasswordCantChange = 2243, - PasswordHistConflict = 2244, - PasswordTooShort = 2245, - PasswordTooRecent = 2246, - InvalidDatabase = 2247, - DatabaseUpToDate = 2248, - SyncRequired = 2249, - UseNotFound = 2250, - BadAsgType = 2251, - DeviceIsShared = 2252, - SameAsComputerName = 2253, - NoComputerName = 2270, - MsgAlreadyStarted = 2271, - MsgInitFailed = 2272, - NameNotFound = 2273, - AlreadyForwarded = 2274, - AddForwarded = 2275, - AlreadyExists = 2276, - TooManyNames = 2277, - DelComputerName = 2278, - LocalForward = 2279, - GrpMsgProcessor = 2280, - PausedRemote = 2281, - BadReceive = 2282, - NameInUse = 2283, - MsgNotStarted = 2284, - NotLocalName = 2285, - NoForwardName = 2286, - RemoteFull = 2287, - NameNotForwarded = 2288, - TruncatedBroadcast = 2289, - InvalidDevice = 2294, - WriteFault = 2295, - DuplicateName = 2297, - DeleteLater = 2298, - IncompleteDel = 2299, - MultipleNets = 2300, - NetNameNotFound = 2310, - DeviceNotShared = 2311, - ClientNameNotFound = 2312, - FileIdNotFound = 2314, - ExecFailure = 2315, - TmpFile = 2316, - TooMuchData = 2317, - DeviceShareConflict = 2318, - BrowserTableIncomplete = 2319, - NotLocalDomain = 2320, - IsDfsShare = 2321, - DevInvalidOpCode = 2331, - DevNotFound = 2332, - DevNotOpen = 2333, - BadQueueDevString = 2334, - BadQueuePriority = 2335, - NoCommDevs = 2337, - QueueNotFound = 2338, - BadDevString = 2340, - BadDev = 2341, - InUseBySpooler = 2342, - CommDevInUse = 2343, - InvalidComputer = 2351, - MaxLenExceeded = 2354, - BadComponent = 2356, - CantType = 2357, - TooManyEntries = 2362, - ProfileFileTooBig = 2370, - ProfileOffset = 2371, - ProfileCleanup = 2372, - ProfileUnknownCmd = 2373, - ProfileLoadErr = 2374, - ProfileSaveErr = 2375, - LogOverflow = 2377, - LogFileChanged = 2378, - LogFileCorrupt = 2379, - SourceIsDir = 2380, - BadSource = 2381, - BadDest = 2382, - DifferentServers = 2383, - RunSrvPaused = 2385, - ErrCommRunSrv = 2389, - ErrorExecingGhost = 2391, - ShareNotFound = 2392, - InvalidLana = 2400, - OpenFiles = 2401, - ActiveConns = 2402, - BadPasswordCore = 2403, - DevInUse = 2404, - LocalDrive = 2405, - AlertExists = 2430, - TooManyAlerts = 2431, - NoSuchAlert = 2432, - BadRecipient = 2433, - AcctLimitExceeded = 2434, - InvalidLogSeek = 2440, - BadUasConfig = 2450, - InvalidUASOp = 2451, - LastAdmin = 2452, - DCNotFound = 2453, - LogonTrackingError = 2454, - NetlogonNotStarted = 2455, - CanNotGrowUASFile = 2456, - TimeDiffAtDC = 2457, - PasswordMismatch = 2458, - NoSuchServer = 2460, - NoSuchSession = 2461, - NoSuchConnection = 2462, - TooManyServers = 2463, - TooManySessions = 2464, - TooManyConnections = 2465, - TooManyFiles = 2466, - NoAlternateServers = 2467, - TryDownLevel = 2470, - UPSDriverNotStarted = 2480, - UPSInvalidConfig = 2481, - UPSInvalidCommPort = 2482, - UPSSignalAsserted = 2483, - UPSShutdownFailed = 2484, - BadDosRetCode = 2500, - ProgNeedsExtraMem = 2501, - BadDosFunction = 2502, - RemoteBootFailed = 2503, - BadFileCheckSum = 2504, - NoRplBootSystem = 2505, - RplLoadrNetBiosErr = 2506, - RplLoadrDiskErr = 2507, - ImageParamErr = 2508, - TooManyImageParams = 2509, - NonDosFloppyUsed = 2510, - RplBootRestart = 2511, - RplSrvrCallFailed = 2512, - CantConnectRplSrvr = 2513, - CantOpenImageFile = 2514, - CallingRplSrvr = 2515, - StartingRplBoot = 2516, - RplBootServiceTerm = 2517, - RplBootStartFailed = 2518, - RPL_CONNECTED = 2519, - BrowserConfiguredToNotRun = 2550, - RplNoAdaptersStarted = 2610, - RplBadRegistry = 2611, - RplBadDatabase = 2612, - RplRplfilesShare = 2613, - RplNotRplServer = 2614, - RplCannotEnum = 2615, - RplWkstaInfoCorrupted = 2616, - RplWkstaNotFound = 2617, - RplWkstaNameUnavailable = 2618, - RplProfileInfoCorrupted = 2619, - RplProfileNotFound = 2620, - RplProfileNameUnavailable = 2621, - RplProfileNotEmpty = 2622, - RplConfigInfoCorrupted = 2623, - RplConfigNotFound = 2624, - RplAdapterInfoCorrupted = 2625, - RplInternal = 2626, - RplVendorInfoCorrupted = 2627, - RplBootInfoCorrupted = 2628, - RplWkstaNeedsUserAcct = 2629, - RplNeedsRPLUSERAcct = 2630, - RplBootNotFound = 2631, - RplIncompatibleProfile = 2632, - RplAdapterNameUnavailable = 2633, - RplConfigNotEmpty = 2634, - RplBootInUse = 2635, - RplBackupDatabase = 2636, - RplAdapterNotFound = 2637, - RplVendorNotFound = 2638, - RplVendorNameUnavailable = 2639, - RplBootNameUnavailable = 2640, - RplConfigNameUnavailable = 2641, - DfsInternalCorruption = 2660, - DfsVolumeDataCorrupt = 2661, - DfsNoSuchVolume = 2662, - DfsVolumeAlreadyExists = 2663, - DfsAlreadyShared = 2664, - DfsNoSuchShare = 2665, - DfsNotALeafVolume = 2666, - DfsLeafVolume = 2667, - DfsVolumeHasMultipleServers = 2668, - DfsCantCreateJunctionPoint = 2669, - DfsServerNotDfsAware = 2670, - DfsBadRenamePath = 2671, - DfsVolumeIsOffline = 2672, - DfsNoSuchServer = 2673, - DfsCyclicalName = 2674, - DfsNotSupportedInServerDfs = 2675, - DfsDuplicateService = 2676, + Success = 0, + ERROR_ACCESS_DENIED = 5, + MemberInAlias = 1378, + NetNotStarted = 2102, + UnknownServer = 2103, + ShareMem = 2104, + NoNetworkResource = 2105, + RemoteOnly = 2106, + DevNotRedirected = 2107, + ServerNotStarted = 2114, + ItemNotFound = 2115, + UnknownDevDir = 2116, + RedirectedPath = 2117, + DuplicateShare = 2118, + NoRoom = 2119, + TooManyItems = 2121, + InvalidMaxUsers = 2122, + BufTooSmall = 2123, + RemoteErr = 2127, + LanmanIniError = 2131, + NetworkError = 2136, + WkstaInconsistentState = 2137, + WkstaNotStarted = 2138, + BrowserNotStarted = 2139, + InternalError = 2140, + BadTransactConfig = 2141, + InvalidAPI = 2142, + BadEventName = 2143, + DupNameReboot = 2144, + CfgCompNotFound = 2146, + CfgParamNotFound = 2147, + LineTooLong = 2149, + QNotFound = 2150, + JobNotFound = 2151, + DestNotFound = 2152, + DestExists = 2153, + QExists = 2154, + QNoRoom = 2155, + JobNoRoom = 2156, + DestNoRoom = 2157, + DestIdle = 2158, + DestInvalidOp = 2159, + ProcNoRespond = 2160, + SpoolerNotLoaded = 2161, + DestInvalidState = 2162, + QInvalidState = 2163, + JobInvalidState = 2164, + SpoolNoMemory = 2165, + DriverNotFound = 2166, + DataTypeInvalid = 2167, + ProcNotFound = 2168, + ServiceTableLocked = 2180, + ServiceTableFull = 2181, + ServiceInstalled = 2182, + ServiceEntryLocked = 2183, + ServiceNotInstalled = 2184, + BadServiceName = 2185, + ServiceCtlTimeout = 2186, + ServiceCtlBusy = 2187, + BadServiceProgName = 2188, + ServiceNotCtrl = 2189, + ServiceKillProc = 2190, + ServiceCtlNotValid = 2191, + NotInDispatchTbl = 2192, + BadControlRecv = 2193, + ServiceNotStarting = 2194, + AlreadyLoggedOn = 2200, + NotLoggedOn = 2201, + BadUsername = 2202, + BadPassword = 2203, + UnableToAddName_W = 2204, + UnableToAddName_F = 2205, + UnableToDelName_W = 2206, + UnableToDelName_F = 2207, + LogonsPaused = 2209, + LogonServerConflict = 2210, + LogonNoUserPath = 2211, + LogonScriptError = 2212, + StandaloneLogon = 2214, + LogonServerNotFound = 2215, + LogonDomainExists = 2216, + NonValidatedLogon = 2217, + ACFNotFound = 2219, + GroupNotFound = 2220, + UserNotFound = 2221, + ResourceNotFound = 2222, + GroupExists = 2223, + UserExists = 2224, + ResourceExists = 2225, + NotPrimary = 2226, + ACFNotLoaded = 2227, + ACFNoRoom = 2228, + ACFFileIOFail = 2229, + ACFTooManyLists = 2230, + UserLogon = 2231, + ACFNoParent = 2232, + CanNotGrowSegment = 2233, + SpeGroupOp = 2234, + NotInCache = 2235, + UserInGroup = 2236, + UserNotInGroup = 2237, + AccountUndefined = 2238, + AccountExpired = 2239, + InvalidWorkstation = 2240, + InvalidLogonHours = 2241, + PasswordExpired = 2242, + PasswordCantChange = 2243, + PasswordHistConflict = 2244, + PasswordTooShort = 2245, + PasswordTooRecent = 2246, + InvalidDatabase = 2247, + DatabaseUpToDate = 2248, + SyncRequired = 2249, + UseNotFound = 2250, + BadAsgType = 2251, + DeviceIsShared = 2252, + SameAsComputerName = 2253, + NoComputerName = 2270, + MsgAlreadyStarted = 2271, + MsgInitFailed = 2272, + NameNotFound = 2273, + AlreadyForwarded = 2274, + AddForwarded = 2275, + AlreadyExists = 2276, + TooManyNames = 2277, + DelComputerName = 2278, + LocalForward = 2279, + GrpMsgProcessor = 2280, + PausedRemote = 2281, + BadReceive = 2282, + NameInUse = 2283, + MsgNotStarted = 2284, + NotLocalName = 2285, + NoForwardName = 2286, + RemoteFull = 2287, + NameNotForwarded = 2288, + TruncatedBroadcast = 2289, + InvalidDevice = 2294, + WriteFault = 2295, + DuplicateName = 2297, + DeleteLater = 2298, + IncompleteDel = 2299, + MultipleNets = 2300, + NetNameNotFound = 2310, + DeviceNotShared = 2311, + ClientNameNotFound = 2312, + FileIdNotFound = 2314, + ExecFailure = 2315, + TmpFile = 2316, + TooMuchData = 2317, + DeviceShareConflict = 2318, + BrowserTableIncomplete = 2319, + NotLocalDomain = 2320, + IsDfsShare = 2321, + DevInvalidOpCode = 2331, + DevNotFound = 2332, + DevNotOpen = 2333, + BadQueueDevString = 2334, + BadQueuePriority = 2335, + NoCommDevs = 2337, + QueueNotFound = 2338, + BadDevString = 2340, + BadDev = 2341, + InUseBySpooler = 2342, + CommDevInUse = 2343, + InvalidComputer = 2351, + MaxLenExceeded = 2354, + BadComponent = 2356, + CantType = 2357, + TooManyEntries = 2362, + ProfileFileTooBig = 2370, + ProfileOffset = 2371, + ProfileCleanup = 2372, + ProfileUnknownCmd = 2373, + ProfileLoadErr = 2374, + ProfileSaveErr = 2375, + LogOverflow = 2377, + LogFileChanged = 2378, + LogFileCorrupt = 2379, + SourceIsDir = 2380, + BadSource = 2381, + BadDest = 2382, + DifferentServers = 2383, + RunSrvPaused = 2385, + ErrCommRunSrv = 2389, + ErrorExecingGhost = 2391, + ShareNotFound = 2392, + InvalidLana = 2400, + OpenFiles = 2401, + ActiveConns = 2402, + BadPasswordCore = 2403, + DevInUse = 2404, + LocalDrive = 2405, + AlertExists = 2430, + TooManyAlerts = 2431, + NoSuchAlert = 2432, + BadRecipient = 2433, + AcctLimitExceeded = 2434, + InvalidLogSeek = 2440, + BadUasConfig = 2450, + InvalidUASOp = 2451, + LastAdmin = 2452, + DCNotFound = 2453, + LogonTrackingError = 2454, + NetlogonNotStarted = 2455, + CanNotGrowUASFile = 2456, + TimeDiffAtDC = 2457, + PasswordMismatch = 2458, + NoSuchServer = 2460, + NoSuchSession = 2461, + NoSuchConnection = 2462, + TooManyServers = 2463, + TooManySessions = 2464, + TooManyConnections = 2465, + TooManyFiles = 2466, + NoAlternateServers = 2467, + TryDownLevel = 2470, + UPSDriverNotStarted = 2480, + UPSInvalidConfig = 2481, + UPSInvalidCommPort = 2482, + UPSSignalAsserted = 2483, + UPSShutdownFailed = 2484, + BadDosRetCode = 2500, + ProgNeedsExtraMem = 2501, + BadDosFunction = 2502, + RemoteBootFailed = 2503, + BadFileCheckSum = 2504, + NoRplBootSystem = 2505, + RplLoadrNetBiosErr = 2506, + RplLoadrDiskErr = 2507, + ImageParamErr = 2508, + TooManyImageParams = 2509, + NonDosFloppyUsed = 2510, + RplBootRestart = 2511, + RplSrvrCallFailed = 2512, + CantConnectRplSrvr = 2513, + CantOpenImageFile = 2514, + CallingRplSrvr = 2515, + StartingRplBoot = 2516, + RplBootServiceTerm = 2517, + RplBootStartFailed = 2518, + RPL_CONNECTED = 2519, + BrowserConfiguredToNotRun = 2550, + RplNoAdaptersStarted = 2610, + RplBadRegistry = 2611, + RplBadDatabase = 2612, + RplRplfilesShare = 2613, + RplNotRplServer = 2614, + RplCannotEnum = 2615, + RplWkstaInfoCorrupted = 2616, + RplWkstaNotFound = 2617, + RplWkstaNameUnavailable = 2618, + RplProfileInfoCorrupted = 2619, + RplProfileNotFound = 2620, + RplProfileNameUnavailable = 2621, + RplProfileNotEmpty = 2622, + RplConfigInfoCorrupted = 2623, + RplConfigNotFound = 2624, + RplAdapterInfoCorrupted = 2625, + RplInternal = 2626, + RplVendorInfoCorrupted = 2627, + RplBootInfoCorrupted = 2628, + RplWkstaNeedsUserAcct = 2629, + RplNeedsRPLUSERAcct = 2630, + RplBootNotFound = 2631, + RplIncompatibleProfile = 2632, + RplAdapterNameUnavailable = 2633, + RplConfigNotEmpty = 2634, + RplBootInUse = 2635, + RplBackupDatabase = 2636, + RplAdapterNotFound = 2637, + RplVendorNotFound = 2638, + RplVendorNameUnavailable = 2639, + RplBootNameUnavailable = 2640, + RplConfigNameUnavailable = 2641, + DfsInternalCorruption = 2660, + DfsVolumeDataCorrupt = 2661, + DfsNoSuchVolume = 2662, + DfsVolumeAlreadyExists = 2663, + DfsAlreadyShared = 2664, + DfsNoSuchShare = 2665, + DfsNotALeafVolume = 2666, + DfsLeafVolume = 2667, + DfsVolumeHasMultipleServers = 2668, + DfsCantCreateJunctionPoint = 2669, + DfsServerNotDfsAware = 2670, + DfsBadRenamePath = 2671, + DfsVolumeIsOffline = 2672, + DfsNoSuchServer = 2673, + DfsCyclicalName = 2674, + DfsNotSupportedInServerDfs = 2675, + DfsDuplicateService = 2676, DfsCantRemoveLastServerShare = 2677, - DfsVolumeIsInterDfs = 2678, - DfsInconsistent = 2679, - DfsServerUpgraded = 2680, - DfsDataIsIdentical = 2681, - DfsCantRemoveDfsRoot = 2682, - DfsChildOrParentInDfs = 2683, - DfsInternalError = 2690, - SetupAlreadyJoined = 2691, - SetupNotJoined = 2692, - SetupDomainController = 2693, - DefaultJoinRequired = 2694, - InvalidWorkgroupName = 2695, + DfsVolumeIsInterDfs = 2678, + DfsInconsistent = 2679, + DfsServerUpgraded = 2680, + DfsDataIsIdentical = 2681, + DfsCantRemoveDfsRoot = 2682, + DfsChildOrParentInDfs = 2683, + DfsInternalError = 2690, + SetupAlreadyJoined = 2691, + SetupNotJoined = 2692, + SetupDomainController = 2693, + DefaultJoinRequired = 2694, + InvalidWorkgroupName = 2695, NameUsesIncompatibleCodePage = 2696, - ComputerAccountNotFound = 2697, - PersonalSku = 2698, - SetupCheckDNSConfig = 2699, - PasswordMustChange = 2701, - AccountLockedOut = 2702, - PasswordTooLong = 2703, - PasswordNotComplexEnough = 2704, - PasswordFilterError = 2705, + ComputerAccountNotFound = 2697, + PersonalSku = 2698, + SetupCheckDNSConfig = 2699, + PasswordMustChange = 2701, + AccountLockedOut = 2702, + PasswordTooLong = 2703, + PasswordNotComplexEnough = 2704, + PasswordFilterError = 2705, } @@ -4053,12 +4092,12 @@ IMAGE_DEBUG_DIRECTORY :: struct { IMAGE_DEBUG_TYPE_CODEVIEW :: 2 -SICHINTF :: DWORD -SHCONTF :: DWORD -SFGAOF :: ULONG +SICHINTF :: DWORD +SHCONTF :: DWORD +SFGAOF :: ULONG FILEOPENDIALOGOPTIONS :: DWORD -REFPROPERTYKEY :: ^PROPERTYKEY -REFPROPVARIANT :: ^PROPVARIANT +REFPROPERTYKEY :: ^PROPERTYKEY +REFPROPVARIANT :: ^PROPVARIANT SIGDN :: enum c_int { NORMALDISPLAY = 0, @@ -4083,57 +4122,57 @@ SIATTRIBFLAGS :: enum c_int { FDAP :: enum c_int { BOTTOM = 0, - TOP = 1, + TOP = 1, } FDE_SHAREVIOLATION_RESPONSE :: enum c_int { DEFAULT = 0, - ACCEPT = 1, - REFUSE = 2, + ACCEPT = 1, + REFUSE = 2, } GETPROPERTYSTOREFLAGS :: enum c_int { - DEFAULT = 0, - HANDLERPROPERTIESONLY = 0x1, - READWRITE = 0x2, - TEMPORARY = 0x4, - FASTPROPERTIESONLY = 0x8, - OPENSLOWITEM = 0x10, - DELAYCREATION = 0x20, - BESTEFFORT = 0x40, - NO_OPLOCK = 0x80, - PREFERQUERYPROPERTIES = 0x100, - EXTRINSICPROPERTIES = 0x200, - EXTRINSICPROPERTIESONLY = 0x400, - VOLATILEPROPERTIES = 0x800, - VOLATILEPROPERTIESONLY = 0x1000, - MASK_VALID = 0x1fff, + DEFAULT = 0, + HANDLERPROPERTIESONLY = 0x1, + READWRITE = 0x2, + TEMPORARY = 0x4, + FASTPROPERTIESONLY = 0x8, + OPENSLOWITEM = 0x10, + DELAYCREATION = 0x20, + BESTEFFORT = 0x40, + NO_OPLOCK = 0x80, + PREFERQUERYPROPERTIES = 0x100, + EXTRINSICPROPERTIES = 0x200, + EXTRINSICPROPERTIESONLY = 0x400, + VOLATILEPROPERTIES = 0x800, + VOLATILEPROPERTIESONLY = 0x1000, + MASK_VALID = 0x1fff, } PROPERTYKEY :: struct { fmtid: GUID, - pid: DWORD, + pid: DWORD, } BIND_OPTS :: struct { - cbStruct: DWORD, - grfFlags: DWORD, - grfMode: DWORD, + cbStruct: DWORD, + grfFlags: DWORD, + grfMode: DWORD, dwTickCountDeadline: DWORD, } STATSTG :: struct { - pwcsName: LPOLESTR, - type: DWORD, - cbSize: ULARGE_INTEGER, - mtime: FILETIME, - ctime: FILETIME, - atime: FILETIME, - grfMode: DWORD, + pwcsName: LPOLESTR, + type: DWORD, + cbSize: ULARGE_INTEGER, + mtime: FILETIME, + ctime: FILETIME, + atime: FILETIME, + grfMode: DWORD, grfLocksSupported: DWORD, - clsid: CLSID, - grfStateBits: DWORD, - reserved: DWORD, + clsid: CLSID, + grfStateBits: DWORD, + reserved: DWORD, } COMDLG_FILTERSPEC :: struct { @@ -4142,15 +4181,15 @@ COMDLG_FILTERSPEC :: struct { DECIMAL :: struct { wReserved: USHORT, - _: struct #raw_union { - _: struct { + using _: struct #raw_union { + using _: struct { scale, sign: BYTE, }, signscale: USHORT, }, Hi32: ULONG, - _: struct #raw_union { - _: struct { + using _: struct #raw_union { + using _: struct { Lo32, Mid32: ULONG, }, Lo64: ULONGLONG, @@ -4223,14 +4262,14 @@ LWSTDAPI :: HRESULT CLSID_FileOpenDialog := &GUID{0xDC1C5A9C, 0xE88A, 0x4DDE, {0xA5, 0xA1, 0x60, 0xF8, 0x2A, 0x20, 0xAE, 0xF7}} CLSID_FileSaveDialog := &GUID{0xC0B4E2F3, 0xBA21, 0x4773, {0x8D, 0xBA, 0x33, 0x5E, 0xC9, 0x46, 0xEB, 0x8B}} -CLSID_TaskbarList := &GUID{0x56FDF344, 0xFD6D, 0x11d0, {0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90}} +CLSID_TaskbarList := &GUID{0x56FDF344, 0xFD6D, 0x11d0, {0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90}} -IID_IFileDialog := &GUID{0x42F85136, 0xDB7E, 0x439C, {0x85, 0xF1, 0xE4, 0x07, 0x5D, 0x13, 0x5F, 0xC8}} -IID_IFileSaveDialog := &GUID{0x84BCCD23, 0x5FDE, 0x4CDB, {0xAE, 0xA4, 0xAF, 0x64, 0xB8, 0x3D, 0x78, 0xAB}} -IID_IFileOpenDialog := &GUID{0xD57C7288, 0xD4AD, 0x4768, {0xBE, 0x02, 0x9D, 0x96, 0x95, 0x32, 0xD9, 0x60}} -IID_ITaskbarList := &GUID{0x56FDF342, 0xFD6D, 0x11d0, {0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90}} -IID_ITaskbarList2 := &GUID{0x602D4995, 0xB13A, 0x429b, {0xA6, 0x6E, 0x19, 0x35, 0xE4, 0x4F, 0x43, 0x17}} -IID_ITaskbarList3 := &GUID{0xea1afb91, 0x9e28, 0x4b86, {0x90, 0xe9, 0x9e, 0x9f, 0x8a, 0x5e, 0xef, 0xaf}} +IID_IFileDialog := &GUID{0x42F85136, 0xDB7E, 0x439C, {0x85, 0xF1, 0xE4, 0x07, 0x5D, 0x13, 0x5F, 0xC8}} +IID_IFileSaveDialog := &GUID{0x84BCCD23, 0x5FDE, 0x4CDB, {0xAE, 0xA4, 0xAF, 0x64, 0xB8, 0x3D, 0x78, 0xAB}} +IID_IFileOpenDialog := &GUID{0xD57C7288, 0xD4AD, 0x4768, {0xBE, 0x02, 0x9D, 0x96, 0x95, 0x32, 0xD9, 0x60}} +IID_ITaskbarList := &GUID{0x56FDF342, 0xFD6D, 0x11d0, {0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90}} +IID_ITaskbarList2 := &GUID{0x602D4995, 0xB13A, 0x429b, {0xA6, 0x6E, 0x19, 0x35, 0xE4, 0x4F, 0x43, 0x17}} +IID_ITaskbarList3 := &GUID{0xea1afb91, 0x9e28, 0x4b86, {0x90, 0xe9, 0x9e, 0x9f, 0x8a, 0x5e, 0xef, 0xaf}} IModalWindow :: struct #raw_union { #subtype IUnknown: IUnknown, @@ -4726,24 +4765,24 @@ Windows_Product_Type :: enum DWORD { WEB_SERVER_CORE = 0x0000001D, // Web Server (core installation) } -ENABLE_ECHO_INPUT : DWORD : 0x0004 -ENABLE_INSERT_MODE : DWORD : 0x0020 -ENABLE_LINE_INPUT : DWORD : 0x0002 -ENABLE_MOUSE_INPUT : DWORD : 0x0010 -ENABLE_PROCESSED_INPUT : DWORD : 0x0001 -ENABLE_QUICK_EDIT_MODE : DWORD : 0x0040 -ENABLE_WINDOW_INPUT : DWORD : 0x0008 -ENABLE_VIRTUAL_TERMINAL_INPUT : DWORD : 0x0200 -ENABLE_PROCESSED_OUTPUT : DWORD : 0x0001 -ENABLE_WRAP_AT_EOL_OUTPUT : DWORD : 0x0002 +ENABLE_ECHO_INPUT : DWORD : 0x0004 +ENABLE_INSERT_MODE : DWORD : 0x0020 +ENABLE_LINE_INPUT : DWORD : 0x0002 +ENABLE_MOUSE_INPUT : DWORD : 0x0010 +ENABLE_PROCESSED_INPUT : DWORD : 0x0001 +ENABLE_QUICK_EDIT_MODE : DWORD : 0x0040 +ENABLE_WINDOW_INPUT : DWORD : 0x0008 +ENABLE_VIRTUAL_TERMINAL_INPUT : DWORD : 0x0200 +ENABLE_PROCESSED_OUTPUT : DWORD : 0x0001 +ENABLE_WRAP_AT_EOL_OUTPUT : DWORD : 0x0002 ENABLE_VIRTUAL_TERMINAL_PROCESSING : DWORD : 0x0004 -DISABLE_NEWLINE_AUTO_RETURN : DWORD : 0x0008 -ENABLE_LVB_GRID_WORLDWIDE : DWORD : 0x0010 +DISABLE_NEWLINE_AUTO_RETURN : DWORD : 0x0008 +ENABLE_LVB_GRID_WORLDWIDE : DWORD : 0x0010 -CTRL_C_EVENT : DWORD : 0 -CTRL_BREAK_EVENT : DWORD : 1 -CTRL_CLOSE_EVENT : DWORD : 2 -CTRL_LOGOFF_EVENT : DWORD : 5 +CTRL_C_EVENT : DWORD : 0 +CTRL_BREAK_EVENT : DWORD : 1 +CTRL_CLOSE_EVENT : DWORD : 2 +CTRL_LOGOFF_EVENT : DWORD : 5 CTRL_SHUTDOWN_EVENT : DWORD : 6 COORD :: struct { @@ -4752,45 +4791,45 @@ COORD :: struct { } SMALL_RECT :: struct { - Left: SHORT, - Top: SHORT, - Right: SHORT, + Left: SHORT, + Top: SHORT, + Right: SHORT, Bottom: SHORT, } CONSOLE_SCREEN_BUFFER_INFO :: struct { - dwSize: COORD, - dwCursorPosition: COORD, - wAttributes: WORD, - srWindow: SMALL_RECT, + dwSize: COORD, + dwCursorPosition: COORD, + wAttributes: WORD, + srWindow: SMALL_RECT, dwMaximumWindowSize: COORD, } CONSOLE_CURSOR_INFO :: struct { - dwSize: DWORD, + dwSize: DWORD, bVisible: BOOL, } PCONSOLE_SCREEN_BUFFER_INFO :: ^CONSOLE_SCREEN_BUFFER_INFO -PCONSOLE_CURSOR_INFO :: ^CONSOLE_CURSOR_INFO +PCONSOLE_CURSOR_INFO :: ^CONSOLE_CURSOR_INFO Event_Type :: enum WORD { - KEY_EVENT = 0x0001, - MOUSE_EVENT = 0x0002, + KEY_EVENT = 0x0001, + MOUSE_EVENT = 0x0002, WINDOW_BUFFER_SIZE_EVENT = 0x0004, - MENU_EVENT = 0x0008, - FOCUS_EVENT = 0x0010, + MENU_EVENT = 0x0008, + FOCUS_EVENT = 0x0010, } INPUT_RECORD :: struct { EventType: Event_Type, Event: struct #raw_union { - KeyEvent: KEY_EVENT_RECORD, - MouseEvent: MOUSE_EVENT_RECORD, - WindowBufferSizeEvent: WINDOW_BUFFER_SIZE_RECORD, - MenuEvent: MENU_EVENT_RECORD, - FocusEvent: FOCUS_EVENT_RECORD, + KeyEvent: KEY_EVENT_RECORD `raw_union_tag:"EventType=KEY_EVENT"`, + MouseEvent: MOUSE_EVENT_RECORD `raw_union_tag:"EventType=MOUSE_EVENT"`, + WindowBufferSizeEvent: WINDOW_BUFFER_SIZE_RECORD `raw_union_tag:"EventType=WINDOW_BUFFER_SIZE_EVENT"`, + MenuEvent: MENU_EVENT_RECORD `raw_union_tag:"EventType=MENU_EVENT"`, + FocusEvent: FOCUS_EVENT_RECORD `raw_union_tag:"EventType=FOCUS_EVENT"`, }, } @@ -4820,10 +4859,10 @@ KEY_EVENT_RECORD :: struct { } MOUSE_EVENT_RECORD :: struct { - dwMousePosition: COORD, - dwButtonState: DWORD, + dwMousePosition: COORD, + dwButtonState: DWORD, dwControlKeyState: DWORD, - dwEventFlags: DWORD, + dwEventFlags: DWORD, } WINDOW_BUFFER_SIZE_RECORD :: struct { @@ -4949,16 +4988,16 @@ SO_SNDBUF : c_int : 0x1001 SO_ERROR : c_int : 0x1007 SO_BROADCAST : c_int : 0x0020 -TCP_NODELAY: c_int : 0x0001 -IP_TTL: c_int : 4 -IPV6_V6ONLY: c_int : 27 -IP_MULTICAST_LOOP: c_int : 11 -IPV6_MULTICAST_LOOP: c_int : 11 -IP_MULTICAST_TTL: c_int : 10 -IP_ADD_MEMBERSHIP: c_int : 12 +TCP_NODELAY : c_int : 0x0001 +IP_TTL : c_int : 4 +IPV6_V6ONLY : c_int : 27 +IP_MULTICAST_LOOP : c_int : 11 +IPV6_MULTICAST_LOOP : c_int : 11 +IP_MULTICAST_TTL : c_int : 10 +IP_ADD_MEMBERSHIP : c_int : 12 -IPV6_ADD_MEMBERSHIP: c_int : 12 -IPV6_DROP_MEMBERSHIP: c_int : 13 +IPV6_ADD_MEMBERSHIP : c_int : 12 +IPV6_DROP_MEMBERSHIP : c_int : 13 MAX_PROTOCOL_CHAIN: DWORD : 7 @@ -4972,8 +5011,8 @@ MSG_OOB : c_int : 1 // `send`/`recv` should process out-of-band data. MSG_PEEK : c_int : 2 // `recv` should not remove the data from the buffer. Only valid for non-overlapped operations. -SOCKET :: distinct uintptr // TODO -socklen_t :: c_int +SOCKET :: distinct uintptr // TODO +socklen_t :: c_int ADDRESS_FAMILY :: USHORT ip_mreq :: struct { @@ -4999,7 +5038,7 @@ ADDRINFOA :: struct { ai_socktype: c_int, ai_protocol: c_int, ai_addrlen: size_t, - ai_canonname: ^c_char, + ai_canonname: [^]c_char `fmt:"q,ai_addrlen"`, ai_addr: ^SOCKADDR, ai_next: ^ADDRINFOA, } @@ -5032,18 +5071,18 @@ in6_addr :: struct { } -DNS_STATUS :: distinct DWORD // zero is success -DNS_INFO_NO_RECORDS :: 9501 +DNS_STATUS :: distinct DWORD // zero is success +DNS_INFO_NO_RECORDS :: 9501 DNS_QUERY_NO_RECURSION :: 0x00000004 DNS_RECORD :: struct { // aka DNS_RECORDA - pNext: ^DNS_RECORD, - pName: cstring, - wType: WORD, + pNext: ^DNS_RECORD, + pName: cstring, + wType: WORD, wDataLength: USHORT, - Flags: DWORD, - dwTtl: DWORD, - _: DWORD, + Flags: DWORD, + dwTtl: DWORD, + _: DWORD, Data: struct #raw_union #align(4) { CNAME: DNS_PTR_DATAA, A: u32be, // Ipv4 Address @@ -5064,8 +5103,8 @@ DNS_PTR_DATAA :: cstring DNS_MX_DATAA :: struct { pNameExchange: cstring, // the hostname - wPreference: WORD, // lower values preferred - _: WORD, // padding. + wPreference: WORD, // lower values preferred + _: WORD, // padding. } DNS_SRV_DATAA :: struct { pNameTarget: cstring, @@ -5110,8 +5149,8 @@ ENUMRESTYPEPROCW :: #type proc (hModule: HMODULE, lpType: LPCWSTR, lParam: LONG_ ENUMRESLANGPROCW :: #type proc (hModule: HMODULE, lpType: LPCWSTR, lpName: LPWSTR, wIDLanguage: LANGID, lParam: LONG_PTR)-> BOOL DTR_Control :: enum byte { - Disable = 0, - Enable = 1, + Disable = 0, + Enable = 1, Handshake = 2, } RTS_Control :: enum byte { @@ -5128,9 +5167,9 @@ Parity :: enum byte { Space = 4, } Stop_Bits :: enum byte { - One = 0, + One = 0, One_And_A_Half = 1, - Two = 2, + Two = 2, } DCB :: struct { @@ -5166,34 +5205,34 @@ DCB :: struct { } COMMTIMEOUTS :: struct { - ReadIntervalTimeout: DWORD, - ReadTotalTimeoutMultiplier: DWORD, - ReadTotalTimeoutConstant: DWORD, + ReadIntervalTimeout: DWORD, + ReadTotalTimeoutMultiplier: DWORD, + ReadTotalTimeoutConstant: DWORD, WriteTotalTimeoutMultiplier: DWORD, - WriteTotalTimeoutConstant: DWORD, + WriteTotalTimeoutConstant: DWORD, } -Com_Stat_Bits :: enum { - fCtsHold, - fDsrHold, - fRlsdHold, - fXoffHold, - fXoffSent, - fEof, - fTxim, -} COMSTAT :: struct { - bits: bit_set[Com_Stat_Bits; DWORD], - cbInQue: DWORD, + using _: bit_field DWORD { + fCtsHold: BOOL | 1, + fDsrHold: BOOL | 1, + fRlsdHol: BOOL | 1, + fXoffHol: BOOL | 1, + fXoffSen: BOOL | 1, + fEof: BOOL | 1, + fTxim: BOOL | 1, + fReserved: DWORD | 25, + }, + cbInQue: DWORD, cbOutQue: DWORD, } -Com_Error_Bits :: enum { +Com_Error_Bits :: enum DWORD { RXOVER, OVERRUN, RXPARITY, FRAME, BREAK, } -Com_Error :: bit_set[Com_Error_Bits; DWORD] +Com_Error :: distinct bit_set[Com_Error_Bits; DWORD] diff --git a/core/sys/windows/user32.odin b/core/sys/windows/user32.odin index 76826f80b..580c09b45 100644 --- a/core/sys/windows/user32.odin +++ b/core/sys/windows/user32.odin @@ -2,12 +2,11 @@ package sys_windows import "base:intrinsics" -import "core:c" foreign import user32 "system:User32.lib" @(default_calling_convention="system") foreign user32 { - GetClassInfoW :: proc(hInstance: HINSTANCE, lpClassName: LPCWSTR, lpWndClass: ^WNDCLASSW) -> BOOL --- + GetClassInfoW :: proc(hInstance: HINSTANCE, lpClassName: LPCWSTR, lpWndClass: ^WNDCLASSW) -> BOOL --- GetClassInfoExW :: proc(hInstance: HINSTANCE, lpszClass: LPCWSTR, lpwcx: ^WNDCLASSEXW) -> BOOL --- GetClassLongW :: proc(hWnd: HWND, nIndex: INT) -> DWORD --- @@ -20,67 +19,68 @@ foreign user32 { GetParent :: proc(hWnd: HWND) -> HWND --- SetWinEventHook :: proc( - eventMin, eventMax: DWORD, - hmodWinEventProc: HMODULE, - pfnWinEvenProc: WINEVENTPROC, + eventMin, eventMax: DWORD, + hmodWinEventProc: HMODULE, + pfnWinEvenProc: WINEVENTPROC, idProcess, idThread: DWORD, - dwFlags: WinEventFlags, + dwFlags: WinEventFlags, ) -> HWINEVENTHOOK --- IsChild :: proc(hWndParent, hWnd: HWND) -> BOOL --- - RegisterClassW :: proc(lpWndClass: ^WNDCLASSW) -> ATOM --- + RegisterClassW :: proc(lpWndClass: ^WNDCLASSW) -> ATOM --- RegisterClassExW :: proc(^WNDCLASSEXW) -> ATOM --- UnregisterClassW :: proc(lpClassName: LPCWSTR, hInstance: HINSTANCE) -> BOOL --- - RegisterHotKey :: proc(hnwd: HWND, id: c.int, fsModifiers: UINT, vk: UINT) -> BOOL --- + RegisterHotKey :: proc(hnwd: HWND, id: c_int, fsModifiers: UINT, vk: UINT) -> BOOL --- CreateWindowExW :: proc( - dwExStyle: DWORD, - lpClassName: LPCWSTR, - lpWindowName: LPCWSTR, - dwStyle: DWORD, + dwExStyle: DWORD, + lpClassName: LPCWSTR, + lpWindowName: LPCWSTR, + dwStyle: DWORD, X, Y, nWidth, nHeight: INT, - hWndParent: HWND, - hMenu: HMENU, - hInstance: HINSTANCE, - lpParam: LPVOID, + hWndParent: HWND, + hMenu: HMENU, + hInstance: HINSTANCE, + lpParam: LPVOID, ) -> HWND --- GetWindowThreadProcessId :: proc(hwnd: HWND, lpdwProcessId: LPDWORD) -> DWORD --- DestroyWindow :: proc(hWnd: HWND) -> BOOL --- - ShowWindow :: proc(hWnd: HWND, nCmdShow: INT) -> BOOL --- - IsWindow :: proc(hWnd: HWND) -> BOOL --- - IsWindowVisible :: proc(hwnd: HWND) -> BOOL --- - IsWindowEnabled :: proc(hwnd: HWND) -> BOOL --- - IsIconic :: proc(hwnd: HWND) -> BOOL --- - IsZoomed :: proc(hwnd: HWND) -> BOOL --- - BringWindowToTop :: proc(hWnd: HWND) -> BOOL --- - GetTopWindow :: proc(hWnd: HWND) -> HWND --- + ShowWindow :: proc(hWnd: HWND, nCmdShow: INT) -> BOOL --- + IsWindow :: proc(hWnd: HWND) -> BOOL --- + IsWindowVisible :: proc(hwnd: HWND) -> BOOL --- + IsWindowEnabled :: proc(hwnd: HWND) -> BOOL --- + IsIconic :: proc(hwnd: HWND) -> BOOL --- + IsZoomed :: proc(hwnd: HWND) -> BOOL --- + BringWindowToTop :: proc(hWnd: HWND) -> BOOL --- + GetTopWindow :: proc(hWnd: HWND) -> HWND --- + GetWindow :: proc(hwnd: HWND, uCmd: UINT) -> HWND --- SetForegroundWindow :: proc(hWnd: HWND) -> BOOL --- GetForegroundWindow :: proc() -> HWND --- - GetDesktopWindow :: proc() -> HWND --- - UpdateWindow :: proc(hWnd: HWND) -> BOOL --- - SetActiveWindow :: proc(hWnd: HWND) -> HWND --- - GetActiveWindow :: proc() -> HWND --- - SetFocus :: proc(hWnd: HWND) -> HWND --- - GetFocus :: proc() -> HWND --- - RedrawWindow :: proc(hwnd: HWND, lprcUpdate: LPRECT, hrgnUpdate: HRGN, flags: RedrawWindowFlags) -> BOOL --- - SetParent :: proc(hWndChild: HWND, hWndNewParent: HWND) -> HWND --- - SetPropW :: proc(hWnd: HWND, lpString: LPCWSTR, hData: HANDLE) -> BOOL --- - GetPropW :: proc(hWnd: HWND, lpString: LPCWSTR) -> HANDLE --- - RemovePropW :: proc(hWnd: HWND, lpString: LPCWSTR) -> HANDLE --- - EnumPropsW :: proc(hWnd: HWND, lpEnumFunc: PROPENUMPROCW) -> INT --- - EnumPropsExW :: proc(hWnd: HWND, lpEnumFunc: PROPENUMPROCW, lParam: LPARAM) -> INT --- - GetMessageW :: proc(lpMsg: ^MSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT) -> INT --- + GetDesktopWindow :: proc() -> HWND --- + UpdateWindow :: proc(hWnd: HWND) -> BOOL --- + SetActiveWindow :: proc(hWnd: HWND) -> HWND --- + GetActiveWindow :: proc() -> HWND --- + SetFocus :: proc(hWnd: HWND) -> HWND --- + GetFocus :: proc() -> HWND --- + RedrawWindow :: proc(hwnd: HWND, lprcUpdate: LPRECT, hrgnUpdate: HRGN, flags: RedrawWindowFlags) -> BOOL --- + SetParent :: proc(hWndChild: HWND, hWndNewParent: HWND) -> HWND --- + SetPropW :: proc(hWnd: HWND, lpString: LPCWSTR, hData: HANDLE) -> BOOL --- + GetPropW :: proc(hWnd: HWND, lpString: LPCWSTR) -> HANDLE --- + RemovePropW :: proc(hWnd: HWND, lpString: LPCWSTR) -> HANDLE --- + EnumPropsW :: proc(hWnd: HWND, lpEnumFunc: PROPENUMPROCW) -> INT --- + EnumPropsExW :: proc(hWnd: HWND, lpEnumFunc: PROPENUMPROCW, lParam: LPARAM) -> INT --- + GetMessageW :: proc(lpMsg: ^MSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT) -> INT --- TranslateMessage :: proc(lpMsg: ^MSG) -> BOOL --- DispatchMessageW :: proc(lpMsg: ^MSG) -> LRESULT --- - WaitMessage :: proc() -> BOOL --- - MsgWaitForMultipleObjects :: proc(nCount: DWORD, pHandles: ^HANDLE, fWaitAll: BOOL, dwMilliseconds: DWORD, dwWakeMask: DWORD) -> DWORD --- + WaitMessage :: proc() -> BOOL --- + MsgWaitForMultipleObjects :: proc(nCount: DWORD, pHandles: [^]HANDLE, fWaitAll: BOOL, dwMilliseconds: DWORD, dwWakeMask: DWORD) -> DWORD --- PeekMessageA :: proc(lpMsg: ^MSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT, wRemoveMsg: UINT) -> BOOL --- PeekMessageW :: proc(lpMsg: ^MSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT, wRemoveMsg: UINT) -> BOOL --- @@ -100,97 +100,97 @@ foreign user32 { DefWindowProcA :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT --- DefWindowProcW :: proc(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT --- - FindWindowA :: proc(lpClassName: LPCSTR, lpWindowName: LPCSTR) -> HWND --- - FindWindowW :: proc(lpClassName: LPCWSTR, lpWindowName: LPCWSTR) -> HWND --- + FindWindowA :: proc(lpClassName: LPCSTR, lpWindowName: LPCSTR) -> HWND --- + FindWindowW :: proc(lpClassName: LPCWSTR, lpWindowName: LPCWSTR) -> HWND --- FindWindowExA :: proc(hWndParent: HWND, hWndChildAfter: HWND, lpszClass: LPCSTR, lpszWindow: LPCSTR) -> HWND --- FindWindowExW :: proc(hWndParent: HWND, hWndChildAfter: HWND, lpszClass: LPCWSTR, lpszWindow: LPCWSTR) -> HWND --- - LoadIconA :: proc(hInstance: HINSTANCE, lpIconName: LPCSTR) -> HICON --- - LoadIconW :: proc(hInstance: HINSTANCE, lpIconName: LPCWSTR) -> HICON --- + LoadIconA :: proc(hInstance: HINSTANCE, lpIconName: LPCSTR) -> HICON --- + LoadIconW :: proc(hInstance: HINSTANCE, lpIconName: LPCWSTR) -> HICON --- GetIconInfoExW :: proc(hIcon: HICON, piconinfo: PICONINFOEXW) -> BOOL --- - LoadCursorA :: proc(hInstance: HINSTANCE, lpCursorName: LPCSTR) -> HCURSOR --- - LoadCursorW :: proc(hInstance: HINSTANCE, lpCursorName: LPCWSTR) -> HCURSOR --- - LoadImageW :: proc(hInst: HINSTANCE, name: LPCWSTR, type: UINT, cx, cy: INT, fuLoad: UINT) -> HANDLE --- + LoadCursorA :: proc(hInstance: HINSTANCE, lpCursorName: LPCSTR) -> HCURSOR --- + LoadCursorW :: proc(hInstance: HINSTANCE, lpCursorName: LPCWSTR) -> HCURSOR --- + LoadImageW :: proc(hInst: HINSTANCE, name: LPCWSTR, type: UINT, cx, cy: INT, fuLoad: UINT) -> HANDLE --- - CreateIcon :: proc(hInstance: HINSTANCE, nWidth, nHeight: INT, cPlanes: BYTE, cBitsPixel: BYTE, lpbANDbits: PBYTE, lpbXORbits: PBYTE) -> HICON --- + CreateIcon :: proc(hInstance: HINSTANCE, nWidth, nHeight: INT, cPlanes: BYTE, cBitsPixel: BYTE, lpbANDbits: PBYTE, lpbXORbits: PBYTE) -> HICON --- CreateIconFromResource :: proc(presbits: PBYTE, dwResSize: DWORD, fIcon: BOOL, dwVer: DWORD) -> HICON --- - DestroyIcon :: proc(hIcon: HICON) -> BOOL --- - DrawIcon :: proc(hDC: HDC, X, Y: INT, hIcon: HICON) -> BOOL --- + DestroyIcon :: proc(hIcon: HICON) -> BOOL --- + DrawIcon :: proc(hDC: HDC, X, Y: INT, hIcon: HICON) -> BOOL --- - CreateCursor :: proc(hInst: HINSTANCE, xHotSpot, yHotSpot, nWidth, nHeight: INT, pvANDPlane: PVOID, pvXORPlane: PVOID) -> HCURSOR --- + CreateCursor :: proc(hInst: HINSTANCE, xHotSpot, yHotSpot, nWidth, nHeight: INT, pvANDPlane: PVOID, pvXORPlane: PVOID) -> HCURSOR --- DestroyCursor :: proc(hCursor: HCURSOR) -> BOOL --- - GetWindowRect :: proc(hWnd: HWND, lpRect: LPRECT) -> BOOL --- - GetClientRect :: proc(hWnd: HWND, lpRect: LPRECT) -> BOOL --- - ClientToScreen :: proc(hWnd: HWND, lpPoint: LPPOINT) -> BOOL --- - ScreenToClient :: proc(hWnd: HWND, lpPoint: LPPOINT) -> BOOL --- - SetWindowPos :: proc(hWnd: HWND, hWndInsertAfter: HWND, X, Y, cx, cy: INT, uFlags: UINT) -> BOOL --- - MoveWindow :: proc(hWnd: HWND, X, Y, hWidth, hHeight: INT, bRepaint: BOOL) -> BOOL --- - GetSystemMetrics :: proc(nIndex: INT) -> INT --- - AdjustWindowRect :: proc(lpRect: LPRECT, dwStyle: DWORD, bMenu: BOOL) -> BOOL --- - AdjustWindowRectEx :: proc(lpRect: LPRECT, dwStyle: DWORD, bMenu: BOOL, dwExStyle: DWORD) -> BOOL --- + GetWindowRect :: proc(hWnd: HWND, lpRect: LPRECT) -> BOOL --- + GetClientRect :: proc(hWnd: HWND, lpRect: LPRECT) -> BOOL --- + ClientToScreen :: proc(hWnd: HWND, lpPoint: LPPOINT) -> BOOL --- + ScreenToClient :: proc(hWnd: HWND, lpPoint: LPPOINT) -> BOOL --- + SetWindowPos :: proc(hWnd: HWND, hWndInsertAfter: HWND, X, Y, cx, cy: INT, uFlags: UINT) -> BOOL --- + MoveWindow :: proc(hWnd: HWND, X, Y, hWidth, hHeight: INT, bRepaint: BOOL) -> BOOL --- + GetSystemMetrics :: proc(nIndex: INT) -> INT --- + AdjustWindowRect :: proc(lpRect: LPRECT, dwStyle: DWORD, bMenu: BOOL) -> BOOL --- + AdjustWindowRectEx :: proc(lpRect: LPRECT, dwStyle: DWORD, bMenu: BOOL, dwExStyle: DWORD) -> BOOL --- AdjustWindowRectExForDpi :: proc(lpRect: LPRECT, dwStyle: DWORD, bMenu: BOOL, dwExStyle: DWORD, dpi: UINT) -> BOOL --- SystemParametersInfoW :: proc(uiAction, uiParam: UINT, pvParam: PVOID, fWinIni: UINT) -> BOOL --- - GetMonitorInfoW :: proc(hMonitor: HMONITOR, lpmi: LPMONITORINFO) -> BOOL --- + GetMonitorInfoW :: proc(hMonitor: HMONITOR, lpmi: LPMONITORINFO) -> BOOL --- GetWindowDC :: proc(hWnd: HWND) -> HDC --- - GetDC :: proc(hWnd: HWND) -> HDC --- - GetDCEx :: proc(hWnd: HWND, hrgnClip: HRGN, flags: DWORD) -> HDC --- - ReleaseDC :: proc(hWnd: HWND, hDC: HDC) -> INT --- + GetDC :: proc(hWnd: HWND) -> HDC --- + GetDCEx :: proc(hWnd: HWND, hrgnClip: HRGN, flags: DWORD) -> HDC --- + ReleaseDC :: proc(hWnd: HWND, hDC: HDC) -> INT --- GetDlgCtrlID :: proc(hWnd: HWND) -> INT --- - GetDlgItem :: proc(hDlg: HWND, nIDDlgItem: INT) -> HWND --- + GetDlgItem :: proc(hDlg: HWND, nIDDlgItem: INT) -> HWND --- - CreateMenu :: proc() -> HMENU --- - CreatePopupMenu :: proc() -> HMENU --- - DeleteMenu :: proc(hMenu: HMENU, uPosition: UINT, uFlags: UINT) -> BOOL --- - DestroyMenu :: proc(hMenu: HMENU) -> BOOL --- - InsertMenuW :: proc(hMenu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT_PTR, lpNewItem: LPCWSTR) -> BOOL --- - AppendMenuW :: proc(hMenu: HMENU, uFlags: UINT, uIDNewItem: UINT_PTR, lpNewItem: LPCWSTR) -> BOOL --- - GetMenu :: proc(hWnd: HWND) -> HMENU --- - SetMenu :: proc(hWnd: HWND, hMenu: HMENU) -> BOOL --- - TrackPopupMenu :: proc(hMenu: HMENU, uFlags: UINT, x, y: INT, nReserved: INT, hWnd: HWND, prcRect: ^RECT) -> INT --- + CreateMenu :: proc() -> HMENU --- + CreatePopupMenu :: proc() -> HMENU --- + DeleteMenu :: proc(hMenu: HMENU, uPosition: UINT, uFlags: UINT) -> BOOL --- + DestroyMenu :: proc(hMenu: HMENU) -> BOOL --- + InsertMenuW :: proc(hMenu: HMENU, uPosition: UINT, uFlags: UINT, uIDNewItem: UINT_PTR, lpNewItem: LPCWSTR) -> BOOL --- + AppendMenuW :: proc(hMenu: HMENU, uFlags: UINT, uIDNewItem: UINT_PTR, lpNewItem: LPCWSTR) -> BOOL --- + GetMenu :: proc(hWnd: HWND) -> HMENU --- + SetMenu :: proc(hWnd: HWND, hMenu: HMENU) -> BOOL --- + TrackPopupMenu :: proc(hMenu: HMENU, uFlags: UINT, x, y: INT, nReserved: INT, hWnd: HWND, prcRect: ^RECT) -> INT --- RegisterWindowMessageW :: proc(lpString: LPCWSTR) -> UINT --- CreateAcceleratorTableW :: proc(paccel: LPACCEL, cAccel: INT) -> HACCEL --- DestroyAcceleratorTable :: proc(hAccel: HACCEL) -> BOOL --- - LoadAcceleratorsW :: proc(hInstance: HINSTANCE, lpTableName: LPCWSTR) -> HACCEL --- - TranslateAcceleratorW :: proc(hWnd: HWND, hAccTable: HACCEL, lpMsg: LPMSG) -> INT --- - CopyAcceleratorTableW :: proc(hAccelSrc: HACCEL, lpAccelDst: LPACCEL, cAccelEntries: INT) -> INT --- + LoadAcceleratorsW :: proc(hInstance: HINSTANCE, lpTableName: LPCWSTR) -> HACCEL --- + TranslateAcceleratorW :: proc(hWnd: HWND, hAccTable: HACCEL, lpMsg: LPMSG) -> INT --- + CopyAcceleratorTableW :: proc(hAccelSrc: HACCEL, lpAccelDst: LPACCEL, cAccelEntries: INT) -> INT --- - InsertMenuItemW :: proc(hmenu: HMENU, item: UINT, fByPosition: BOOL, lpmi: LPMENUITEMINFOW) -> BOOL --- - GetMenuItemInfoW :: proc(hmenu: HMENU, item: UINT, fByPosition: BOOL, lpmii: LPMENUITEMINFOW) -> BOOL --- - SetMenuItemInfoW :: proc(hmenu: HMENU, item: UINT, fByPositon: BOOL, lpmii: LPMENUITEMINFOW) -> BOOL --- + InsertMenuItemW :: proc(hmenu: HMENU, item: UINT, fByPosition: BOOL, lpmi: LPMENUITEMINFOW) -> BOOL --- + GetMenuItemInfoW :: proc(hmenu: HMENU, item: UINT, fByPosition: BOOL, lpmii: LPMENUITEMINFOW) -> BOOL --- + SetMenuItemInfoW :: proc(hmenu: HMENU, item: UINT, fByPositon: BOOL, lpmii: LPMENUITEMINFOW) -> BOOL --- GetMenuDefaultItem :: proc(hMenu: HMENU, fByPos: UINT, gmdiFlags: UINT) -> UINT --- SetMenuDefaultItem :: proc(hMenu: HMENU, uItem: UINT, fByPos: UINT) -> BOOL --- - GetMenuItemRect :: proc(hWnd: HWND, hMenu: HMENU, uItem: UINT, lprcItem: LPRECT) -> c_int --- + GetMenuItemRect :: proc(hWnd: HWND, hMenu: HMENU, uItem: UINT, lprcItem: LPRECT) -> c_int --- - GetUpdateRect :: proc(hWnd: HWND, lpRect: LPRECT, bErase: BOOL) -> BOOL --- - ValidateRect :: proc(hWnd: HWND, lpRect: ^RECT) -> BOOL --- + GetUpdateRect :: proc(hWnd: HWND, lpRect: LPRECT, bErase: BOOL) -> BOOL --- + ValidateRect :: proc(hWnd: HWND, lpRect: ^RECT) -> BOOL --- InvalidateRect :: proc(hWnd: HWND, lpRect: ^RECT, bErase: BOOL) -> BOOL --- BeginPaint :: proc(hWnd: HWND, lpPaint: ^PAINTSTRUCT) -> HDC --- - EndPaint :: proc(hWnd: HWND, lpPaint: ^PAINTSTRUCT) -> BOOL --- + EndPaint :: proc(hWnd: HWND, lpPaint: ^PAINTSTRUCT) -> BOOL --- - GetCapture :: proc() -> HWND --- - SetCapture :: proc(hWnd: HWND) -> HWND --- - ReleaseCapture :: proc() -> BOOL --- + GetCapture :: proc() -> HWND --- + SetCapture :: proc(hWnd: HWND) -> HWND --- + ReleaseCapture :: proc() -> BOOL --- TrackMouseEvent :: proc(lpEventTrack: LPTRACKMOUSEEVENT) -> BOOL --- - GetKeyState :: proc(nVirtKey: INT) -> SHORT --- + GetKeyState :: proc(nVirtKey: INT) -> SHORT --- GetAsyncKeyState :: proc(vKey: INT) -> SHORT --- GetKeyboardState :: proc(lpKeyState: PBYTE) -> BOOL --- MapVirtualKeyW :: proc(uCode: UINT, uMapType: UINT) -> UINT --- - ToUnicode :: proc(nVirtKey: UINT, wScanCode: UINT, lpKeyState: ^BYTE, pwszBuff: LPWSTR, cchBuff: INT, wFlags: UINT) -> INT --- + ToUnicode :: proc(nVirtKey: UINT, wScanCode: UINT, lpKeyState: ^BYTE, pwszBuff: LPWSTR, cchBuff: INT, wFlags: UINT) -> INT --- - SetWindowsHookExW :: proc(idHook: INT, lpfn: HOOKPROC, hmod: HINSTANCE, dwThreadId: DWORD) -> HHOOK --- + SetWindowsHookExW :: proc(idHook: INT, lpfn: HOOKPROC, hmod: HINSTANCE, dwThreadId: DWORD) -> HHOOK --- UnhookWindowsHookEx :: proc(hhk: HHOOK) -> BOOL --- - CallNextHookEx :: proc(hhk: HHOOK, nCode: INT, wParam: WPARAM, lParam: LPARAM) -> LRESULT --- + CallNextHookEx :: proc(hhk: HHOOK, nCode: INT, wParam: WPARAM, lParam: LPARAM) -> LRESULT --- - SetTimer :: proc(hWnd: HWND, nIDEvent: UINT_PTR, uElapse: UINT, lpTimerFunc: TIMERPROC) -> UINT_PTR --- + SetTimer :: proc(hWnd: HWND, nIDEvent: UINT_PTR, uElapse: UINT, lpTimerFunc: TIMERPROC) -> UINT_PTR --- KillTimer :: proc(hWnd: HWND, uIDEvent: UINT_PTR) -> BOOL --- // MessageBoxA :: proc(hWnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT) -> INT --- @@ -198,143 +198,150 @@ foreign user32 { // MessageBoxExA :: proc(hWnd: HWND, lpText: LPCSTR, lpCaption: LPCSTR, uType: UINT, wLanguageId: WORD) -> INT --- MessageBoxExW :: proc(hWnd: HWND, lpText: LPCWSTR, lpCaption: LPCWSTR, uType: UINT, wLanguageId: WORD) -> INT --- - ClipCursor :: proc(lpRect: LPRECT) -> BOOL --- + ClipCursor :: proc(lpRect: LPRECT) -> BOOL --- GetCursorPos :: proc(lpPoint: LPPOINT) -> BOOL --- SetCursorPos :: proc(X, Y: INT) -> BOOL --- - SetCursor :: proc(hCursor: HCURSOR) -> HCURSOR --- + SetCursor :: proc(hCursor: HCURSOR) -> HCURSOR --- when !intrinsics.is_package_imported("raylib") { ShowCursor :: proc(bShow: BOOL) -> INT --- } - EnumDisplayDevicesW :: proc (lpDevice: LPCWSTR, iDevNum: DWORD, lpDisplayDevice: PDISPLAY_DEVICEW, dwFlags: DWORD) -> BOOL --- + EnumDisplayDevicesW :: proc(lpDevice: LPCWSTR, iDevNum: DWORD, lpDisplayDevice: PDISPLAY_DEVICEW, dwFlags: DWORD) -> BOOL --- EnumDisplaySettingsW :: proc(lpszDeviceName: LPCWSTR, iModeNum: DWORD, lpDevMode: ^DEVMODEW) -> BOOL --- - MonitorFromPoint :: proc(pt: POINT, dwFlags: Monitor_From_Flags) -> HMONITOR --- - MonitorFromRect :: proc(lprc: LPRECT, dwFlags: Monitor_From_Flags) -> HMONITOR --- - MonitorFromWindow :: proc(hwnd: HWND, dwFlags: Monitor_From_Flags) -> HMONITOR --- + MonitorFromPoint :: proc(pt: POINT, dwFlags: Monitor_From_Flags) -> HMONITOR --- + MonitorFromRect :: proc(lprc: LPRECT, dwFlags: Monitor_From_Flags) -> HMONITOR --- + MonitorFromWindow :: proc(hwnd: HWND, dwFlags: Monitor_From_Flags) -> HMONITOR --- EnumDisplayMonitors :: proc(hdc: HDC, lprcClip: LPRECT, lpfnEnum: Monitor_Enum_Proc, dwData: LPARAM) -> BOOL --- - EnumWindows :: proc(lpEnumFunc: Window_Enum_Proc, lParam: LPARAM) -> BOOL --- + EnumWindows :: proc(lpEnumFunc: Window_Enum_Proc, lParam: LPARAM) -> BOOL --- EnumChildWindows :: proc(hWndParent: HWND, lpEnumFunc: Window_Enum_Proc, lParam: LPARAM) -> BOOL --- - IsProcessDPIAware :: proc() -> BOOL --- + IsProcessDPIAware :: proc() -> BOOL --- SetProcessDPIAware :: proc() -> BOOL --- - SetThreadDpiAwarenessContext :: proc(dpiContext: DPI_AWARENESS_CONTEXT) -> DPI_AWARENESS_CONTEXT --- - GetThreadDpiAwarenessContext :: proc() -> DPI_AWARENESS_CONTEXT --- - GetWindowDpiAwarenessContext :: proc(hwnd: HWND) -> DPI_AWARENESS_CONTEXT --- + SetThreadDpiAwarenessContext :: proc(dpiContext: DPI_AWARENESS_CONTEXT) -> DPI_AWARENESS_CONTEXT --- + GetThreadDpiAwarenessContext :: proc() -> DPI_AWARENESS_CONTEXT --- + GetWindowDpiAwarenessContext :: proc(hwnd: HWND) -> DPI_AWARENESS_CONTEXT --- GetDpiFromDpiAwarenessContext :: proc(value: DPI_AWARENESS_CONTEXT) -> UINT --- - GetDpiForWindow :: proc(hwnd: HWND) -> UINT --- + GetDpiForWindow :: proc(hwnd: HWND) -> UINT --- SetProcessDpiAwarenessContext :: proc(value: DPI_AWARENESS_CONTEXT) -> BOOL --- BroadcastSystemMessageW :: proc( - flags: DWORD, + flags: DWORD, lpInfo: LPDWORD, - Msg: UINT, + Msg: UINT, wParam: WPARAM, lParam: LPARAM, ) -> c_long --- BroadcastSystemMessageExW :: proc( - flags: DWORD, - lpInfo: LPDWORD, - Msg: UINT, - wParam: WPARAM, - lParam: LPARAM, + flags: DWORD, + lpInfo: LPDWORD, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, pbsmInfo: PBSMINFO, ) -> c_long --- SendMessageTimeoutW :: proc( - hWnd: HWND, - Msg: UINT, - wParam: WPARAM, - lParam: LPARAM, - fuFlags: UINT, - uTimeout: UINT, + hWnd: HWND, + Msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + fuFlags: UINT, + uTimeout: UINT, lpdwResult: PDWORD_PTR, ) -> LRESULT --- - GetSysColor :: proc(nIndex: INT) -> DWORD --- + GetSysColor :: proc(nIndex: INT) -> DWORD --- GetSysColorBrush :: proc(nIndex: INT) -> HBRUSH --- - SetSysColors :: proc(cElements: INT, lpaElements: ^INT, lpaRgbValues: ^COLORREF) -> BOOL --- - MessageBeep :: proc(uType: UINT) -> BOOL --- + SetSysColors :: proc(cElements: INT, lpaElements: [^]INT, lpaRgbValues: ^COLORREF) -> BOOL --- + MessageBeep :: proc(uType: UINT) -> BOOL --- - IsDialogMessageW :: proc(hDlg: HWND, lpMsg: LPMSG) -> BOOL --- + IsDialogMessageW :: proc(hDlg: HWND, lpMsg: LPMSG) -> BOOL --- GetWindowTextLengthW :: proc(hWnd: HWND) -> INT --- - GetWindowTextW :: proc(hWnd: HWND, lpString: LPWSTR, nMaxCount: INT) -> INT --- - SetWindowTextW :: proc(hWnd: HWND, lpString: LPCWSTR) -> BOOL --- - CallWindowProcW :: proc(lpPrevWndFunc: WNDPROC, hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT --- - EnableWindow :: proc(hWnd: HWND, bEnable: BOOL) -> BOOL --- + GetWindowTextW :: proc(hWnd: HWND, lpString: LPWSTR, nMaxCount: INT) -> INT --- + SetWindowTextW :: proc(hWnd: HWND, lpString: LPCWSTR) -> BOOL --- + CallWindowProcW :: proc(lpPrevWndFunc: WNDPROC, hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT --- + EnableWindow :: proc(hWnd: HWND, bEnable: BOOL) -> BOOL --- - DefRawInputProc :: proc(paRawInput: ^PRAWINPUT, nInput: INT, cbSizeHeader: UINT) -> LRESULT --- - GetRawInputBuffer :: proc(pRawInput: PRAWINPUT, pcbSize: PUINT, cbSizeHeader: UINT) -> UINT --- - GetRawInputData :: proc(hRawInput: HRAWINPUT, uiCommand: UINT, pData: LPVOID, pcbSize: PUINT, cbSizeHeader: UINT) -> UINT --- - GetRawInputDeviceInfoW :: proc(hDevice: HANDLE, uiCommand: UINT, pData: LPVOID, pcbSize: PUINT) -> UINT --- - GetRawInputDeviceList :: proc(pRawInputDeviceList: PRAWINPUTDEVICELIST, puiNumDevices: PUINT, cbSize: UINT) -> UINT --- + DefRawInputProc :: proc(paRawInput: ^PRAWINPUT, nInput: INT, cbSizeHeader: UINT) -> LRESULT --- + GetRawInputBuffer :: proc(pRawInput: PRAWINPUT, pcbSize: PUINT, cbSizeHeader: UINT) -> UINT --- + GetRawInputData :: proc(hRawInput: HRAWINPUT, uiCommand: UINT, pData: LPVOID, pcbSize: PUINT, cbSizeHeader: UINT) -> UINT --- + GetRawInputDeviceInfoW :: proc(hDevice: HANDLE, uiCommand: UINT, pData: LPVOID, pcbSize: PUINT) -> UINT --- + GetRawInputDeviceList :: proc(pRawInputDeviceList: PRAWINPUTDEVICELIST, puiNumDevices: PUINT, cbSize: UINT) -> UINT --- GetRegisteredRawInputDevices :: proc(pRawInputDevices: PRAWINPUTDEVICE, puiNumDevices: PUINT, cbSize: UINT) -> UINT --- - RegisterRawInputDevices :: proc(pRawInputDevices: PCRAWINPUTDEVICE, uiNumDevices: UINT, cbSize: UINT) -> BOOL --- + RegisterRawInputDevices :: proc(pRawInputDevices: PCRAWINPUTDEVICE, uiNumDevices: UINT, cbSize: UINT) -> BOOL --- SendInput :: proc(cInputs: UINT, pInputs: [^]INPUT, cbSize: INT) -> UINT --- SetLayeredWindowAttributes :: proc(hWnd: HWND, crKey: COLORREF, bAlpha: BYTE, dwFlags: DWORD) -> BOOL --- - FillRect :: proc(hDC: HDC, lprc: ^RECT, hbr: HBRUSH) -> int --- - EqualRect :: proc(lprc1, lprc2: ^RECT) -> BOOL --- - OffsetRect :: proc(lprc1: ^RECT, dx, dy: INT) -> BOOL --- - InflateRect :: proc(lprc1: ^RECT, dx, dy: INT) -> BOOL --- + FillRect :: proc(hDC: HDC, lprc: ^RECT, hbr: HBRUSH) -> c_int --- + FrameRect :: proc(hDC: HDC, lprc: ^RECT, hbr: HBRUSH) -> c_int --- + InvertRect :: proc(hDC: HDC, lprc: ^RECT) -> BOOL --- + EqualRect :: proc(lprc1, lprc2: ^RECT) -> BOOL --- + OffsetRect :: proc(lprc1: ^RECT, dx, dy: INT) -> BOOL --- + InflateRect :: proc(lprc1: ^RECT, dx, dy: INT) -> BOOL --- IntersectRect :: proc(lprcDst, lprcSrc1, lprcSrc2: ^RECT) -> BOOL --- - SubtractRect :: proc(lprcDst, lprcSrc1, lprcSrc2: ^RECT) -> BOOL --- - UnionRect :: proc(lprcDst, lprcSrc1, lprcSrc2: ^RECT) -> BOOL --- - IsRectEmpty :: proc(lprc: ^RECT) -> BOOL --- - SetRectEmpty :: proc(lprc: ^RECT) -> BOOL --- - CopyRect :: proc(lprcDst, lprcSrc: ^RECT) -> BOOL --- + SubtractRect :: proc(lprcDst, lprcSrc1, lprcSrc2: ^RECT) -> BOOL --- + UnionRect :: proc(lprcDst, lprcSrc1, lprcSrc2: ^RECT) -> BOOL --- + IsRectEmpty :: proc(lprc: ^RECT) -> BOOL --- + SetRectEmpty :: proc(lprc: ^RECT) -> BOOL --- + CopyRect :: proc(lprcDst, lprcSrc: ^RECT) -> BOOL --- - GetWindowInfo :: proc(hwnd: HWND, pwi: PWINDOWINFO) -> BOOL --- - GetWindowPlacement :: proc(hWnd: HWND, lpwndpl: ^WINDOWPLACEMENT) -> BOOL --- - SetWindowPlacement :: proc(hwnd: HWND, lpwndpl: ^WINDOWPLACEMENT) -> BOOL --- - SetWindowRgn :: proc(hWnd: HWND, hRgn: HRGN, bRedraw: BOOL) -> int --- - CreateRectRgnIndirect :: proc(lprect: ^RECT) -> HRGN --- - GetSystemMetricsForDpi :: proc(nIndex: int, dpi: UINT) -> int --- + GetWindowInfo :: proc(hwnd: HWND, pwi: PWINDOWINFO) -> BOOL --- + GetWindowPlacement :: proc(hWnd: HWND, lpwndpl: ^WINDOWPLACEMENT) -> BOOL --- + SetWindowPlacement :: proc(hwnd: HWND, lpwndpl: ^WINDOWPLACEMENT) -> BOOL --- + SetWindowRgn :: proc(hWnd: HWND, hRgn: HRGN, bRedraw: BOOL) -> c_int --- + CreateRectRgnIndirect :: proc(lprect: ^RECT) -> HRGN --- + GetSystemMetricsForDpi :: proc(nIndex: c_int, dpi: UINT) -> c_int --- GetCursorInfo :: proc(pci: PCURSORINFO) -> BOOL --- - GetSystemMenu :: proc(hWnd: HWND, bRevert: BOOL) -> HMENU --- - EnableMenuItem :: proc(hMenu: HMENU, uIDEnableItem: UINT, uEnable: UINT) -> BOOL --- + GetSystemMenu :: proc(hWnd: HWND, bRevert: BOOL) -> HMENU --- + EnableMenuItem :: proc(hMenu: HMENU, uIDEnableItem: UINT, uEnable: UINT) -> BOOL --- MenuItemFromPoint :: proc(hWnd: HWND, hMenu: HMENU, ptScreen: POINT) -> INT --- - DrawTextW :: proc(hdc: HDC, lpchText: LPCWSTR, cchText: INT, lprc: LPRECT, format: DrawTextFormat) -> INT --- + DrawTextW :: proc(hdc: HDC, lpchText: LPCWSTR, cchText: INT, lprc: LPRECT, format: DrawTextFormat) -> INT --- DrawTextExW :: proc(hdc: HDC, lpchText: LPCWSTR, cchText: INT, lprc: LPRECT, format: DrawTextFormat, lpdtp: PDRAWTEXTPARAMS) -> INT --- - GetLocaleInfoEx :: proc(lpLocaleName: LPCWSTR, LCType: LCTYPE, lpLCData: LPWSTR, cchData: INT) -> INT --- + GetLocaleInfoEx :: proc(lpLocaleName: LPCWSTR, LCType: LCTYPE, lpLCData: LPWSTR, cchData: INT) -> INT --- IsValidLocaleName :: proc(lpLocaleName: LPCWSTR) -> BOOL --- ResolveLocaleName :: proc(lpNameToResolve: LPCWSTR, lpLocaleName: LPWSTR, cchLocaleName: INT) -> INT --- - IsValidCodePage :: proc(CodePage: UINT) -> BOOL --- - GetACP :: proc() -> CODEPAGE --- - GetCPInfoExW :: proc(CodePage: CODEPAGE, dwFlags: DWORD, lpCPInfoEx: LPCPINFOEXW) -> BOOL --- + IsValidCodePage :: proc(CodePage: UINT) -> BOOL --- + GetACP :: proc() -> CODEPAGE --- + GetCPInfoExW :: proc(CodePage: CODEPAGE, dwFlags: DWORD, lpCPInfoEx: LPCPINFOEXW) -> BOOL --- - GetProcessWindowStation :: proc() -> HWINSTA --- + GetProcessWindowStation :: proc() -> HWINSTA --- GetUserObjectInformationW :: proc(hObj: HANDLE, nIndex: GetUserObjectInformationFlags, pvInfo: PVOID, nLength: DWORD, lpnLengthNeeded: LPDWORD) -> BOOL --- - OpenClipboard :: proc(hWndNewOwner: HWND) -> BOOL --- - CloseClipboard :: proc() -> BOOL --- - GetClipboardData :: proc(uFormat: UINT) -> HANDLE --- - SetClipboardData :: proc(uFormat: UINT, hMem: HANDLE) -> HANDLE --- + OpenClipboard :: proc(hWndNewOwner: HWND) -> BOOL --- + CloseClipboard :: proc() -> BOOL --- + GetClipboardData :: proc(uFormat: UINT) -> HANDLE --- + SetClipboardData :: proc(uFormat: UINT, hMem: HANDLE) -> HANDLE --- IsClipboardFormatAvailable :: proc(format: UINT) -> BOOL --- - EmptyClipboard :: proc() -> BOOL --- + EmptyClipboard :: proc() -> BOOL --- + + SetScrollInfo :: proc(hwnd: HWND, nBar: c_int, lpsi: ^SCROLLINFO, redraw: BOOL) -> c_int --- + GetScrollInfo :: proc(hwnd: HWND, nBar: c_int, lpsi: ^SCROLLINFO) -> BOOL --- + ShowScrollBar :: proc(hwnd: HWND, nBar: c_int, bShow: BOOL) -> BOOL --- + EnableScrollBar :: proc(hwnd: HWND, wSBflags: UINT, wArrows: UINT) -> BOOL --- } CreateWindowW :: #force_inline proc "system" ( - lpClassName: LPCTSTR, + lpClassName: LPCTSTR, lpWindowName: LPCTSTR, - dwStyle: DWORD, - X: INT, - Y: INT, - nWidth: INT, - nHeight: INT, - hWndParent: HWND, - hMenu: HMENU, - hInstance: HINSTANCE, - lpParam: LPVOID, + dwStyle: DWORD, + X: INT, + Y: INT, + nWidth: INT, + nHeight: INT, + hWndParent: HWND, + hMenu: HMENU, + hInstance: HINSTANCE, + lpParam: LPVOID, ) -> HWND { return CreateWindowExW( 0, @@ -369,31 +376,38 @@ when ODIN_ARCH == .amd64 { SetWindowLongPtrW :: SetWindowLongW } +@(require_results) GET_SC_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> INT { return INT(wParam) & 0xFFF0 } +@(require_results) GET_WHEEL_DELTA_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> c_short { return cast(c_short)HIWORD(cast(DWORD)wParam) } +@(require_results) GET_KEYSTATE_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> WORD { return LOWORD(cast(DWORD)wParam) } +@(require_results) GET_NCHITTEST_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> c_short { return cast(c_short)LOWORD(cast(DWORD)wParam) } +@(require_results) GET_XBUTTON_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> WORD { return HIWORD(cast(DWORD)wParam) } // Retrieves the input code from wParam in WM_INPUT message. +@(require_results) GET_RAWINPUT_CODE_WPARAM :: #force_inline proc "contextless" (wParam: WPARAM) -> RAWINPUT_CODE { return RAWINPUT_CODE(wParam & 0xFF) } +@(require_results) MAKEINTRESOURCEW :: #force_inline proc "contextless" (#any_int i: int) -> LPWSTR { return cast(LPWSTR)uintptr(WORD(i)) } @@ -405,7 +419,7 @@ Monitor_From_Flags :: enum DWORD { } Monitor_Enum_Proc :: #type proc "system" (HMONITOR, HDC, LPRECT, LPARAM) -> BOOL -Window_Enum_Proc :: #type proc "system" (HWND, LPARAM) -> BOOL +Window_Enum_Proc :: #type proc "system" (HWND, LPARAM) -> BOOL USER_DEFAULT_SCREEN_DPI :: 96 DPI_AWARENESS_CONTEXT :: distinct HANDLE @@ -415,7 +429,7 @@ DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE :: DPI_AWARENESS_CONTEXT(~uintptr(2)) DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 :: DPI_AWARENESS_CONTEXT(~uintptr(3)) // -4 DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED :: DPI_AWARENESS_CONTEXT(~uintptr(4)) // -5 -RAWINPUT_CODE :: enum { +RAWINPUT_CODE :: enum DWORD { // The input is in the regular message flow, // the app is required to call DefWindowProc // so that the system can perform clean ups. @@ -426,16 +440,16 @@ RAWINPUT_CODE :: enum { } RAWINPUTHEADER :: struct { - dwType: DWORD, - dwSize: DWORD, + dwType: DWORD, + dwSize: DWORD, hDevice: HANDLE, - wParam: WPARAM, + wParam: WPARAM, } RAWHID :: struct { dwSizeHid: DWORD, - dwCount: DWORD, - bRawData: [1]BYTE, + dwCount: DWORD, + bRawData: [1]BYTE, } RAWMOUSE :: struct { @@ -447,27 +461,27 @@ RAWMOUSE :: struct { usButtonData: USHORT, }, }, - ulRawButtons: ULONG, - lLastX: LONG, - lLastY: LONG, + ulRawButtons: ULONG, + lLastX: LONG, + lLastY: LONG, ulExtraInformation: ULONG, } RAWKEYBOARD :: struct { - MakeCode: USHORT, - Flags: USHORT, - Rserved: USHORT, - VKey: USHORT, - Message: UINT, + MakeCode: USHORT, + Flags: USHORT, + Rserved: USHORT, + VKey: USHORT, + Message: UINT, ExtraInformation: ULONG, } RAWINPUT :: struct { header: RAWINPUTHEADER, data: struct #raw_union { - mouse: RAWMOUSE, + mouse: RAWMOUSE, keyboard: RAWKEYBOARD, - hid: RAWHID, + hid: RAWHID, }, } @@ -476,42 +490,42 @@ HRAWINPUT :: distinct LPARAM RAWINPUTDEVICE :: struct { usUsagePage: USHORT, - usUsage: USHORT, - dwFlags: DWORD, - hwndTarget: HWND, + usUsage: USHORT, + dwFlags: DWORD, + hwndTarget: HWND, } -PRAWINPUTDEVICE :: ^RAWINPUTDEVICE +PRAWINPUTDEVICE :: ^RAWINPUTDEVICE PCRAWINPUTDEVICE :: PRAWINPUTDEVICE RAWINPUTDEVICELIST :: struct { hDevice: HANDLE, - dwType: DWORD, + dwType: DWORD, } PRAWINPUTDEVICELIST :: ^RAWINPUTDEVICELIST RID_DEVICE_INFO_HID :: struct { - dwVendorId: DWORD, - dwProductId: DWORD, + dwVendorId: DWORD, + dwProductId: DWORD, dwVersionNumber: DWORD, - usUsagePage: USHORT, - usUsage: USHORT, + usUsagePage: USHORT, + usUsage: USHORT, } RID_DEVICE_INFO_KEYBOARD :: struct { - dwType: DWORD, - dwSubType: DWORD, - dwKeyboardMode: DWORD, + dwType: DWORD, + dwSubType: DWORD, + dwKeyboardMode: DWORD, dwNumberOfFunctionKeys: DWORD, - dwNumberOfIndicators: DWORD, - dwNumberOfKeysTotal: DWORD, + dwNumberOfIndicators: DWORD, + dwNumberOfKeysTotal: DWORD, } RID_DEVICE_INFO_MOUSE :: struct { - dwId: DWORD, - dwNumberOfButtons: DWORD, - dwSampleRate: DWORD, + dwId: DWORD, + dwNumberOfButtons: DWORD, + dwSampleRate: DWORD, fHasHorizontalWheel: BOOL, } @@ -519,103 +533,103 @@ RID_DEVICE_INFO :: struct { cbSize: DWORD, dwType: DWORD, using DUMMYUNIONNAME: struct #raw_union { - mouse: RID_DEVICE_INFO_MOUSE, - keyboard: RID_DEVICE_INFO_KEYBOARD, - hid: RID_DEVICE_INFO_HID, + mouse: RID_DEVICE_INFO_MOUSE `raw_union_tag:"dwType=0"`, + keyboard: RID_DEVICE_INFO_KEYBOARD `raw_union_tag:"dwType=1"`, + hid: RID_DEVICE_INFO_HID `raw_union_tag:"dwType=2"`, }, } -RIDEV_REMOVE :: 0x00000001 -RIDEV_EXCLUDE :: 0x00000010 -RIDEV_PAGEONLY :: 0x00000020 -RIDEV_NOLEGACY :: 0x00000030 -RIDEV_INPUTSINK :: 0x00000100 +RIDEV_REMOVE :: 0x00000001 +RIDEV_EXCLUDE :: 0x00000010 +RIDEV_PAGEONLY :: 0x00000020 +RIDEV_NOLEGACY :: 0x00000030 +RIDEV_INPUTSINK :: 0x00000100 RIDEV_CAPTUREMOUSE :: 0x00000200 -RIDEV_NOHOTKEYS :: 0x00000200 -RIDEV_APPKEYS :: 0x00000400 -RIDEV_EXINPUTSINK :: 0x00001000 -RIDEV_DEVNOTIFY :: 0x00002000 +RIDEV_NOHOTKEYS :: 0x00000200 +RIDEV_APPKEYS :: 0x00000400 +RIDEV_EXINPUTSINK :: 0x00001000 +RIDEV_DEVNOTIFY :: 0x00002000 RID_HEADER :: 0x10000005 -RID_INPUT :: 0x10000003 +RID_INPUT :: 0x10000003 RIDI_PREPARSEDDATA :: 0x20000005 -RIDI_DEVICENAME :: 0x20000007 -RIDI_DEVICEINFO :: 0x2000000b +RIDI_DEVICENAME :: 0x20000007 +RIDI_DEVICEINFO :: 0x2000000b -RIM_TYPEMOUSE :: 0 +RIM_TYPEMOUSE :: 0 RIM_TYPEKEYBOARD :: 1 -RIM_TYPEHID :: 2 +RIM_TYPEHID :: 2 -RI_KEY_MAKE :: 0 -RI_KEY_BREAK :: 1 -RI_KEY_E0 :: 2 -RI_KEY_E1 :: 4 +RI_KEY_MAKE :: 0 +RI_KEY_BREAK :: 1 +RI_KEY_E0 :: 2 +RI_KEY_E1 :: 4 RI_KEY_TERMSRV_SET_LED :: 8 -RI_KEY_TERMSRV_SHADOW :: 0x10 +RI_KEY_TERMSRV_SHADOW :: 0x10 -MOUSE_MOVE_RELATIVE :: 0x00 -MOUSE_MOVE_ABSOLUTE :: 0x01 -MOUSE_VIRTUAL_DESKTOP :: 0x02 +MOUSE_MOVE_RELATIVE :: 0x00 +MOUSE_MOVE_ABSOLUTE :: 0x01 +MOUSE_VIRTUAL_DESKTOP :: 0x02 MOUSE_ATTRIBUTES_CHANGED :: 0x04 -MOUSE_MOVE_NOCOALESCE :: 0x08 +MOUSE_MOVE_NOCOALESCE :: 0x08 -RI_MOUSE_BUTTON_1_DOWN :: 0x0001 -RI_MOUSE_LEFT_BUTTON_DOWN :: RI_MOUSE_BUTTON_1_DOWN -RI_MOUSE_BUTTON_1_UP :: 0x0002 -RI_MOUSE_LEFT_BUTTON_UP :: RI_MOUSE_BUTTON_1_UP -RI_MOUSE_BUTTON_2_DOWN :: 0x0004 -RI_MOUSE_RIGHT_BUTTON_DOWN :: RI_MOUSE_BUTTON_2_DOWN -RI_MOUSE_BUTTON_2_UP :: 0x0008 -RI_MOUSE_RIGHT_BUTTON_UP :: RI_MOUSE_BUTTON_2_UP -RI_MOUSE_BUTTON_3_DOWN :: 0x0010 +RI_MOUSE_BUTTON_1_DOWN :: 0x0001 +RI_MOUSE_LEFT_BUTTON_DOWN :: RI_MOUSE_BUTTON_1_DOWN +RI_MOUSE_BUTTON_1_UP :: 0x0002 +RI_MOUSE_LEFT_BUTTON_UP :: RI_MOUSE_BUTTON_1_UP +RI_MOUSE_BUTTON_2_DOWN :: 0x0004 +RI_MOUSE_RIGHT_BUTTON_DOWN :: RI_MOUSE_BUTTON_2_DOWN +RI_MOUSE_BUTTON_2_UP :: 0x0008 +RI_MOUSE_RIGHT_BUTTON_UP :: RI_MOUSE_BUTTON_2_UP +RI_MOUSE_BUTTON_3_DOWN :: 0x0010 RI_MOUSE_MIDDLE_BUTTON_DOWN :: RI_MOUSE_BUTTON_3_DOWN -RI_MOUSE_BUTTON_3_UP :: 0x0020 -RI_MOUSE_MIDDLE_BUTTON_UP :: RI_MOUSE_BUTTON_3_UP -RI_MOUSE_BUTTON_4_DOWN :: 0x0040 -RI_MOUSE_BUTTON_4_UP :: 0x0080 -RI_MOUSE_BUTTON_5_DOWN :: 0x0100 -RI_MOUSE_BUTTON_5_UP :: 0x0200 -RI_MOUSE_WHEEL :: 0x0400 -RI_MOUSE_HWHEEL :: 0x0800 +RI_MOUSE_BUTTON_3_UP :: 0x0020 +RI_MOUSE_MIDDLE_BUTTON_UP :: RI_MOUSE_BUTTON_3_UP +RI_MOUSE_BUTTON_4_DOWN :: 0x0040 +RI_MOUSE_BUTTON_4_UP :: 0x0080 +RI_MOUSE_BUTTON_5_DOWN :: 0x0100 +RI_MOUSE_BUTTON_5_UP :: 0x0200 +RI_MOUSE_WHEEL :: 0x0400 +RI_MOUSE_HWHEEL :: 0x0800 WINDOWPLACEMENT :: struct { - length: UINT, - flags: UINT, - showCmd: UINT, - ptMinPosition: POINT, - ptMaxPosition: POINT, + length: UINT, + flags: UINT, + showCmd: UINT, + ptMinPosition: POINT, + ptMaxPosition: POINT, rcNormalPosition: RECT, } WINDOWINFO :: struct { - cbSize: DWORD, - rcWindow: RECT, - rcClient: RECT, - dwStyle: DWORD, - dwExStyle: DWORD, - dwWindowStatus: DWORD, + cbSize: DWORD, + rcWindow: RECT, + rcClient: RECT, + dwStyle: DWORD, + dwExStyle: DWORD, + dwWindowStatus: DWORD, cxWindowBorders: UINT, cyWindowBorders: UINT, - atomWindowType: ATOM, + atomWindowType: ATOM, wCreatorVersion: WORD, } PWINDOWINFO :: ^WINDOWINFO CURSORINFO :: struct { - cbSize: DWORD, - flags: DWORD, - hCursor: HCURSOR, + cbSize: DWORD, + flags: DWORD, + hCursor: HCURSOR, ptScreenPos: POINT, } PCURSORINFO :: ^CURSORINFO DRAWTEXTPARAMS :: struct { - cbSize: UINT, - iTabLength: INT, - iLeftMargin: INT, - iRightMargin: INT, + cbSize: UINT, + iTabLength: INT, + iLeftMargin: INT, + iRightMargin: INT, uiLengthDrawn: UINT, } PDRAWTEXTPARAMS :: ^DRAWTEXTPARAMS @@ -673,12 +687,12 @@ GetUserObjectInformationFlags :: enum INT { } USEROBJECTFLAGS :: struct { - fInherit: BOOL, + fInherit: BOOL, fReserved: BOOL, - dwFlags: DWORD, + dwFlags: DWORD, } -PROPENUMPROCW :: #type proc(unnamedParam1: HWND, unnamedParam2: LPCWSTR, unnamedParam3: HANDLE) -> BOOL +PROPENUMPROCW :: #type proc(unnamedParam1: HWND, unnamedParam2: LPCWSTR, unnamedParam3: HANDLE) -> BOOL PROPENUMPROCEXW :: #type proc(unnamedParam1: HWND, unnamedParam2: LPCWSTR, unnamedParam3: HANDLE, unnamedParam4: ULONG_PTR) -> BOOL RT_CURSOR :: LPWSTR(uintptr(0x00000001)) @@ -713,8 +727,8 @@ MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID :: LPWSTR(uintptr(0x00000010) ACCEL :: struct { /* Also called the flags field */ fVirt: BYTE, - key: WORD, - cmd: WORD, + key: WORD, + cmd: WORD, } LPACCEL :: ^ACCEL @@ -730,32 +744,32 @@ MIIM_BITMAP :: 0x00000080 MIIM_FTYPE :: 0x00000100 MENUITEMINFOW :: struct { - cbSize: UINT, - fMask: UINT, - fType: UINT, // used if MIIM_TYPE (4.0) or MIIM_FTYPE (>4.0) - fState: UINT, // used if MIIM_STATE - wID: UINT, // used if MIIM_ID - hSubMenu: HMENU, // used if MIIM_SUBMENU - hbmpChecked: HBITMAP, // used if MIIM_CHECKMARKS + cbSize: UINT, + fMask: UINT, + fType: UINT, // used if MIIM_TYPE (4.0) or MIIM_FTYPE (>4.0) + fState: UINT, // used if MIIM_STATE + wID: UINT, // used if MIIM_ID + hSubMenu: HMENU, // used if MIIM_SUBMENU + hbmpChecked: HBITMAP, // used if MIIM_CHECKMARKS hbmpUnchecked: HBITMAP, // used if MIIM_CHECKMARKS - dwItemData: ULONG_PTR, // used if MIIM_DATA - dwTypeData: LPWSTR, // used if MIIM_TYPE (4.0) or MIIM_STRING (>4.0) - cch: UINT, // used if MIIM_TYPE (4.0) or MIIM_STRING (>4.0) - hbmpItem: HBITMAP, // used if MIIM_BITMAP + dwItemData: ULONG_PTR, // used if MIIM_DATA + dwTypeData: LPWSTR, // used if MIIM_TYPE (4.0) or MIIM_STRING (>4.0) + cch: UINT, // used if MIIM_TYPE (4.0) or MIIM_STRING (>4.0) + hbmpItem: HBITMAP, // used if MIIM_BITMAP } LPMENUITEMINFOW :: ^MENUITEMINFOW DISPLAY_DEVICEW :: struct { - cb: DWORD, - DeviceName: [32]WCHAR, + cb: DWORD, + DeviceName: [32]WCHAR, DeviceString: [128]WCHAR, - StateFlags: DWORD, - DeviceID: [128]WCHAR, - DeviceKey: [128]WCHAR, + StateFlags: DWORD, + DeviceID: [128]WCHAR, + DeviceKey: [128]WCHAR, } PDISPLAY_DEVICEW :: ^DISPLAY_DEVICEW // OUTOFCONTEXT is the zero value, use {} -WinEventFlags :: bit_set[WinEventFlag; DWORD] +WinEventFlags :: distinct bit_set[WinEventFlag; DWORD] WinEventFlag :: enum DWORD { SKIPOWNTHREAD = 0, @@ -792,7 +806,7 @@ CF_PRIVATEFIRST :: 0x0200 CF_PRIVATELAST :: 0x02FF STICKYKEYS :: struct { - cbSize: UINT, + cbSize: UINT, dwFlags: DWORD, } LPSTICKYKEYS :: ^STICKYKEYS @@ -822,7 +836,7 @@ SKF_LALTLATCHED :: 0x10000000 SKF_RALTLATCHED :: 0x20000000 TOGGLEKEYS :: struct { - cbSize: UINT, + cbSize: UINT, dwFlags: DWORD, } LPTOGGLEKEYS :: ^TOGGLEKEYS @@ -835,10 +849,10 @@ TKF_HOTKEYSOUND :: 0x10 TKF_INDICATOR :: 0x20 FILTERKEYS :: struct { - cbSize: UINT, - dwFlags: DWORD, - iWaitMSec: DWORD, - iDelayMSec: DWORD, + cbSize: UINT, + dwFlags: DWORD, + iWaitMSec: DWORD, + iDelayMSec: DWORD, iRepeatMSec: DWORD, iBounceMSec: DWORD, } @@ -853,24 +867,87 @@ FKF_INDICATOR :: 0x20 FKF_CLICKON :: 0x40 NONCLIENTMETRICSW :: struct { - cbSize: UINT, - iBorderWidth: i32, - iScrollWidth: i32, - iScrollHeight: i32, - iCaptionWidth: i32, - iCaptionHeight: i32, - lfCaptionFont: LOGFONTW, - iSmCaptionWidth: i32, - iSmCaptionHeight: i32, - lfSmCaptionFont: LOGFONTW, - iMenuWidth: i32, - iMenuHeight: i32, - lfMenuFont: LOGFONTW, - lfStatusFont: LOGFONTW, - lfMessageFont: LOGFONTW, - iPaddedBorderWidth: i32, + cbSize: UINT, + iBorderWidth: c_int, + iScrollWidth: c_int, + iScrollHeight: c_int, + iCaptionWidth: c_int, + iCaptionHeight: c_int, + lfCaptionFont: LOGFONTW, + iSmCaptionWidth: c_int, + iSmCaptionHeight: c_int, + lfSmCaptionFont: LOGFONTW, + iMenuWidth: c_int, + iMenuHeight: c_int, + lfMenuFont: LOGFONTW, + lfStatusFont: LOGFONTW, + lfMessageFont: LOGFONTW, + iPaddedBorderWidth: c_int, } LPNONCLIENTMETRICSW :: ^NONCLIENTMETRICSW LWA_COLORKEY :: 0x1 LWA_ALPHA :: 0x2 + +SCROLLINFO :: struct { + cbSize: UINT, + fMask: UINT, + nMin: c_int, + nMax: c_int, + nPage: UINT, + nPos: c_int, + nTrackPos: c_int, +} +LPSCROLLINFO :: ^SCROLLINFO + +// Scroll Bar Constants +SB_MIN :: 0 +SB_HORZ :: 0 +SB_VERT :: 1 +SB_CTL :: 2 +SB_BOTH :: 3 + +// Scroll Bar Commands +SB_LINEUP :: 0 +SB_LINELEFT :: 0 +SB_LINEDOWN :: 1 +SB_LINERIGHT :: 1 +SB_PAGEUP :: 2 +SB_PAGELEFT :: 2 +SB_PAGEDOWN :: 3 +SB_PAGERIGHT :: 3 +SB_THUMBPOSITION :: 4 +SB_THUMBTRACK :: 5 +SB_TOP :: 6 +SB_LEFT :: 6 +SB_BOTTOM :: 7 +SB_RIGHT :: 7 +SB_ENDSCROLL :: 8 + +// Constants for SCROLLINFO.fMask +SIF_RANGE :: 0x0001 +SIF_PAGE :: 0x0002 +SIF_POS :: 0x0004 +SIF_DISABLENOSCROLL :: 0x0008 +SIF_TRACKPOS :: 0x0010 +SIF_ALL :: (SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS) + +// EnableScrollBar() flags +ESB_ENABLE_BOTH :: 0x0000 +ESB_DISABLE_BOTH :: 0x0003 +ESB_DISABLE_LEFT :: 0x0001 +ESB_DISABLE_RIGHT :: 0x0002 +ESB_DISABLE_UP :: 0x0001 +ESB_DISABLE_DOWN :: 0x0002 +ESB_DISABLE_LTUP :: ESB_DISABLE_LEFT +ESB_DISABLE_RTDN :: ESB_DISABLE_RIGHT + +// Command constants for GetWindow +GW_HWNDFIRST :: 0 +GW_HWNDLAST :: 1 +GW_HWNDNEXT :: 2 +GW_HWNDPREV :: 3 +GW_OWNER :: 4 +GW_CHILD :: 5 +GW_ENABLEDPOPUP :: 6 +GW_MAX :: 6 diff --git a/core/sys/windows/userenv.odin b/core/sys/windows/userenv.odin index 2a2209d2c..1ed731407 100644 --- a/core/sys/windows/userenv.odin +++ b/core/sys/windows/userenv.odin @@ -5,19 +5,22 @@ foreign import userenv "system:Userenv.lib" @(default_calling_convention="system") foreign userenv { - GetUserProfileDirectoryW :: proc(hToken: HANDLE, - lpProfileDir: LPWSTR, - lpcchSize: ^DWORD) -> BOOL --- + GetUserProfileDirectoryW :: proc( + hToken: HANDLE, + lpProfileDir: LPWSTR, + lpcchSize: ^DWORD, + ) -> BOOL --- + LoadUserProfileW :: proc( - hToken: HANDLE, + hToken: HANDLE, lpProfileInfo: ^PROFILEINFOW, ) -> BOOL --- // https://docs.microsoft.com/en-us/windows/win32/api/userenv/nf-userenv-createprofile // The caller must have administrator privileges to call this function. CreateProfile :: proc( - pszUserSid: LPCWSTR, - pszUserName: LPCWSTR, + pszUserSid: LPCWSTR, + pszUserName: LPCWSTR, pszProfilePath: wstring, cchProfilePath: DWORD, ) -> u32 --- @@ -25,15 +28,15 @@ foreign userenv { // https://docs.microsoft.com/en-us/windows/win32/api/userenv/nf-userenv-deleteprofilew // The caller must have administrative privileges to delete a user's profile. DeleteProfileW :: proc( - lpSidString: LPCWSTR, - lpProfilePath: LPCWSTR, + lpSidString: LPCWSTR, + lpProfilePath: LPCWSTR, lpComputerName: LPCWSTR, ) -> BOOL --- // https://docs.microsoft.com/en-us/windows/win32/api/sddl/nf-sddl-convertsidtostringsida // To turn a SID into a string SID to use with CreateProfile & DeleteProfileW. ConvertSidToStringSidW :: proc( - Sid: ^SID, + Sid: ^SID, StringSid: ^LPCWSTR, ) -> BOOL --- } diff --git a/core/sys/windows/util.odin b/core/sys/windows/util.odin index 125038ac4..8cabdeb04 100644 --- a/core/sys/windows/util.odin +++ b/core/sys/windows/util.odin @@ -7,74 +7,89 @@ import "base:intrinsics" L :: intrinsics.constant_utf16_cstring // https://learn.microsoft.com/en-us/windows/win32/winmsg/makeword +@(require_results) MAKEWORD :: #force_inline proc "contextless" (#any_int a, b: int) -> WORD { return WORD(BYTE(DWORD_PTR(a) & 0xff)) | (WORD(BYTE(DWORD_PTR(b) & 0xff)) << 8) } // https://learn.microsoft.com/en-us/windows/win32/winmsg/makelong +@(require_results) MAKELONG :: #force_inline proc "contextless" (#any_int a, b: int) -> LONG { return LONG(WORD(DWORD_PTR(a) & 0xffff)) | (LONG(WORD(DWORD_PTR(b) & 0xffff)) << 16) } // https://learn.microsoft.com/en-us/windows/win32/winmsg/loword +@(require_results) LOWORD :: #force_inline proc "contextless" (#any_int x: int) -> WORD { return WORD(x & 0xffff) } // https://learn.microsoft.com/en-us/windows/win32/winmsg/hiword +@(require_results) HIWORD :: #force_inline proc "contextless" (#any_int x: int) -> WORD { return WORD(x >> 16) } // https://learn.microsoft.com/en-us/windows/win32/winmsg/lobyte +@(require_results) LOBYTE :: #force_inline proc "contextless" (w: WORD) -> BYTE { return BYTE((DWORD_PTR(w)) & 0xff) } // https://learn.microsoft.com/en-us/windows/win32/winmsg/hibyte +@(require_results) HIBYTE :: #force_inline proc "contextless" (w: WORD) -> BYTE { return BYTE(((DWORD_PTR(w)) >> 8) & 0xff) } // https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-makewparam +@(require_results) MAKEWPARAM :: #force_inline proc "contextless" (#any_int l, h: int) -> WPARAM { return WPARAM(MAKELONG(l, h)) } // https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-makelparam +@(require_results) MAKELPARAM :: #force_inline proc "contextless" (#any_int l, h: int) -> LPARAM { return LPARAM(MAKELONG(l, h)) } // https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-makelresult +@(require_results) MAKELRESULT :: #force_inline proc "contextless" (#any_int l, h: int) -> LRESULT { return LRESULT(MAKELONG(l, h)) } // https://learn.microsoft.com/en-us/windows/win32/api/windowsx/nf-windowsx-get_x_lparam +@(require_results) GET_X_LPARAM :: #force_inline proc "contextless" (lp: LPARAM) -> c_int { return cast(c_int)cast(c_short)LOWORD(cast(DWORD)lp) } // https://learn.microsoft.com/en-us/windows/win32/api/windowsx/nf-windowsx-get_y_lparam +@(require_results) GET_Y_LPARAM :: #force_inline proc "contextless" (lp: LPARAM) -> c_int { return cast(c_int)cast(c_short)HIWORD(cast(DWORD)lp) } // https://learn.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-makelcid +@(require_results) MAKELCID :: #force_inline proc "contextless" (lgid, srtid: WORD) -> LCID { return (DWORD(WORD(srtid)) << 16) | DWORD(WORD(lgid)) } // https://learn.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-makelangid +@(require_results) MAKELANGID :: #force_inline proc "contextless" (p, s: WORD) -> DWORD { return DWORD(WORD(s)) << 10 | DWORD(WORD(p)) } +@(require_results) LANGIDFROMLCID :: #force_inline proc "contextless" (lcid: LCID) -> LANGID { return LANGID(lcid) } +@(require_results) utf8_to_utf16_alloc :: proc(s: string, allocator := context.temp_allocator) -> []u16 { if len(s) < 1 { return nil @@ -82,14 +97,14 @@ utf8_to_utf16_alloc :: proc(s: string, allocator := context.temp_allocator) -> [ b := transmute([]byte)s cstr := raw_data(b) - n := MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, cstr, i32(len(s)), nil, 0) + n := MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, cstr, c_int(len(s)), nil, 0) if n == 0 { return nil } text := make([]u16, n+1, allocator) - n1 := MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, cstr, i32(len(s)), raw_data(text), n) + n1 := MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, cstr, c_int(len(s)), raw_data(text), n) if n1 == 0 { delete(text, allocator) return nil @@ -102,15 +117,16 @@ utf8_to_utf16_alloc :: proc(s: string, allocator := context.temp_allocator) -> [ return text[:n] } +@(require_results) utf8_to_utf16_buf :: proc(buf: []u16, s: string) -> []u16 { - n1 := MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, raw_data(s), i32(len(s)), nil, 0) + n1 := MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, raw_data(s), c_int(len(s)), nil, 0) if n1 == 0 { return nil } else if int(n1) > len(buf) { return nil } - n1 = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, raw_data(s), i32(len(s)), raw_data(buf[:]), n1) + n1 = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, raw_data(s), c_int(len(s)), raw_data(buf[:]), n1) if n1 == 0 { return nil } else if int(n1) > len(buf) { @@ -120,6 +136,7 @@ utf8_to_utf16_buf :: proc(buf: []u16, s: string) -> []u16 { } utf8_to_utf16 :: proc{utf8_to_utf16_alloc, utf8_to_utf16_buf} +@(require_results) utf8_to_wstring_alloc :: proc(s: string, allocator := context.temp_allocator) -> wstring { if res := utf8_to_utf16(s, allocator); len(res) > 0 { return wstring(raw_data(res)) @@ -127,6 +144,7 @@ utf8_to_wstring_alloc :: proc(s: string, allocator := context.temp_allocator) -> return nil } +@(require_results) utf8_to_wstring_buf :: proc(buf: []u16, s: string) -> wstring { if res := utf8_to_utf16(buf, s); len(res) > 0 { return wstring(raw_data(res)) @@ -136,6 +154,7 @@ utf8_to_wstring_buf :: proc(buf: []u16, s: string) -> wstring { utf8_to_wstring :: proc{utf8_to_wstring_alloc, utf8_to_wstring_buf} +@(require_results) wstring_to_utf8_alloc :: proc(s: wstring, N: int, allocator := context.temp_allocator) -> (res: string, err: runtime.Allocator_Error) { context.allocator = allocator @@ -143,7 +162,7 @@ wstring_to_utf8_alloc :: proc(s: wstring, N: int, allocator := context.temp_allo return } - n := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, i32(N) if N > 0 else -1, nil, 0, nil, nil) + n := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, c_int(N) if N > 0 else -1, nil, 0, nil, nil) if n == 0 { return } @@ -155,7 +174,7 @@ wstring_to_utf8_alloc :: proc(s: wstring, N: int, allocator := context.temp_allo // will not be null terminated. text := make([]byte, n) or_return - n1 := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, i32(N), raw_data(text), n, nil, nil) + n1 := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, c_int(N), raw_data(text), n, nil, nil) if n1 == 0 { delete(text, allocator) return @@ -170,15 +189,16 @@ wstring_to_utf8_alloc :: proc(s: wstring, N: int, allocator := context.temp_allo return string(text[:n]), nil } +@(require_results) wstring_to_utf8_buf :: proc(buf: []u8, s: wstring, N := -1) -> (res: string) { - n := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, i32(N), nil, 0, nil, nil) + n := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, c_int(N), nil, 0, nil, nil) if n == 0 { return } else if int(n) > len(buf) { return } - n2 := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, i32(N), raw_data(buf), n, nil, nil) + n2 := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, c_int(N), raw_data(buf), n, nil, nil) if n2 == 0 { return } else if int(n2) > len(buf) { @@ -211,6 +231,7 @@ Returns: - res: A cloned and converted string - err: An optional allocator error if one occured, `nil` otherwise */ +@(require_results) utf16_to_utf8_alloc :: proc(s: []u16, allocator := context.temp_allocator) -> (res: string, err: runtime.Allocator_Error) { if len(s) == 0 { return "", nil @@ -232,6 +253,7 @@ Inputs: Returns: - res: A converted string, backed byu `buf` */ +@(require_results) utf16_to_utf8_buf :: proc(buf: []u8, s: []u16) -> (res: string) { if len(s) == 0 { return @@ -244,8 +266,9 @@ utf16_to_utf8 :: proc{utf16_to_utf8_alloc, utf16_to_utf8_buf} // AdvAPI32, NetAPI32 and UserENV helpers. -allowed_username :: proc(username: string) -> bool { - contains_any :: proc(s, chars: string) -> bool { +@(require_results) +allowed_username :: proc "contextless" (username: string) -> bool { + contains_any :: proc "contextless" (s, chars: string) -> bool { if chars == "" { return false } @@ -287,8 +310,8 @@ allowed_username :: proc(username: string) -> bool { } // Returns .Success on success. +@(require_results) _add_user :: proc(servername: string, username: string, password: string) -> (ok: NET_API_STATUS) { - servername_w: wstring username_w: []u16 password_w: []u16 @@ -339,8 +362,8 @@ _add_user :: proc(servername: string, username: string, password: string) -> (ok return } +@(require_results) get_computer_name_and_account_sid :: proc(username: string) -> (computer_name: string, sid := SID{}, ok: bool) { - username_w := utf8_to_utf16(username, context.temp_allocator) cbsid: DWORD computer_name_size: DWORD @@ -381,8 +404,8 @@ get_computer_name_and_account_sid :: proc(username: string) -> (computer_name: s return } +@(require_results) get_sid :: proc(username: string, sid: ^SID) -> (ok: bool) { - username_w := utf8_to_utf16(username, context.temp_allocator) cbsid: DWORD computer_name_size: DWORD @@ -451,6 +474,7 @@ add_del_from_group :: proc(sid: ^SID, group: string) -> (ok: NET_API_STATUS) { return } +@(require_results) add_user_profile :: proc(username: string) -> (ok: bool, profile_path: string) { username_w := utf8_to_utf16(username, context.temp_allocator) diff --git a/core/sys/windows/ux_theme.odin b/core/sys/windows/ux_theme.odin index 679d9998f..e19800246 100644 --- a/core/sys/windows/ux_theme.odin +++ b/core/sys/windows/ux_theme.odin @@ -3,11 +3,73 @@ package sys_windows foreign import uxtheme "system:UxTheme.lib" -MARGINS :: distinct [4]i32 +MARGINS :: struct { + cxLeftWidth: c_int, + cxRightWidth: c_int, + cyTopHeight: c_int, + cyBottomHeight: c_int, +} PMARGINS :: ^MARGINS @(default_calling_convention="system") foreign uxtheme { - IsThemeActive :: proc() -> BOOL --- - SetWindowTheme :: proc(hWnd: HWND, pszSubAppName, pszSubIdList: LPCWSTR) -> HRESULT --- + IsThemeActive :: proc() -> BOOL --- + GetWindowTheme :: proc(hwnd: HWND) -> HTHEME --- + SetWindowTheme :: proc(hWnd: HWND, pszSubAppName, pszSubIdList: LPCWSTR) -> HRESULT --- + + // Buffered painting and buffered animation + BufferedPaintInit :: proc() -> HRESULT --- + BufferedPaintUnInit :: proc() -> HRESULT --- + + BeginBufferedPaint :: proc(hdcTarget: HDC, prcTarget: ^RECT, dwFormat: BP_BUFFERFORMAT, pPaintParams: ^BP_PAINTPARAMS, phdc: ^HDC) -> HPAINTBUFFER --- + EndBufferedPaint :: proc(hBufferedPaint: HPAINTBUFFER, fUpdateTarget: BOOL) -> HRESULT --- + + GetBufferedPaintTargetRect :: proc(hBufferedPaint: HPAINTBUFFER, prc: ^RECT) -> HRESULT --- + GetBufferedPaintTargetDC :: proc(hBufferedPaint: HPAINTBUFFER) -> HDC --- + GetBufferedPaintDC :: proc(hBufferedPaint: HPAINTBUFFER) -> HDC --- + GetBufferedPaintBits :: proc(hBufferedPaint, ppbBuffer: ^[^]RGBQUAD, pcxRow: ^c_int) -> HRESULT --- + + BufferedPaintClear :: proc(hBufferedPaint: HPAINTBUFFER, prc: ^RECT) -> HRESULT --- + BufferedPaintSetAlpha :: proc(hBufferedPaint: HPAINTBUFFER, prc: ^RECT, alpha: BYTE) -> HRESULT --- + + BufferedPaintStopAllAnimations :: proc(hwnd: HWND) -> HRESULT --- + BeginBufferedAnimation :: proc(hwnd: HWND, hdcTarget: HDC, prcTarget: ^RECT, dwFormat: BP_BUFFERFORMAT, pPaintParams: ^BP_PAINTPARAMS, pAnimationParams: ^BP_ANIMATIONPARAMS, phdcFrom: ^HDC, phdcTo: ^HDC) -> HANIMATIONBUFFER --- + BufferedPaintRenderAnimation :: proc(hwnd: HWND, hdcTarget: HDC) -> BOOL --- +} + +HTHEME :: distinct HANDLE +HPAINTBUFFER :: distinct HANDLE +HANIMATIONBUFFER :: distinct HANDLE + +BP_BUFFERFORMAT :: enum c_int { + BPBF_COMPATIBLEBITMAP, + BPBF_DIB, + BPBF_TOPDOWNDIB, + BPBF_TOPDOWNMONODIB, +} + +BP_ANIMATIONSTYLE :: enum c_int { + BPAS_NONE, + BPAS_LINEAR, + BPAS_CUBIC, + BPAS_SINE, +} + +// Constants for BP_PAINTPARAMS.dwFlags +BPPF_ERASE :: 0x0001 +BPPF_NOCLIP :: 0x0002 +BPPF_NONCLIENT :: 0x0004 + +BP_ANIMATIONPARAMS :: struct { + cbSize: DWORD, + dwFlags: DWORD, + style: BP_ANIMATIONSTYLE, + dwDuration: DWORD, +} + +BP_PAINTPARAMS :: struct { + cbSize: DWORD, + dwFlags: DWORD, + prcExclude: ^RECT, + pBlendFunction: ^BLENDFUNCTION, } diff --git a/core/sys/windows/wgl.odin b/core/sys/windows/wgl.odin index f50f06939..532a987eb 100644 --- a/core/sys/windows/wgl.odin +++ b/core/sys/windows/wgl.odin @@ -1,8 +1,6 @@ #+build windows package sys_windows -import "core:c" - foreign import "system:Opengl32.lib" CONTEXT_MAJOR_VERSION_ARB :: 0x2091 @@ -54,9 +52,9 @@ GLYPHMETRICSFLOAT :: struct { gmfCellIncY: f32, } -CreateContextAttribsARBType :: #type proc "c" (hdc: HDC, hShareContext: rawptr, attribList: [^]c.int) -> HGLRC -ChoosePixelFormatARBType :: #type proc "c" (hdc: HDC, attribIList: [^]c.int, attribFList: [^]f32, maxFormats: DWORD, formats: [^]c.int, numFormats: [^]DWORD) -> BOOL -SwapIntervalEXTType :: #type proc "c" (interval: c.int) -> bool +CreateContextAttribsARBType :: #type proc "c" (hdc: HDC, hShareContext: rawptr, attribList: [^]c_int) -> HGLRC +ChoosePixelFormatARBType :: #type proc "c" (hdc: HDC, attribIList: [^]c_int, attribFList: [^]f32, maxFormats: DWORD, formats: [^]c_int, numFormats: [^]DWORD) -> BOOL +SwapIntervalEXTType :: #type proc "c" (interval: c_int) -> bool GetExtensionsStringARBType :: #type proc "c" (HDC) -> cstring // Procedures @@ -73,18 +71,18 @@ foreign Opengl32 { wglGetProcAddress :: proc(c_str: cstring) -> rawptr --- wglDeleteContext :: proc(HGLRC: HGLRC) -> BOOL --- wglCopyContext :: proc(src, dst: HGLRC, mask: UINT) -> BOOL --- - wglCreateLayerContext :: proc(hdc: HDC, layer_plane: c.int) -> HGLRC --- - wglDescribeLayerPlane :: proc(hdc: HDC, pixel_format, layer_plane: c.int, bytes: UINT, pd: LPLAYERPLANEDESCRIPTOR) -> BOOL --- + wglCreateLayerContext :: proc(hdc: HDC, layer_plane: c_int) -> HGLRC --- + wglDescribeLayerPlane :: proc(hdc: HDC, pixel_format, layer_plane: c_int, bytes: UINT, pd: LPLAYERPLANEDESCRIPTOR) -> BOOL --- wglGetCurrentContext :: proc() -> HGLRC --- wglGetCurrentDC :: proc() -> HDC --- - wglGetLayerPaletteEntries :: proc(hdc: HDC, layer_plane, start, entries: c.int, cr: ^COLORREF) -> c.int --- - wglRealizeLayerPalette :: proc(hdc: HDC, layer_plane: c.int, realize: BOOL) -> BOOL --- - wglSetLayerPaletteEntries :: proc(hdc: HDC, layer_plane, start, entries: c.int, cr: ^COLORREF) -> c.int --- + wglGetLayerPaletteEntries :: proc(hdc: HDC, layer_plane, start, entries: c_int, cr: ^COLORREF) -> c_int --- + wglRealizeLayerPalette :: proc(hdc: HDC, layer_plane: c_int, realize: BOOL) -> BOOL --- + wglSetLayerPaletteEntries :: proc(hdc: HDC, layer_plane, start, entries: c_int, cr: ^COLORREF) -> c_int --- wglShareLists :: proc(HGLRC1, HGLRC2: HGLRC) -> BOOL --- wglSwapLayerBuffers :: proc(hdc: HDC, planes: DWORD) -> BOOL --- wglUseFontBitmapsA :: proc(hdc: HDC, first, count, list_base: DWORD) -> BOOL --- wglUseFontBitmapsW :: proc(hdc: HDC, first, count, list_base: DWORD) -> BOOL --- - wglUseFontOutlines :: proc(hdc: HDC, first, count, list_base: DWORD, deviation, extrusion: f32, format: c.int, gmf: LPGLYPHMETRICSFLOAT) -> BOOL --- + wglUseFontOutlines :: proc(hdc: HDC, first, count, list_base: DWORD, deviation, extrusion: f32, format: c_int, gmf: LPGLYPHMETRICSFLOAT) -> BOOL --- } // Used by vendor:OpenGL @@ -93,7 +91,7 @@ gl_set_proc_address :: proc(p: rawptr, name: cstring) { func := wglGetProcAddress(name) switch uintptr(func) { case 0, 1, 2, 3, ~uintptr(0): - module := LoadLibraryW(L("opengl32.dll")) + module := LoadLibraryW("opengl32.dll") func = GetProcAddress(module, name) } (^rawptr)(p)^ = func diff --git a/core/sys/windows/winerror.odin b/core/sys/windows/winerror.odin index 23467761d..2807ca0f8 100644 --- a/core/sys/windows/winerror.odin +++ b/core/sys/windows/winerror.odin @@ -248,6 +248,13 @@ E_HANDLE :: 0x80070006 // Handle that is not valid E_OUTOFMEMORY :: 0x8007000E // Failed to allocate necessary memory E_INVALIDARG :: 0x80070057 // One or more arguments are not valid +SEC_E_INCOMPLETE_MESSAGE :: 0x80090318 + +SEC_I_INCOMPLETE_CREDENTIALS :: 0x00090320 +SEC_I_CONTINUE_NEEDED :: 0x00090312 +SEC_I_CONTEXT_EXPIRED :: 0x00090317 +SEC_I_RENEGOTIATE :: 0x00090321 + // Severity values SEVERITY :: enum DWORD { SUCCESS = 0, diff --git a/core/sys/windows/winmm.odin b/core/sys/windows/winmm.odin index b85548b85..d1848cb7b 100644 --- a/core/sys/windows/winmm.odin +++ b/core/sys/windows/winmm.odin @@ -12,28 +12,28 @@ foreign winmm { timeEndPeriod :: proc(uPeriod: UINT) -> MMRESULT --- timeGetTime :: proc() -> DWORD --- - waveOutGetNumDevs :: proc() -> UINT --- - waveOutGetDevCapsW :: proc(uDeviceID: UINT_PTR, pwoc: LPWAVEOUTCAPSW, cbwoc: UINT) -> MMRESULT --- - waveOutGetVolume :: proc(hwo: HWAVEOUT, pdwVolume: LPDWORD) -> MMRESULT --- - waveOutSetVolume :: proc(hwo: HWAVEOUT, dwVolume: DWORD) -> MMRESULT --- - waveOutGetErrorTextW :: proc(mmrError: MMRESULT, pszText: LPWSTR, cchText: UINT) -> MMRESULT --- - waveOutOpen :: proc(phwo: LPHWAVEOUT, uDeviceID: UINT, pwfx: LPCWAVEFORMATEX, dwCallback: DWORD_PTR, dwInstance: DWORD_PTR, fdwOpen: DWORD) -> MMRESULT --- - waveOutClose :: proc(hwo: HWAVEOUT) -> MMRESULT --- - waveOutPrepareHeader :: proc(hwo: HWAVEOUT, pwh: LPWAVEHDR, cbwh: UINT) -> MMRESULT --- + waveOutGetNumDevs :: proc() -> UINT --- + waveOutGetDevCapsW :: proc(uDeviceID: UINT_PTR, pwoc: LPWAVEOUTCAPSW, cbwoc: UINT) -> MMRESULT --- + waveOutGetVolume :: proc(hwo: HWAVEOUT, pdwVolume: LPDWORD) -> MMRESULT --- + waveOutSetVolume :: proc(hwo: HWAVEOUT, dwVolume: DWORD) -> MMRESULT --- + waveOutGetErrorTextW :: proc(mmrError: MMRESULT, pszText: LPWSTR, cchText: UINT) -> MMRESULT --- + waveOutOpen :: proc(phwo: LPHWAVEOUT, uDeviceID: UINT, pwfx: LPCWAVEFORMATEX, dwCallback: DWORD_PTR, dwInstance: DWORD_PTR, fdwOpen: DWORD) -> MMRESULT --- + waveOutClose :: proc(hwo: HWAVEOUT) -> MMRESULT --- + waveOutPrepareHeader :: proc(hwo: HWAVEOUT, pwh: LPWAVEHDR, cbwh: UINT) -> MMRESULT --- waveOutUnprepareHeader :: proc(hwo: HWAVEOUT, pwh: LPWAVEHDR, cbwh: UINT) -> MMRESULT --- - waveOutWrite :: proc(hwo: HWAVEOUT, pwh: LPWAVEHDR, cbwh: UINT) -> MMRESULT --- - waveOutPause :: proc(hwo: HWAVEOUT) -> MMRESULT --- - waveOutRestart :: proc(hwo: HWAVEOUT) -> MMRESULT --- - waveOutReset :: proc(hwo: HWAVEOUT) -> MMRESULT --- - waveOutBreakLoop :: proc(hwo: HWAVEOUT) -> MMRESULT --- - waveOutGetPosition :: proc(hwo: HWAVEOUT, pmmt: LPMMTIME, cbmmt: UINT) -> MMRESULT --- - waveOutGetPitch :: proc(hwo: HWAVEOUT, pdwPitch: LPDWORD) -> MMRESULT --- - waveOutSetPitch :: proc(hwo: HWAVEOUT, pdwPitch: DWORD) -> MMRESULT --- + waveOutWrite :: proc(hwo: HWAVEOUT, pwh: LPWAVEHDR, cbwh: UINT) -> MMRESULT --- + waveOutPause :: proc(hwo: HWAVEOUT) -> MMRESULT --- + waveOutRestart :: proc(hwo: HWAVEOUT) -> MMRESULT --- + waveOutReset :: proc(hwo: HWAVEOUT) -> MMRESULT --- + waveOutBreakLoop :: proc(hwo: HWAVEOUT) -> MMRESULT --- + waveOutGetPosition :: proc(hwo: HWAVEOUT, pmmt: LPMMTIME, cbmmt: UINT) -> MMRESULT --- + waveOutGetPitch :: proc(hwo: HWAVEOUT, pdwPitch: LPDWORD) -> MMRESULT --- + waveOutSetPitch :: proc(hwo: HWAVEOUT, pdwPitch: DWORD) -> MMRESULT --- waveOutGetPlaybackRate :: proc(hwo: HWAVEOUT, pdwRate: LPDWORD) -> MMRESULT --- waveOutSetPlaybackRate :: proc(hwo: HWAVEOUT, pdwRate: DWORD) -> MMRESULT --- - waveOutGetID :: proc(hwo: HWAVEOUT, puDeviceID: LPUINT) -> MMRESULT --- + waveOutGetID :: proc(hwo: HWAVEOUT, puDeviceID: LPUINT) -> MMRESULT --- - waveInGetNumDevs :: proc() -> UINT --- + waveInGetNumDevs :: proc() -> UINT --- waveInGetDevCapsW :: proc(uDeviceID: UINT_PTR, pwic: LPWAVEINCAPSW, cbwic: UINT) -> MMRESULT --- PlaySoundW :: proc(pszSound: LPCWSTR, hmod: HMODULE, fdwSound: DWORD) -> BOOL --- @@ -272,10 +272,10 @@ LPHWAVEOUT :: ^HWAVEOUT MMTIME :: struct { wType: MMTIME_TYPE, u: struct #raw_union { - ms: DWORD, - sample: DWORD, - cb: DWORD, - ticks: DWORD, + ms: DWORD `raw_union_tag:"wType=TIME_MS"`, + sample: DWORD `raw_union_tag:"wType=TIME_SAMPLES"`, + cb: DWORD `raw_union_tag:"wType=TIME_BYTES"`, + ticks: DWORD `raw_union_tag:"wType=TIME_TICKS"`, smpte: struct { hour: BYTE, min: BYTE, @@ -284,10 +284,10 @@ MMTIME :: struct { fps: BYTE, dummy: BYTE, pad: [2]BYTE, - }, + } `raw_union_tag:"wType=TIME_SMPTE"`, midi: struct { songptrpos: DWORD, - }, + } `raw_union_tag:"wType=TIME_MIDI"`, }, } LPMMTIME :: ^MMTIME @@ -307,12 +307,13 @@ MMTIME_TYPE :: enum UINT { TIME_TICKS = 0x0020, } -MAXPNAMELEN :: 32 +MAXPNAMELEN :: 32 MAXERRORLENGTH :: 256 -MMVERSION :: UINT +MMVERSION :: UINT // Input is four characters string // Output is little-endian u32 representation +@(require_results) MAKEFOURCC :: #force_inline proc "contextless" (s: [4]byte) -> DWORD { return (DWORD(s[0])) | (DWORD(s[1]) << 8) | (DWORD(s[2]) << 16) | (DWORD(s[3]) << 24 ) } diff --git a/core/sys/windows/winnls.odin b/core/sys/windows/winnls.odin index ffb2638d5..9c2c219ef 100644 --- a/core/sys/windows/winnls.odin +++ b/core/sys/windows/winnls.odin @@ -5,8 +5,8 @@ LCTYPE :: distinct DWORD LOCALE_NAME_MAX_LENGTH :: 85 LOCALE_NAME_USER_DEFAULT :: 0 -LOCALE_NAME_INVARIANT : wstring = L("") -LOCALE_NAME_SYSTEM_DEFAULT : wstring = L("!x-sys-default-locale") +LOCALE_NAME_INVARIANT : wstring = "" +LOCALE_NAME_SYSTEM_DEFAULT : wstring = "!x-sys-default-locale" // String Length Maximums. // 5 ranges, 2 bytes ea., 0 term. @@ -16,16 +16,16 @@ MAX_DEFAULTCHAR :: 2 CPINFOEXW :: struct{ // Maximum length, in bytes, of a character in the code page. - MaxCharSize: UINT, + MaxCharSize: UINT, // The default is usually the "?" character for the code page. - DefaultChar: [MAX_DEFAULTCHAR]BYTE, + DefaultChar: [MAX_DEFAULTCHAR]BYTE, // A fixed-length array of lead byte ranges, for which the number of lead byte ranges is variable. - LeadByte: [MAX_LEADBYTES]BYTE, + LeadByte: [MAX_LEADBYTES]BYTE, // The default is usually the "?" character or the katakana middle dot character. UnicodeDefaultChar: WCHAR, // Code page value. This value reflects the code page passed to the GetCPInfoEx function. - CodePage: CODEPAGE, + CodePage: CODEPAGE, // Full name of the code page. - CodePageName: [MAX_PATH]WCHAR, + CodePageName: [MAX_PATH]WCHAR, } LPCPINFOEXW :: ^CPINFOEXW diff --git a/core/sys/windows/winver.odin b/core/sys/windows/winver.odin index 47751dab7..878080102 100644 --- a/core/sys/windows/winver.odin +++ b/core/sys/windows/winver.odin @@ -5,14 +5,14 @@ foreign import version "system:version.lib" @(default_calling_convention = "system") foreign version { - GetFileVersionInfoSizeW :: proc(lpwstrFilename: LPCWSTR, lpdwHandle: LPDWORD) -> DWORD --- - GetFileVersionInfoW :: proc(lptstrFilename: LPCWSTR, dwHandle: DWORD, dwLen: DWORD, lpData: LPVOID) -> BOOL --- + GetFileVersionInfoSizeW :: proc(lpwstrFilename: LPCWSTR, lpdwHandle: LPDWORD) -> DWORD --- + GetFileVersionInfoW :: proc(lptstrFilename: LPCWSTR, dwHandle: DWORD, dwLen: DWORD, lpData: LPVOID) -> BOOL --- GetFileVersionInfoSizeExW :: proc(dwFlags: FILE_VER_GET_FLAGS, lpwstrFilename: LPCWSTR, lpdwHandle: LPDWORD) -> DWORD --- - GetFileVersionInfoExW :: proc(dwFlags: FILE_VER_GET_FLAGS, lpwstrFilename: LPCWSTR, dwHandle, dwLen: DWORD, lpData: LPVOID) -> DWORD --- + GetFileVersionInfoExW :: proc(dwFlags: FILE_VER_GET_FLAGS, lpwstrFilename: LPCWSTR, dwHandle, dwLen: DWORD, lpData: LPVOID) -> DWORD --- - VerLanguageNameW :: proc(wLang: DWORD, szLang: LPWSTR, cchLang: DWORD) -> DWORD --- - VerQueryValueW :: proc(pBlock: LPCVOID, lpSubBlock: LPCWSTR, lplpBuffer: ^LPVOID, puLen: PUINT) -> BOOL --- + VerLanguageNameW :: proc(wLang: DWORD, szLang: LPWSTR, cchLang: DWORD) -> DWORD --- + VerQueryValueW :: proc(pBlock: LPCVOID, lpSubBlock: LPCWSTR, lplpBuffer: ^LPVOID, puLen: PUINT) -> BOOL --- } FILE_VER_GET :: enum DWORD {LOCALISED, NEUTRAL, PREFETCHED} diff --git a/core/sys/windows/wow64_apiset.odin b/core/sys/windows/wow64_apiset.odin index 3d29b786e..cce0ab2cc 100644 --- a/core/sys/windows/wow64_apiset.odin +++ b/core/sys/windows/wow64_apiset.odin @@ -5,30 +5,30 @@ foreign import kernel32 "system:Kernel32.lib" @(default_calling_convention="system") foreign kernel32 { - GetSystemWow64Directory2W :: proc (lpBuffer: LPWSTR, uSize: UINT, ImageFileMachineTyp: WORD) -> UINT --- - GetSystemWow64DirectoryW :: proc (lpBuffer: LPWSTR, uSize: UINT) -> UINT --- - IsWow64GuestMachineSupported :: proc (WowGuestMachine: USHORT, MachineIsSupported: ^BOOL) -> HRESULT --- - IsWow64Process :: proc (hProcess: HANDLE, Wow64Process: PBOOL) -> BOOL --- - IsWow64Process2 :: proc (hProcess: HANDLE, pProcessMachine: ^USHORT, pNativeMachine: ^USHORT) -> BOOL --- - Wow64EnableWow64FsRedirection :: proc (Wow64FsEnableRedirection: BOOLEAN) -> BOOLEAN --- - Wow64DisableWow64FsRedirection :: proc (OldValue: ^PVOID) -> BOOL --- - Wow64RevertWow64FsRedirection :: proc (OlValue: PVOID) -> BOOL --- - Wow64GetThreadContext :: proc (hThread: HANDLE, lpContext: PWOW64_CONTEXT) -> BOOL --- - Wow64SetThreadContext :: proc(hThread: HANDLE, lpContext: ^WOW64_CONTEXT) -> BOOL --- + GetSystemWow64Directory2W :: proc(lpBuffer: LPWSTR, uSize: UINT, ImageFileMachineTyp: WORD) -> UINT --- + GetSystemWow64DirectoryW :: proc(lpBuffer: LPWSTR, uSize: UINT) -> UINT --- + IsWow64GuestMachineSupported :: proc(WowGuestMachine: USHORT, MachineIsSupported: ^BOOL) -> HRESULT --- + IsWow64Process :: proc(hProcess: HANDLE, Wow64Process: PBOOL) -> BOOL --- + IsWow64Process2 :: proc(hProcess: HANDLE, pProcessMachine: ^USHORT, pNativeMachine: ^USHORT) -> BOOL --- + Wow64EnableWow64FsRedirection :: proc(Wow64FsEnableRedirection: BOOLEAN) -> BOOLEAN --- + Wow64DisableWow64FsRedirection :: proc(OldValue: ^PVOID) -> BOOL --- + Wow64RevertWow64FsRedirection :: proc(OlValue: PVOID) -> BOOL --- + Wow64GetThreadContext :: proc(hThread: HANDLE, lpContext: PWOW64_CONTEXT) -> BOOL --- + Wow64SetThreadContext :: proc(hThread: HANDLE, lpContext: ^WOW64_CONTEXT) -> BOOL --- Wow64SetThreadDefaultGuestMachine :: proc(Machine: USHORT) -> USHORT --- - Wow64SuspendThread :: proc (hThread: HANDLE) -> DWORD --- + Wow64SuspendThread :: proc(hThread: HANDLE) -> DWORD --- } WOW64_CONTEXT_i386 :: 0x00010000 -WOW64_CONTEXT_CONTROL :: (WOW64_CONTEXT_i386 | 0x00000001) -WOW64_CONTEXT_INTEGER :: (WOW64_CONTEXT_i386 | 0x00000002) +WOW64_CONTEXT_CONTROL :: (WOW64_CONTEXT_i386 | 0x00000001) +WOW64_CONTEXT_INTEGER :: (WOW64_CONTEXT_i386 | 0x00000002) WOW64_CONTEXT_SEGMENTS :: (WOW64_CONTEXT_i386 | 0x00000004) -WOW64_CONTEXT_FLOATING_POINT :: (WOW64_CONTEXT_i386 | 0x00000008) -WOW64_CONTEXT_DEBUG_REGISTERS :: (WOW64_CONTEXT_i386 | 0x00000010) +WOW64_CONTEXT_FLOATING_POINT :: (WOW64_CONTEXT_i386 | 0x00000008) +WOW64_CONTEXT_DEBUG_REGISTERS :: (WOW64_CONTEXT_i386 | 0x00000010) WOW64_CONTEXT_EXTENDED_REGISTERS :: (WOW64_CONTEXT_i386 | 0x00000020) -WOW64_CONTEXT_FULL :: (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | WOW64_CONTEXT_SEGMENTS) +WOW64_CONTEXT_FULL :: (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | WOW64_CONTEXT_SEGMENTS) WOW64_CONTEXT_ALL :: ( WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | @@ -41,45 +41,45 @@ WOW64_SIZE_OF_80387_REGISTERS :: 80 WOW64_MAXIMUM_SUPPORTED_EXTENSION :: 512 WOW64_CONTEXT :: struct { - ContextFlags: DWORD, - Dr0: DWORD, - Dr1: DWORD, - Dr2: DWORD, - Dr3: DWORD, - Dr6: DWORD, - Dr7: DWORD, - FloatSave: WOW64_FLOATING_SAVE_AREA, - SegGs: DWORD, - SegFs: DWORD, - SegEs: DWORD, - SegDs: DWORD, - Edi: DWORD, - Esi: DWORD, - Ebx: DWORD, - Edx: DWORD, - Ecx: DWORD, - Eax: DWORD, - Ebp: DWORD, - Eip: DWORD, - SegCs: DWORD, - EFlags: DWORD, - Esp: DWORD, - SegSs: DWORD, + ContextFlags: DWORD, + Dr0: DWORD, + Dr1: DWORD, + Dr2: DWORD, + Dr3: DWORD, + Dr6: DWORD, + Dr7: DWORD, + FloatSave: WOW64_FLOATING_SAVE_AREA, + SegGs: DWORD, + SegFs: DWORD, + SegEs: DWORD, + SegDs: DWORD, + Edi: DWORD, + Esi: DWORD, + Ebx: DWORD, + Edx: DWORD, + Ecx: DWORD, + Eax: DWORD, + Ebp: DWORD, + Eip: DWORD, + SegCs: DWORD, + EFlags: DWORD, + Esp: DWORD, + SegSs: DWORD, ExtendedRegisters: [WOW64_MAXIMUM_SUPPORTED_EXTENSION]BYTE, } PWOW64_CONTEXT :: ^WOW64_CONTEXT WOW64_FLOATING_SAVE_AREA :: struct { - ControlWord: DWORD, - StatusWord: DWORD, - TagWord: DWORD, - ErrorOffset: DWORD, + ControlWord: DWORD, + StatusWord: DWORD, + TagWord: DWORD, + ErrorOffset: DWORD, ErrorSelector: DWORD, - DataOffset: DWORD, - DataSelector: DWORD, - RegisterArea: [WOW64_SIZE_OF_80387_REGISTERS]BYTE, - Cr0NpxState: DWORD, + DataOffset: DWORD, + DataSelector: DWORD, + RegisterArea: [WOW64_SIZE_OF_80387_REGISTERS]BYTE, + Cr0NpxState: DWORD, } PWOW64_FLOATING_SAVE_AREA :: ^WOW64_FLOATING_SAVE_AREA \ No newline at end of file diff --git a/core/sys/windows/ws2_32.odin b/core/sys/windows/ws2_32.odin index ed2ad5e24..77a288d6f 100644 --- a/core/sys/windows/ws2_32.odin +++ b/core/sys/windows/ws2_32.odin @@ -35,11 +35,10 @@ WSANETWORKEVENTS :: struct { iErrorCode: [FD_MAX_EVENTS]c_int, } -WSAEVENT :: HANDLE WSAID_ACCEPTEX :: GUID{0xb5367df1, 0xcbac, 0x11cf, {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} WSAID_GETACCEPTEXSOCKADDRS :: GUID{0xb5367df2, 0xcbac, 0x11cf, {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} -WSAID_CONNECTX :: GUID{0x25a207b9, 0xddf3, 0x4660, {0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}} +WSAID_CONNECTEX :: GUID{0x25a207b9, 0xddf3, 0x4660, {0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}} SIO_GET_EXTENSION_FUNCTION_POINTER :: IOC_INOUT | IOC_WS2 | 6 SIO_UDP_CONNRESET :: IOC_IN | IOC_VENDOR | 12 @@ -109,62 +108,62 @@ foreign ws2_32 { WSAPoll :: proc(fdArray: ^WSA_POLLFD, fds: c_ulong, timeout: c_int) -> c_int --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsaduplicatesocketw) WSADuplicateSocketW :: proc( - s: SOCKET, - dwProcessId: DWORD, + s: SOCKET, + dwProcessId: DWORD, lpProtocolInfo: LPWSAPROTOCOL_INFO, ) -> c_int --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasend) WSASend :: proc( - s: SOCKET, - lpBuffers: LPWSABUF, - dwBufferCount: DWORD, + s: SOCKET, + lpBuffers: LPWSABUF, + dwBufferCount: DWORD, lpNumberOfBytesSent: LPDWORD, - dwFlags: DWORD, - lpOverlapped: LPWSAOVERLAPPED, + dwFlags: DWORD, + lpOverlapped: LPWSAOVERLAPPED, lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, ) -> c_int --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasendto) WSASendTo :: proc( - s: SOCKET, - lpBuffers: LPWSABUF, - dwBufferCount: DWORD, + s: SOCKET, + lpBuffers: LPWSABUF, + dwBufferCount: DWORD, lpNumberOfBytesSent: LPDWORD, - dwFlags: DWORD, - lpTo: ^SOCKADDR_STORAGE_LH, - iToLen: c_int, - lpOverlapped: LPWSAOVERLAPPED, + dwFlags: DWORD, + lpTo: ^sockaddr, + iToLen: c_int, + lpOverlapped: LPWSAOVERLAPPED, lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, ) -> c_int --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsarecv) WSARecv :: proc( - s: SOCKET, - lpBuffers: LPWSABUF, - dwBufferCount: DWORD, + s: SOCKET, + lpBuffers: LPWSABUF, + dwBufferCount: DWORD, lpNumberOfBytesRecvd: LPDWORD, - lpFlags: LPDWORD, - lpOverlapped: LPWSAOVERLAPPED, - lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, + lpFlags: LPDWORD, + lpOverlapped: LPWSAOVERLAPPED, + lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, ) -> c_int --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsarecvfrom) WSARecvFrom :: proc( - s: SOCKET, - lpBuffers: LPWSABUF, - dwBufferCount: DWORD, + s: SOCKET, + lpBuffers: LPWSABUF, + dwBufferCount: DWORD, lpNumberOfBytesRecvd: LPDWORD, - lpFlags: LPDWORD, - lpFrom: ^SOCKADDR_STORAGE_LH, - lpFromlen: ^c_int, - lpOverlapped: LPWSAOVERLAPPED, - lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, + lpFlags: LPDWORD, + lpFrom: ^sockaddr, + lpFromlen: LPINT, + lpOverlapped: LPWSAOVERLAPPED, + lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, ) -> c_int --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw) WSASocketW :: proc( - af: c_int, - kind: c_int, - protocol: c_int, + af: c_int, + kind: c_int, + protocol: c_int, lpProtocolInfo: LPWSAPROTOCOL_INFO, - g: GROUP, - dwFlags: DWORD, + g: GROUP, + dwFlags: DWORD, ) -> SOCKET --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsaioctl) WSAIoctl :: proc(s: SOCKET, dwIoControlCode: DWORD, lpvInBuffer: rawptr, cbInBuffer: DWORD, lpvOutBuffer: rawptr, cbOutBuffer: DWORD, lpcbBytesReturned: ^DWORD, lpOverlapped: ^OVERLAPPED, lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE) -> c_int --- @@ -182,8 +181,8 @@ foreign ws2_32 { WSAGetOverlappedResult :: proc(s: SOCKET, lpOverlapped: ^OVERLAPPED, lpcbTransfer: ^DWORD, fWait: BOOL, lpdwFlags: ^DWORD) -> BOOL --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-socket) socket :: proc( - af: c_int, - type: c_int, + af: c_int, + type: c_int, protocol: c_int, ) -> SOCKET --- @@ -197,20 +196,20 @@ foreign ws2_32 { send :: proc(socket: SOCKET, buf: rawptr, len: c_int, flags: c_int) -> c_int --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvfrom) recvfrom :: proc( - socket: SOCKET, - buf: rawptr, - len: c_int, - flags: c_int, - addr: ^SOCKADDR_STORAGE_LH, + socket: SOCKET, + buf: rawptr, + len: c_int, + flags: c_int, + addr: ^SOCKADDR_STORAGE_LH, addrlen: ^c_int, ) -> c_int --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendto) sendto :: proc( - socket: SOCKET, - buf: rawptr, - len: c_int, - flags: c_int, - addr: ^SOCKADDR_STORAGE_LH, + socket: SOCKET, + buf: rawptr, + len: c_int, + flags: c_int, + addr: ^SOCKADDR_STORAGE_LH, addrlen: c_int, ) -> c_int --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-shutdown) @@ -220,11 +219,11 @@ foreign ws2_32 { // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt) setsockopt :: proc( - s: SOCKET, - level: c_int, + s: SOCKET, + level: c_int, optname: c_int, - optval: rawptr, - optlen: c_int, + optval: rawptr, + optlen: c_int, ) -> c_int --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockname) getsockname :: proc(socket: SOCKET, address: ^SOCKADDR_STORAGE_LH, address_len: ^c_int) -> c_int --- @@ -238,10 +237,10 @@ foreign ws2_32 { connect :: proc(socket: SOCKET, address: ^SOCKADDR_STORAGE_LH, len: c_int) -> c_int --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo) getaddrinfo :: proc( - node: cstring, + node: cstring, service: cstring, - hints: ^ADDRINFOA, - res: ^^ADDRINFOA, + hints: ^ADDRINFOA, + res: ^^ADDRINFOA, ) -> c_int --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-freeaddrinfo) freeaddrinfo :: proc(res: ^ADDRINFOA) --- @@ -261,19 +260,19 @@ foreign ws2_32 { lpHandle: LPHANDLE) -> INT --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-select) select :: proc( - nfds: c_int, - readfds: ^fd_set, - writefds: ^fd_set, - exceptfds: ^fd_set, - timeout: ^timeval, + nfds: c_int, + readfds: [^]fd_set, + writefds: [^]fd_set, + exceptfds: [^]fd_set, + timeout: ^timeval, ) -> c_int --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt) getsockopt :: proc( - s: SOCKET, - level: c_int, + s: SOCKET, + level: c_int, optname: c_int, - optval: ^c_char, - optlen: ^c_int, + optval: [^]c_char, + optlen: ^c_int, ) -> c_int --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-ntohl) ntohl :: proc(netlong: c_ulong) -> c_ulong --- diff --git a/core/sys/windows/xinput.odin b/core/sys/windows/xinput.odin index 0089f88cb..f8fd45bc9 100644 --- a/core/sys/windows/xinput.odin +++ b/core/sys/windows/xinput.odin @@ -57,9 +57,9 @@ XINPUT_GAMEPAD_BUTTON_BIT :: enum WORD { XINPUT_GAMEPAD_BUTTON :: distinct bit_set[XINPUT_GAMEPAD_BUTTON_BIT;WORD] // Gamepad thresholds -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE: SHORT : 7849 -XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE: SHORT : 8689 -XINPUT_GAMEPAD_TRIGGER_THRESHOLD: SHORT : 30 +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE : SHORT : 7849 +XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE : SHORT : 8689 +XINPUT_GAMEPAD_TRIGGER_THRESHOLD : SHORT : 30 // Flags to pass to XInputGetCapabilities // Corresponds to log2(XINPUT_FLAG_...) @@ -199,12 +199,12 @@ XINPUT_KEYSTROKE :: struct { // XInput APIs @(default_calling_convention = "system") foreign xinput { - XInputGetState :: proc(user: XUSER, pState: ^XINPUT_STATE) -> System_Error --- - XInputSetState :: proc(user: XUSER, pVibration: ^XINPUT_VIBRATION) -> System_Error --- - XInputGetCapabilities :: proc(user: XUSER, dwFlags: XINPUT_FLAG, pCapabilities: ^XINPUT_CAPABILITIES) -> System_Error --- - XInputEnable :: proc(enable: BOOL) --- - XInputGetAudioDeviceIds :: proc(user: XUSER, pRenderDeviceId: LPWSTR, pRenderCount: ^UINT, pCaptureDeviceId: LPWSTR, pCaptureCount: ^UINT) -> System_Error --- - XInputGetBatteryInformation :: proc(user: XUSER, devType: BATTERY_DEVTYPE, pBatteryInformation: ^XINPUT_BATTERY_INFORMATION) -> System_Error --- - XInputGetKeystroke :: proc(user: XUSER, dwReserved: DWORD, pKeystroke: ^XINPUT_KEYSTROKE) -> System_Error --- + XInputGetState :: proc(user: XUSER, pState: ^XINPUT_STATE) -> System_Error --- + XInputSetState :: proc(user: XUSER, pVibration: ^XINPUT_VIBRATION) -> System_Error --- + XInputGetCapabilities :: proc(user: XUSER, dwFlags: XINPUT_FLAG, pCapabilities: ^XINPUT_CAPABILITIES) -> System_Error --- + XInputEnable :: proc(enable: BOOL) --- + XInputGetAudioDeviceIds :: proc(user: XUSER, pRenderDeviceId: LPWSTR, pRenderCount: ^UINT, pCaptureDeviceId: LPWSTR, pCaptureCount: ^UINT) -> System_Error --- + XInputGetBatteryInformation :: proc(user: XUSER, devType: BATTERY_DEVTYPE, pBatteryInformation: ^XINPUT_BATTERY_INFORMATION) -> System_Error --- + XInputGetKeystroke :: proc(user: XUSER, dwReserved: DWORD, pKeystroke: ^XINPUT_KEYSTROKE) -> System_Error --- XInputGetDSoundAudioDeviceGuids :: proc(user: XUSER, pDSoundRenderGuid: ^GUID, pDSoundCaptureGuid: ^GUID) -> System_Error --- } diff --git a/core/thread/thread.odin b/core/thread/thread.odin index 26c1a3e27..a07801b98 100644 --- a/core/thread/thread.odin +++ b/core/thread/thread.odin @@ -5,7 +5,10 @@ import "base:runtime" import "core:mem" import "base:intrinsics" -_ :: intrinsics +@(private) +unall :: intrinsics.unaligned_load +@(private) +unals :: intrinsics.unaligned_store /* Value, specifying whether `core:thread` functionality is available on the @@ -347,7 +350,9 @@ create_and_start_with_poly_data :: proc(data: $T, fn: proc(data: T), init_contex thread_proc :: proc(t: ^Thread) { fn := cast(proc(T))t.data assert(t.user_index >= 1) - data := (^T)(&t.user_args[0])^ + + data := unall((^T)(&t.user_args)) + fn(data) } if t = create(thread_proc, priority); t == nil { @@ -356,9 +361,7 @@ create_and_start_with_poly_data :: proc(data: $T, fn: proc(data: T), init_contex t.data = rawptr(fn) t.user_index = 1 - data := data - - mem.copy(&t.user_args[0], &data, size_of(T)) + unals((^T)(&t.user_args), data) if self_cleanup { intrinsics.atomic_or(&t.flags, {.Self_Cleanup}) @@ -393,9 +396,10 @@ create_and_start_with_poly_data2 :: proc(arg1: $T1, arg2: $T2, fn: proc(T1, T2), fn := cast(proc(T1, T2))t.data assert(t.user_index >= 2) - user_args := mem.slice_to_bytes(t.user_args[:]) - arg1 := (^T1)(raw_data(user_args))^ - arg2 := (^T2)(raw_data(user_args[size_of(T1):]))^ + ptr := uintptr(&t.user_args) + + arg1 := unall((^T1)(rawptr(ptr))) + arg2 := unall((^T2)(rawptr(ptr + size_of(T1)))) fn(arg1, arg2) } @@ -405,11 +409,10 @@ create_and_start_with_poly_data2 :: proc(arg1: $T1, arg2: $T2, fn: proc(T1, T2), t.data = rawptr(fn) t.user_index = 2 - arg1, arg2 := arg1, arg2 - user_args := mem.slice_to_bytes(t.user_args[:]) + ptr := uintptr(&t.user_args) - n := copy(user_args, mem.ptr_to_bytes(&arg1)) - _ = copy(user_args[n:], mem.ptr_to_bytes(&arg2)) + unals((^T1)(rawptr(ptr)), arg1) + unals((^T2)(rawptr(ptr + size_of(T1))), arg2) if self_cleanup { intrinsics.atomic_or(&t.flags, {.Self_Cleanup}) @@ -444,10 +447,11 @@ create_and_start_with_poly_data3 :: proc(arg1: $T1, arg2: $T2, arg3: $T3, fn: pr fn := cast(proc(T1, T2, T3))t.data assert(t.user_index >= 3) - user_args := mem.slice_to_bytes(t.user_args[:]) - arg1 := (^T1)(raw_data(user_args))^ - arg2 := (^T2)(raw_data(user_args[size_of(T1):]))^ - arg3 := (^T3)(raw_data(user_args[size_of(T1) + size_of(T2):]))^ + ptr := uintptr(&t.user_args) + + arg1 := unall((^T1)(rawptr(ptr))) + arg2 := unall((^T2)(rawptr(ptr + size_of(T1)))) + arg3 := unall((^T3)(rawptr(ptr + size_of(T1) + size_of(T2)))) fn(arg1, arg2, arg3) } @@ -457,12 +461,11 @@ create_and_start_with_poly_data3 :: proc(arg1: $T1, arg2: $T2, arg3: $T3, fn: pr t.data = rawptr(fn) t.user_index = 3 - arg1, arg2, arg3 := arg1, arg2, arg3 - user_args := mem.slice_to_bytes(t.user_args[:]) + ptr := uintptr(&t.user_args) - n := copy(user_args, mem.ptr_to_bytes(&arg1)) - n += copy(user_args[n:], mem.ptr_to_bytes(&arg2)) - _ = copy(user_args[n:], mem.ptr_to_bytes(&arg3)) + unals((^T1)(rawptr(ptr)), arg1) + unals((^T2)(rawptr(ptr + size_of(T1))), arg2) + unals((^T3)(rawptr(ptr + size_of(T1) + size_of(T2))), arg3) if self_cleanup { intrinsics.atomic_or(&t.flags, {.Self_Cleanup}) diff --git a/core/thread/thread_pool.odin b/core/thread/thread_pool.odin index d7a03d04c..10f1438d7 100644 --- a/core/thread/thread_pool.odin +++ b/core/thread/thread_pool.odin @@ -20,6 +20,9 @@ Task :: struct { allocator: mem.Allocator, } +Thread_Init_Proc :: #type proc(thread: ^Thread, user_data: rawptr) +Thread_Fini_Proc :: #type proc(thread: ^Thread, user_data: rawptr) + // Do not access the pool's members directly while the pool threads are running, // since they use different kinds of locking and mutual exclusion devices. // Careless access can and will lead to nasty bugs. Once initialized, the @@ -36,6 +39,13 @@ Pool :: struct { num_done: int, // end of atomics + // called once per thread at startup + thread_init_proc: Thread_Init_Proc, + thread_init_data: rawptr, + // called once per thread at shutdown + thread_fini_proc: Thread_Fini_Proc, + thread_fini_data: rawptr, + is_running: bool, threads: []^Thread, @@ -55,6 +65,10 @@ pool_thread_runner :: proc(t: ^Thread) { data := cast(^Pool_Thread_Data)t.data pool := data.pool + if pool.thread_init_proc != nil { + pool.thread_init_proc(t, pool.thread_init_data) + } + for intrinsics.atomic_load(&pool.is_running) { sync.wait(&pool.sem_available) @@ -66,6 +80,10 @@ pool_thread_runner :: proc(t: ^Thread) { } } + if pool.thread_fini_proc != nil { + pool.thread_fini_proc(t, pool.thread_fini_data) + } + sync.post(&pool.sem_available, 1) } @@ -73,13 +91,26 @@ pool_thread_runner :: proc(t: ^Thread) { // it is destroyed. // // The thread pool requires an allocator which it either owns, or which is thread safe. -pool_init :: proc(pool: ^Pool, allocator: mem.Allocator, thread_count: int) { +pool_init :: proc( + pool: ^Pool, + allocator: mem.Allocator, + thread_count: int, + init_proc: Thread_Init_Proc = nil, + init_data: rawptr = nil, + fini_proc: Thread_Init_Proc = nil, + fini_data: rawptr = nil, +){ context.allocator = allocator pool.allocator = allocator queue.init(&pool.tasks) pool.tasks_done = make([dynamic]Task) pool.threads = make([]^Thread, max(thread_count, 1)) + pool.thread_init_proc = init_proc + pool.thread_fini_proc = fini_proc + pool.thread_init_data = init_data + pool.thread_fini_data = fini_data + pool.is_running = true for _, i in pool.threads { diff --git a/core/thread/thread_unix.odin b/core/thread/thread_unix.odin index e18ea593d..af2a4a3c1 100644 --- a/core/thread/thread_unix.odin +++ b/core/thread/thread_unix.odin @@ -107,7 +107,11 @@ _create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread { high := posix.sched_get_priority_max(policy) switch priority { case .Normal: // Okay - case .Low: params.sched_priority = low + 1 + case .Low: + params.sched_priority = low + 1 + if params.sched_priority >= high { + params.sched_priority = low + } case .High: params.sched_priority = high } res = posix.pthread_attr_setschedparam(&attrs, ¶ms) diff --git a/core/unicode/letter.odin b/core/unicode/letter.odin index a1024dd6c..5191dd900 100644 --- a/core/unicode/letter.odin +++ b/core/unicode/letter.odin @@ -2,7 +2,7 @@ package unicode import "base:runtime" -MAX_RUNE :: '\U00010fff' // Maximum valid unicode code point +MAX_RUNE :: '\U0010ffff' // Maximum valid unicode code point REPLACEMENT_CHAR :: '\ufffd' // Represented an invalid code point MAX_ASCII :: '\u007f' // Maximum ASCII value MAX_LATIN1 :: '\u00ff' // Maximum Latin-1 value diff --git a/core/unicode/tools/generate_entity_table.odin b/core/unicode/tools/generate_entity_table.odin index 020ef94e4..9517b632b 100644 --- a/core/unicode/tools/generate_entity_table.odin +++ b/core/unicode/tools/generate_entity_table.odin @@ -18,7 +18,7 @@ OPTIONS :: xml.Options{ flags = { .Ignore_Unsupported, }, expected_doctype = "un Entity :: struct { name: string, - codepoint: rune, + codepoints: [2]rune, description: string, } @@ -57,7 +57,10 @@ generate_encoding_entity_table :: proc() { fmt.printf("Found `` with %v children.\n", len(charlist.value)) entity_map: map[string]Entity + defer delete(entity_map) + names: [dynamic]string + defer delete(names) min_name_length := max(int) max_name_length := min(int) @@ -78,7 +81,13 @@ generate_encoding_entity_table :: proc() { fmt.eprintln("`` attribute not found.") os.exit(1) } else { - codepoint := strconv.atoi(codepoint_string) + r1, _, r2 := strings.partition(codepoint_string, "-") + + codepoint, codepoint2: int + codepoint, _ = strconv.parse_int(r1) + if r2 != "" { + codepoint2, _ = strconv.parse_int(r2) + } desc, desc_ok := xml.find_child_by_ident(doc, id, "description") description := "" @@ -115,7 +124,7 @@ generate_encoding_entity_table :: proc() { e := Entity{ name = name, - codepoint = rune(codepoint), + codepoints = {rune(codepoint), rune(codepoint2)}, description = description, } @@ -162,22 +171,22 @@ generate_encoding_entity_table :: proc() { entity_name - a string, like "copy" that describes a user-encoded Unicode entity as used in XML. Returns: - "decoded" - The decoded rune if found by name, or -1 otherwise. - "ok" - true if found, false if not. + "decoded" - The decoded runes if found by name, or all zero otherwise. + "rune_count" - The number of decoded runes + "ok" - true if found, false if not. IMPORTANT: XML processors (including browsers) treat these names as case-sensitive. So do we. */ -named_xml_entity_to_rune :: proc(name: string) -> (decoded: rune, ok: bool) { +named_xml_entity_to_rune :: proc(name: string) -> (decoded: [2]rune, rune_count: int, ok: bool) { /* Early out if the name is too short or too long. min as a precaution in case the generated table has a bogus value. */ if len(name) < min(1, XML_NAME_TO_RUNE_MIN_LENGTH) || len(name) > XML_NAME_TO_RUNE_MAX_LENGTH { - return -1, false + return } - switch rune(name[0]) { -`) + switch rune(name[0]) {`) prefix := '?' should_close := false @@ -200,13 +209,17 @@ named_xml_entity_to_rune :: proc(name: string) -> (decoded: rune, ok: bool) { fmt.wprintf(w, " ") } fmt.wprintf(w, " // %v\n", e.description) - fmt.wprintf(w, "\t\t\treturn %v, true\n", rune_to_string(e.codepoint)) + if e.codepoints[1] != 0 { + fmt.wprintf(w, "\t\t\treturn {{%q, %q}}, 2, true\n", e.codepoints[0], e.codepoints[1]) + } else { + fmt.wprintf(w, "\t\t\treturn {{%q, 0}}, 1, true\n", e.codepoints[0]) + } should_close = true } fmt.wprintln(w, "\t\t}") fmt.wprintln(w, "\t}") - fmt.wprintln(w, "\treturn -1, false") + fmt.wprintln(w, "\treturn") fmt.wprintln(w, "}\n") fmt.wprintln(w, GENERATED) @@ -221,12 +234,6 @@ named_xml_entity_to_rune :: proc(name: string) -> (decoded: rune, ok: bool) { } else { fmt.printf("Failed to write generated \"%v\".\n", generated_filename) } - - delete(entity_map) - delete(names) - for &name in names { - free(&name) - } } GENERATED :: `/* @@ -262,14 +269,6 @@ TABLE_FILE_PROLOG :: `/* */ ` -rune_to_string :: proc(r: rune) -> (res: string) { - res = fmt.tprintf("%08x", int(r)) - for len(res) > 2 && res[:2] == "00" { - res = res[2:] - } - return fmt.tprintf("rune(0x%v)", res) -} - is_dotted_name :: proc(name: string) -> (dotted: bool) { for r in name { if r == '.' { return true} diff --git a/core/unicode/utf8/utf8.odin b/core/unicode/utf8/utf8.odin index 281e36f43..78cefa8b4 100644 --- a/core/unicode/utf8/utf8.odin +++ b/core/unicode/utf8/utf8.odin @@ -60,6 +60,7 @@ accept_sizes := [256]u8{ 0xf5..=0xff = 0xf1, // ascii, size 1 } +@(require_results) encode_rune :: proc "contextless" (c: rune) -> ([4]u8, int) { r := c @@ -101,9 +102,11 @@ decode_rune :: proc{ decode_rune_in_string, decode_rune_in_bytes, } +@(require_results) decode_rune_in_string :: #force_inline proc "contextless" (s: string) -> (rune, int) { return decode_rune_in_bytes(transmute([]u8)s) } +@(require_results) decode_rune_in_bytes :: proc "contextless" (s: []u8) -> (rune, int) { n := len(s) if n < 1 { @@ -141,6 +144,7 @@ decode_rune_in_bytes :: proc "contextless" (s: []u8) -> (rune, int) { return rune(s0&MASK4)<<18 | rune(b1&MASKX)<<12 | rune(b2&MASKX)<<6 | rune(b3&MASKX), 4 } +@(require_results) string_to_runes :: proc "odin" (s: string, allocator := context.allocator) -> (runes: []rune) { n := rune_count_in_string(s) @@ -153,6 +157,7 @@ string_to_runes :: proc "odin" (s: string, allocator := context.allocator) -> (r return } +@(require_results) runes_to_string :: proc "odin" (runes: []rune, allocator := context.allocator) -> string { byte_count := 0 for r in runes { @@ -177,9 +182,11 @@ decode_last_rune :: proc{ decode_last_rune_in_bytes, } +@(require_results) decode_last_rune_in_string :: #force_inline proc "contextless" (s: string) -> (rune, int) { return decode_last_rune_in_bytes(transmute([]u8)s) } +@(require_results) decode_last_rune_in_bytes :: proc "contextless" (s: []u8) -> (rune, int) { r: rune size: int @@ -212,6 +219,7 @@ decode_last_rune_in_bytes :: proc "contextless" (s: []u8) -> (rune, int) { return r, size } +@(require_results) rune_at_pos :: proc "contextless" (s: string, pos: int) -> rune { if pos < 0 { return RUNE_ERROR @@ -227,6 +235,7 @@ rune_at_pos :: proc "contextless" (s: string, pos: int) -> rune { return RUNE_ERROR } +@(require_results) rune_string_at_pos :: proc "contextless" (s: string, pos: int) -> string { if pos < 0 { return "" @@ -243,6 +252,7 @@ rune_string_at_pos :: proc "contextless" (s: string, pos: int) -> string { return "" } +@(require_results) rune_at :: proc "contextless" (s: string, byte_index: int) -> rune { r, _ := decode_rune_in_string(s[byte_index:]) return r @@ -250,6 +260,7 @@ rune_at :: proc "contextless" (s: string, byte_index: int) -> rune { // Returns the byte position of rune at position pos in s with an optional start byte position. // Returns -1 if it runs out of the string. +@(require_results) rune_offset :: proc "contextless" (s: string, pos: int, start: int = 0) -> int { if pos < 0 { return -1 @@ -265,6 +276,7 @@ rune_offset :: proc "contextless" (s: string, pos: int, start: int = 0) -> int { return -1 } +@(require_results) valid_rune :: proc "contextless" (r: rune) -> bool { if r < 0 { return false @@ -276,6 +288,7 @@ valid_rune :: proc "contextless" (r: rune) -> bool { return true } +@(require_results) valid_string :: proc "contextless" (s: string) -> bool { n := len(s) for i := 0; i < n; { @@ -309,6 +322,7 @@ valid_string :: proc "contextless" (s: string) -> bool { return true } +@(require_results) rune_start :: #force_inline proc "contextless" (b: u8) -> bool { return b&0xc0 != 0x80 } @@ -318,9 +332,11 @@ rune_count :: proc{ rune_count_in_bytes, } +@(require_results) rune_count_in_string :: #force_inline proc(s: string) -> int { return rune_count_in_bytes(transmute([]u8)s) } +@(require_results) rune_count_in_bytes :: proc "contextless" (s: []u8) -> int { count := 0 n := len(s) @@ -360,6 +376,7 @@ rune_count_in_bytes :: proc "contextless" (s: []u8) -> int { } +@(require_results) rune_size :: proc "contextless" (r: rune) -> int { switch { case r < 0: return -1 @@ -381,6 +398,7 @@ full_rune :: proc{ // full_rune_in_bytes reports if the bytes in b begin with a full utf-8 encoding of a rune or not // An invalid encoding is considered a full rune since it will convert as an error rune of width 1 (RUNE_ERROR) +@(require_results) full_rune_in_bytes :: proc "contextless" (b: []byte) -> bool { n := len(b) if n == 0 { @@ -401,6 +419,7 @@ full_rune_in_bytes :: proc "contextless" (b: []byte) -> bool { // full_rune_in_string reports if the bytes in s begin with a full utf-8 encoding of a rune or not // An invalid encoding is considered a full rune since it will convert as an error rune of width 1 (RUNE_ERROR) +@(require_results) full_rune_in_string :: proc "contextless" (s: string) -> bool { return full_rune_in_bytes(transmute([]byte)s) } diff --git a/examples/all/all_js.odin b/examples/all/all_js.odin index 28b85f537..ee006ae86 100644 --- a/examples/all/all_js.odin +++ b/examples/all/all_js.odin @@ -33,6 +33,7 @@ package all @(require) import "core:crypto/chacha20poly1305" @(require) import chash "core:crypto/hash" @(require) import "core:crypto/deoxysii" +@(require) import "core:crypto/ecdh" @(require) import "core:crypto/ed25519" @(require) import "core:crypto/hkdf" @(require) import "core:crypto/hmac" diff --git a/examples/all/all_linux.odin b/examples/all/all_linux.odin index 2b70fa1e1..d7d005ba0 100644 --- a/examples/all/all_linux.odin +++ b/examples/all/all_linux.odin @@ -2,4 +2,5 @@ package all @(require) import "core:sys/linux" -@(require) import "vendor:x11/xlib" \ No newline at end of file +@(require) import "core:sys/linux/uring" +@(require) import "vendor:x11/xlib" diff --git a/examples/all/all_main.odin b/examples/all/all_main.odin index 7895b4640..c5f627653 100644 --- a/examples/all/all_main.odin +++ b/examples/all/all_main.odin @@ -17,12 +17,14 @@ package all @(require) import "core:container/avl" @(require) import "core:container/bit_array" +@(require) import "core:container/handle_map" +@(require) import "core:container/intrusive/list" +@(require) import "core:container/lru" +@(require) import "core:container/pool" @(require) import "core:container/priority_queue" @(require) import "core:container/queue" -@(require) import "core:container/small_array" -@(require) import "core:container/lru" -@(require) import "core:container/intrusive/list" @(require) import "core:container/rbtree" +@(require) import "core:container/small_array" @(require) import "core:container/topological_sort" @(require) import "core:container/xar" @@ -36,6 +38,7 @@ package all @(require) import "core:crypto/chacha20poly1305" @(require) import chash "core:crypto/hash" @(require) import "core:crypto/deoxysii" +@(require) import "core:crypto/ecdh" @(require) import "core:crypto/ed25519" @(require) import "core:crypto/hkdf" @(require) import "core:crypto/hmac" @@ -104,6 +107,8 @@ package all @(require) import "core:mem/tlsf" @(require) import "core:mem/virtual" +@(require) import "core:nbio" + @(require) import "core:odin/ast" @(require) import doc_format "core:odin/doc-format" @(require) import "core:odin/parser" @@ -156,4 +161,4 @@ package all @(require) import "core:unicode/utf8/utf8string" @(require) import "core:unicode/utf16" -main :: proc() {} \ No newline at end of file +main :: proc() {} diff --git a/examples/all/all_vendor.odin b/examples/all/all_vendor.odin index 80f6c52bb..fc2a401b3 100644 --- a/examples/all/all_vendor.odin +++ b/examples/all/all_vendor.odin @@ -30,6 +30,7 @@ package all // NOTE: needed for doc generator @(require) import "core:sys/darwin/Foundation" @(require) import "core:sys/darwin/CoreFoundation" +@(require) import "core:sys/darwin/CoreGraphics" @(require) import "core:sys/darwin/Security" @(require) import "vendor:darwin/CoreVideo" @(require) import "vendor:darwin/Metal" diff --git a/src/build_settings.cpp b/src/build_settings.cpp index 12631c403..6b8fefa59 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -360,14 +360,13 @@ enum OptInFeatureFlags : u64 { OptInFeatureFlag_IntegerDivisionByZero_Self = 1u<<4, OptInFeatureFlag_IntegerDivisionByZero_AllBits = 1u<<5, - OptInFeatureFlag_UsingStmt = 1u<<6, - - OptInFeatureFlag_IntegerDivisionByZero_ALL = OptInFeatureFlag_IntegerDivisionByZero_Trap| OptInFeatureFlag_IntegerDivisionByZero_Zero| OptInFeatureFlag_IntegerDivisionByZero_Self| OptInFeatureFlag_IntegerDivisionByZero_AllBits, + OptInFeatureFlag_ForceTypeAssert = 1u<<6, + OptInFeatureFlag_UsingStmt = 1u<<7, }; u64 get_feature_flag_from_name(String const &name) { @@ -388,6 +387,9 @@ u64 get_feature_flag_from_name(String const &name) { } if (name == "using-stmt") { return OptInFeatureFlag_UsingStmt; + } + if (name == "force-type-assert") { + return OptInFeatureFlag_ForceTypeAssert; } @@ -587,6 +589,7 @@ struct BuildContext { RelocMode reloc_mode; bool disable_red_zone; + bool disable_unwind; isize max_error_count; @@ -844,6 +847,15 @@ gb_global TargetMetrics target_freestanding_amd64_win64 = { TargetABI_Win64, }; +gb_global TargetMetrics target_freestanding_amd64_mingw = { + TargetOs_freestanding, + TargetArch_amd64, + 8, 8, AMD64_MAX_ALIGNMENT, 32, + str_lit("x86_64-pc-windows-gnu"), + TargetABI_Win64, +}; + + gb_global TargetMetrics target_freestanding_arm64 = { TargetOs_freestanding, TargetArch_arm64, @@ -906,6 +918,7 @@ gb_global NamedTargetMetrics named_targets[] = { { str_lit("freestanding_amd64_sysv"), &target_freestanding_amd64_sysv }, { str_lit("freestanding_amd64_win64"), &target_freestanding_amd64_win64 }, + { str_lit("freestanding_amd64_mingw"), &target_freestanding_amd64_mingw }, { str_lit("freestanding_arm64"), &target_freestanding_arm64 }, { str_lit("freestanding_arm32"), &target_freestanding_arm32 }, diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index 1b3e6912c..e732d8ec3 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -2695,6 +2695,16 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As case BuiltinProc_size_of: { // size_of :: proc(Type or expr) -> untyped int + if (ce->args[0]->kind == Ast_UnaryExpr) { + ast_node(arg, UnaryExpr, ce->args[0]); + if (arg->op.kind == Token_And) { + ERROR_BLOCK(); + + warning(ce->args[0], "'size_of(&x)' returns the size of a pointer, not the size of x"); + error_line("\tSuggestion: Use 'size_of(rawptr)' if you want the size of the pointer"); + } + } + Operand o = {}; check_expr_or_type(c, &o, ce->args[0]); if (o.mode == Addressing_Invalid) { @@ -5373,6 +5383,14 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As return false; } } + if (!are_types_identical(x.type, y.type)) { + gbString xts = type_to_string(x.type); + gbString yts = type_to_string(y.type); + error(x.expr, "Mismatched types for '%.*s', got %s vs %s", LIT(builtin_name), xts, yts); + gb_string_free(yts); + gb_string_free(xts); + return false; + } operand->mode = Addressing_Value; operand->type = make_optional_ok_type(default_type(x.type)); @@ -5416,6 +5434,14 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As return false; } } + if (!are_types_identical(x.type, y.type)) { + gbString xts = type_to_string(x.type); + gbString yts = type_to_string(y.type); + error(x.expr, "Mismatched types for '%.*s', got %s vs %s", LIT(builtin_name), xts, yts); + gb_string_free(yts); + gb_string_free(xts); + return false; + } operand->mode = Addressing_Value; operand->type = default_type(x.type); diff --git a/src/check_decl.cpp b/src/check_decl.cpp index 27babd255..8019d00c3 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -1473,6 +1473,7 @@ gb_internal void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) { e->Procedure.no_sanitize_address = ac.no_sanitize_address; e->Procedure.no_sanitize_memory = ac.no_sanitize_memory; + e->Procedure.no_sanitize_thread = ac.no_sanitize_thread; e->deprecated_message = ac.deprecated_message; e->warning_message = ac.warning_message; diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 2fe6c0251..1c09ad908 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -1133,7 +1133,11 @@ gb_internal void check_assignment(CheckerContext *c, Operand *operand, Type *typ x.mode = Addressing_Value; x.type = t; if (check_is_assignable_to(c, &x, type)) { - add_entity_use(c, operand->expr, e); + if (operand->expr->kind == Ast_SelectorExpr) { + add_entity_use(c, operand->expr->SelectorExpr.selector, e); + } else { + add_entity_use(c, operand->expr, e); + } good = true; break; } @@ -3526,28 +3530,17 @@ gb_internal bool check_cast_internal(CheckerContext *c, Operand *x, Type *type) Type *elem = core_array_type(bt); if (core_type(bt)->kind == Type_Basic) { - if (check_representable_as_constant(c, x->value, type, &x->value)) { - return true; - } - goto check_castable; - } else if (!are_types_identical(elem, bt) && - elem->kind == Type_Basic && - check_representable_as_constant(c, x->value, elem, &x->value)) { - if (check_representable_as_constant(c, x->value, type, &x->value)) { - return true; - } - goto check_castable; + return check_representable_as_constant(c, x->value, type, &x->value) || + (is_type_pointer(type) && check_is_castable_to(c, x, type)); + } else if (!are_types_identical(elem, bt) && elem->kind == Type_Basic && x->type->kind == Type_Basic) { + return check_representable_as_constant(c, x->value, elem, &x->value) || + (is_type_pointer(elem) && check_is_castable_to(c, x, elem)); } else if (check_is_castable_to(c, x, type)) { x->value = {}; x->mode = Addressing_Value; return true; } - - return false; - } - -check_castable: - if (check_is_castable_to(c, x, type)) { + } else if (check_is_castable_to(c, x, type)) { if (x->mode != Addressing_Constant) { x->mode = Addressing_Value; } else if (is_type_slice(type) && is_type_string(x->type)) { @@ -4132,15 +4125,19 @@ gb_internal void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, Typ i64 upper = yt->BitSet.upper; if (lower <= key && key <= upper) { - i64 bit = 1ll<mode = Addressing_Constant; x->type = t_untyped_bool; if (op.kind == Token_in) { - x->value = exact_value_bool((bit & bits) != 0); + x->value = exact_value_bool(!big_int_is_zero(&mask)); } else { - x->value = exact_value_bool((bit & bits) == 0); + x->value = exact_value_bool(big_int_is_zero(&mask)); } x->expr = node; return; @@ -4707,12 +4704,14 @@ gb_internal void convert_to_typed(CheckerContext *c, Operand *operand, Type *tar switch (t->kind) { case Type_Basic: if (operand->mode == Addressing_Constant) { - check_is_expressible(c, operand, t); + check_is_expressible(c, operand, target_type); if (operand->mode == Addressing_Invalid) { return; } update_untyped_expr_value(c, operand->expr, operand->value); - } else { + } + + { switch (operand->type->Basic.kind) { case Basic_UntypedBool: if (!is_type_boolean(target_type)) { @@ -5195,6 +5194,11 @@ gb_internal ExactValue get_constant_field_single(CheckerContext *c, ExactValue v } } else { TypeAndValue index_tav = fv->field->tav; + if (index_tav.mode != Addressing_Constant) { + if (success_) *success_ = false; + if (finish_) *finish_ = true; + return empty_exact_value; + } GB_ASSERT(index_tav.mode == Addressing_Constant); ExactValue index_value = index_tav.value; if (is_type_enumerated_array(node->tav.type)) { @@ -8172,13 +8176,7 @@ gb_internal void check_objc_call_expr(CheckerContext *c, Operand *operand, Ast * Type *return_type = proc.result_count == 0 ? nullptr : proc.results->Tuple.variables[0]->type; bool is_return_instancetype = return_type != nullptr && return_type == t_objc_instancetype; - if (params.count == 0 || !is_type_objc_ptr_to_object(params[0]->type)) { - if (!proc_entity->Procedure.is_objc_class_method) { - // Not a class method, invalid call - error(call, "Invalid Objective-C call: The Objective-C method is not a class method but this first parameter is not an Objective-C object pointer."); - return; - } - + if (proc_entity->Procedure.is_objc_class_method) { if (is_return_instancetype) { if (ce->proc->kind == Ast_SelectorExpr) { ast_node(se, SelectorExpr, ce->proc); @@ -8194,7 +8192,8 @@ gb_internal void check_objc_call_expr(CheckerContext *c, Operand *operand, Ast * self_type = t_objc_Class; params_start = 0; - } else if (ce->args.count > 0) { + } else { + GB_ASSERT(ce->args.count > 0); GB_ASSERT(is_type_objc_ptr_to_object(params[0]->type)); if (ce->args[0]->tav.objc_super_target) { @@ -8226,7 +8225,7 @@ gb_internal void check_objc_call_expr(CheckerContext *c, Operand *operand, Ast * add_objc_proc_type(c, call, return_type, param_types); } -gb_internal ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *proc, Slice const &args, ProcInlining inlining, Type *type_hint) { +gb_internal ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *proc, Slice const &args, ProcInlining inlining, ProcTailing tailing, Type *type_hint) { if (proc != nullptr && proc->kind == Ast_BasicDirective) { ast_node(bd, BasicDirective, proc); @@ -8257,7 +8256,10 @@ gb_internal ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *c return Expr_Expr; } if (inlining != ProcInlining_none) { - error(call, "Inlining operators are not allowed on built-in procedures"); + error(call, "Inlining directives are not allowed on built-in procedures"); + } + if (tailing != ProcTailing_none) { + error(call, "Tailing directives are not allowed on built-in procedures"); } } else { if (proc != nullptr) { @@ -8399,6 +8401,7 @@ gb_internal ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *c } bool is_call_inlined = false; + bool is_call_tailed = true; switch (inlining) { case ProcInlining_inline: @@ -8433,6 +8436,23 @@ gb_internal ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *c } } + switch (tailing) { + case ProcTailing_none: + break; + case ProcTailing_must_tail: + is_call_tailed = true; + if (c->curr_proc_sig == nullptr || !are_types_identical(c->curr_proc_sig, pt)) { + ERROR_BLOCK(); + gbString a = type_to_string(pt); + gbString b = type_to_string(c->curr_proc_sig); + error(call, "Use of '#must_tail' of a procedure must have the same type as the procedure it was called within"); + error_line("\tCall type: %s, parent type: %s", a, b); + gb_string_free(b); + gb_string_free(a); + } + break; + } + { String invalid; if (pt->kind == Type_Proc && pt->Proc.require_target_feature.len != 0) { @@ -8759,6 +8779,14 @@ gb_internal bool check_is_operand_compound_lit_constant(CheckerContext *c, Opera if (is_operand_nil(*o)) { return true; } + if (is_type_any(field_type)) { + return false; + } + if (field_type != nullptr && is_type_typeid(field_type) && o->mode == Addressing_Type) { + add_type_info_type(c, o->type); + return true; + } + Ast *expr = unparen_expr(o->expr); if (expr != nullptr) { Entity *e = strip_entity_wrapping(entity_from_expr(expr)); @@ -8769,13 +8797,12 @@ gb_internal bool check_is_operand_compound_lit_constant(CheckerContext *c, Opera add_type_and_value(c, expr, Addressing_Constant, type_of_expr(expr), exact_value_procedure(expr)); return true; } - } - if (field_type != nullptr && is_type_typeid(field_type) && o->mode == Addressing_Type) { - add_type_info_type(c, o->type); - return true; - } - if (is_type_any(field_type)) { - return false; + + if (e != nullptr && e->kind == Entity_Variable && e->Variable.is_rodata) { + // DeclInfo *d = e->decl_info; + // TODO(bill): rodata inlining for non-indirect values + // e.g. **NOT** []T{...} + } } return o->mode == Addressing_Constant; } @@ -11044,8 +11071,20 @@ gb_internal ExprKind check_type_assertion(CheckerContext *c, Operand *o, Ast *no end:; if ((c->state_flags & StateFlag_no_type_assert) == 0) { - add_package_dependency(c, "runtime", "type_assertion_check"); - add_package_dependency(c, "runtime", "type_assertion_check2"); + bool has_context = true; + if (c->proc_name.len == 0 && c->curr_proc_sig == nullptr) { + has_context = false; + } else if ((c->scope->flags & ScopeFlag_ContextDefined) == 0) { + has_context = false; + } + + if (has_context) { + add_package_dependency(c, "runtime", "type_assertion_check_with_context"); + add_package_dependency(c, "runtime", "type_assertion_check2_with_context"); + } else { + add_package_dependency(c, "runtime", "type_assertion_check_contextless"); + add_package_dependency(c, "runtime", "type_assertion_check2_contextless"); + } } return kind; } @@ -11570,6 +11609,15 @@ gb_internal ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast return kind; case_end; + case_ast_node(ht, HelperType, node); + Type *type = check_type(c, ht->type); + if (type != nullptr && type != t_invalid) { + o->mode = Addressing_Type; + o->type = type; + } + return kind; + case_end; + case_ast_node(i, Implicit, node); switch (i->kind) { case Token_context: @@ -11832,7 +11880,7 @@ gb_internal ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast case_end; case_ast_node(ce, CallExpr, node); - return check_call_expr(c, o, node, ce->proc, ce->args, ce->inlining, type_hint); + return check_call_expr(c, o, node, ce->proc, ce->args, ce->inlining, ce->tailing, type_hint); case_end; case_ast_node(de, DerefExpr, node); @@ -12103,12 +12151,12 @@ gb_internal bool is_exact_value_zero(ExactValue const &v) { -gb_internal bool compare_exact_values_compound_lit(TokenKind op, ExactValue x, ExactValue y, bool *do_break_) { +gb_internal bool compare_exact_values_compound_lit(TokenKind op, ExactValue x, ExactValue y) { ast_node(x_cl, CompoundLit, x.value_compound); ast_node(y_cl, CompoundLit, y.value_compound); if (x_cl->elems.count != y_cl->elems.count) { - if (do_break_) *do_break_ = true; + return false; } bool test = op == Token_CmpEq; @@ -12573,6 +12621,12 @@ gb_internal gbString write_expr_to_string(gbString str, Ast *node, bool shorthan case_end; case_ast_node(ce, CallExpr, node); + switch (ce->tailing) { + case ProcTailing_must_tail: + str = gb_string_appendc(str, "#must_tail "); + break; + } + switch (ce->inlining) { case ProcInlining_inline: str = gb_string_appendc(str, "#force_inline "); @@ -12640,8 +12694,10 @@ gb_internal gbString write_expr_to_string(gbString str, Ast *node, bool shorthan str = write_expr_to_string(str, st->polymorphic_params, shorthand); str = gb_string_appendc(str, ") "); } - if (st->is_packed) str = gb_string_appendc(str, "#packed "); - if (st->is_raw_union) str = gb_string_appendc(str, "#raw_union "); + if (st->is_packed) str = gb_string_appendc(str, "#packed "); + if (st->is_raw_union) str = gb_string_appendc(str, "#raw_union "); + if (st->is_all_or_none) str = gb_string_appendc(str, "#all_or_none "); + if (st->is_simple) str = gb_string_appendc(str, "#simple "); if (st->align) { str = gb_string_appendc(str, "#align "); str = write_expr_to_string(str, st->align, shorthand); diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index 26860db4f..1f433df36 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -1027,7 +1027,9 @@ gb_internal void check_unroll_range_stmt(CheckerContext *ctx, Ast *node, u32 mod error(operand.expr, "Cannot iterate over '%s' of type '%s' in an '#unroll for' statement", s, t); gb_string_free(t); gb_string_free(s); - } else if (operand.mode != Addressing_Constant && unroll_count <= 0) { + } else if (operand.mode != Addressing_Constant && ( + unroll_count <= 0 && + compare_exact_values(Token_CmpEq, inline_for_depth, exact_value_i64(0)))) { error(operand.expr, "An '#unroll for' expression must be known at compile time"); } } diff --git a/src/check_type.cpp b/src/check_type.cpp index 2452cc6d0..b1d0045e9 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -679,6 +679,21 @@ gb_internal void check_struct_type(CheckerContext *ctx, Type *struct_type, Ast * gb_unused(where_clause_ok); } check_struct_fields(ctx, node, &struct_type->Struct.fields, &struct_type->Struct.tags, st->fields, min_field_count, struct_type, context); + + if (st->is_simple) { + bool success = true; + for (Entity *f : struct_type->Struct.fields) { + if (!is_type_nearly_simple_compare(f->type)) { + gbString s = type_to_string(f->type); + error(f->token, "'struct #simple' requires all fields to be at least 'nearly simple compare', got %s", s); + gb_string_free(s); + } + } + if (success) { + struct_type->Struct.is_simple = true; + } + } + wait_signal_set(&struct_type->Struct.fields_wait_signal); } @@ -3753,6 +3768,20 @@ gb_internal bool check_type_internal(CheckerContext *ctx, Ast *e, Type **type, T set_base_type(named_type, *type); return true; case_end; + + default: { + Operand o = {}; + check_expr_base(ctx, &o, e, nullptr); + + if (o.mode == Addressing_Constant && + o.value.kind == ExactValue_Typeid) { + Type *t = o.value.value_typeid; + if (t != nullptr && t != t_invalid) { + *type = t; + return true; + } + } + } } *type = t_invalid; diff --git a/src/checker.cpp b/src/checker.cpp index 4d5482933..453f3e241 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -1530,17 +1530,16 @@ gb_internal void destroy_checker_info(CheckerInfo *i) { map_destroy(&i->load_directory_map); } -gb_internal CheckerContext make_checker_context(Checker *c) { - CheckerContext ctx = {}; - ctx.checker = c; - ctx.info = &c->info; - ctx.scope = builtin_pkg->scope; - ctx.pkg = builtin_pkg; +gb_internal void init_checker_context(CheckerContext *ctx, Checker *c) { + ctx->checker = c; + ctx->info = &c->info; + ctx->scope = builtin_pkg->scope; + ctx->pkg = builtin_pkg; - ctx.type_path = new_checker_type_path(heap_allocator()); - ctx.type_level = 0; - return ctx; + ctx->type_path = new_checker_type_path(heap_allocator()); + ctx->type_level = 0; } + gb_internal void destroy_checker_context(CheckerContext *ctx) { destroy_checker_type_path(ctx->type_path, heap_allocator()); } @@ -1605,7 +1604,7 @@ gb_internal void init_checker(Checker *c) { mpsc_init(&c->global_untyped_queue, a); // , 1<<20); mpsc_init(&c->soa_types_to_complete, a); // , 1<<20); - c->builtin_ctx = make_checker_context(c); + init_checker_context(&c->builtin_ctx, c); } gb_internal void destroy_checker(Checker *c) { @@ -3581,7 +3580,7 @@ gb_internal DECL_ATTRIBUTE_PROC(proc_decl_attribute) { return true; } else if (name == "test") { if (value != nullptr) { - error(value, "'%.*s' expects no parameter, or a string literal containing \"file\" or \"package\"", LIT(name)); + error(value, "Expected no value for '%.*s'", LIT(name)); } ac->test = true; return true; @@ -3629,13 +3628,13 @@ gb_internal DECL_ATTRIBUTE_PROC(proc_decl_attribute) { return true; } else if (name == "init") { if (value != nullptr) { - error(value, "'%.*s' expects no parameter, or a string literal containing \"file\" or \"package\"", LIT(name)); + error(value, "Expected no value for '%.*s'", LIT(name)); } ac->init = true; return true; } else if (name == "fini") { if (value != nullptr) { - error(value, "'%.*s' expects no parameter, or a string literal containing \"file\" or \"package\"", LIT(name)); + error(value, "Expected no value for '%.*s'", LIT(name)); } ac->fini = true; return true; @@ -3991,6 +3990,12 @@ gb_internal DECL_ATTRIBUTE_PROC(proc_decl_attribute) { } ac->no_sanitize_memory = true; return true; + } else if (name == "no_sanitize_thread") { + if (value != nullptr) { + error(value, "'%.*s' expects no parameter", LIT(name)); + } + ac->no_sanitize_thread = true; + return true; } return false; } @@ -4027,6 +4032,7 @@ gb_internal DECL_ATTRIBUTE_PROC(var_decl_attribute) { } else if (ev.kind == ExactValue_String) { String model = ev.value_string; if (model == "default" || + model == "globaldynamic" || model == "localdynamic" || model == "initialexec" || model == "localexec") { @@ -4035,6 +4041,7 @@ gb_internal DECL_ATTRIBUTE_PROC(var_decl_attribute) { ERROR_BLOCK(); error(elem, "Invalid thread local model '%.*s'. Valid models:", LIT(model)); error_line("\tdefault\n"); + error_line("\tglobaldynamic\n"); error_line("\tlocaldynamic\n"); error_line("\tinitialexec\n"); error_line("\tlocalexec\n"); @@ -4962,7 +4969,7 @@ gb_internal void check_collect_entities(CheckerContext *c, Slice const &n gb_internal CheckerContext *create_checker_context(Checker *c) { CheckerContext *ctx = gb_alloc_item(permanent_allocator(), CheckerContext); - *ctx = make_checker_context(c); + init_checker_context(ctx, c); return ctx; } @@ -5407,7 +5414,8 @@ gb_internal DECL_ATTRIBUTE_PROC(foreign_import_decl_attribute) { } gb_internal void check_foreign_import_fullpaths(Checker *c) { - CheckerContext ctx = make_checker_context(c); + CheckerContext ctx = {}; + init_checker_context(&ctx, c); UntypedExprInfoMap untyped = {}; defer (map_destroy(&untyped)); @@ -5790,7 +5798,7 @@ gb_internal void check_collect_entities_all(Checker *c) { for (isize i = 0; i < thread_count; i++) { auto *wd = &collect_entity_worker_data[i]; wd->c = c; - wd->ctx = make_checker_context(c); + init_checker_context(&wd->ctx, c); map_init(&wd->untyped); } @@ -5831,7 +5839,7 @@ gb_internal void check_export_entities(Checker *c) { for (isize i = 0; i < thread_count; i++) { auto *wd = &collect_entity_worker_data[i]; map_clear(&wd->untyped); - wd->ctx = make_checker_context(c); + init_checker_context(&wd->ctx, c); } for (auto const &entry : c->info.packages) { @@ -5898,7 +5906,8 @@ gb_internal void check_import_entities(Checker *c) { } TIME_SECTION("check_import_entities - collect file decls"); - CheckerContext ctx = make_checker_context(c); + CheckerContext ctx = {}; + init_checker_context(&ctx, c); UntypedExprInfoMap untyped = {}; defer (map_destroy(&untyped)); @@ -6247,7 +6256,8 @@ gb_internal bool check_proc_info(Checker *c, ProcInfo *pi, UntypedExprInfoMap *u } } - CheckerContext ctx = make_checker_context(c); + CheckerContext ctx = {}; + init_checker_context(&ctx, c); defer (destroy_checker_context(&ctx)); reset_checker_context(&ctx, pi->file, untyped); ctx.decl = pi->decl; diff --git a/src/checker.hpp b/src/checker.hpp index bda7b2746..f9c279a51 100644 --- a/src/checker.hpp +++ b/src/checker.hpp @@ -141,6 +141,7 @@ struct AttributeContext { bool instrumentation_exit : 1; bool no_sanitize_address : 1; bool no_sanitize_memory : 1; + bool no_sanitize_thread : 1; bool rodata : 1; bool ignore_duplicates : 1; u32 optimization_mode; // ProcedureOptimizationMode diff --git a/src/entity.cpp b/src/entity.cpp index 2b21fdcac..55aca8069 100644 --- a/src/entity.cpp +++ b/src/entity.cpp @@ -268,6 +268,7 @@ struct Entity { bool is_anonymous : 1; bool no_sanitize_address : 1; bool no_sanitize_memory : 1; + bool no_sanitize_thread : 1; bool is_objc_impl_or_import : 1; bool is_objc_class_method : 1; } Procedure; diff --git a/src/exact_value.cpp b/src/exact_value.cpp index f266b8b24..0f425e043 100644 --- a/src/exact_value.cpp +++ b/src/exact_value.cpp @@ -947,7 +947,7 @@ gb_internal gb_inline i32 cmp_f64(f64 a, f64 b) { return (a > b) - (a < b); } -gb_internal bool compare_exact_values_compound_lit(TokenKind op, ExactValue x, ExactValue y, bool *do_break_); +gb_internal bool compare_exact_values_compound_lit(TokenKind op, ExactValue x, ExactValue y); gb_internal bool compare_exact_values(TokenKind op, ExactValue x, ExactValue y) { match_exact_values(&x, &y); @@ -1060,18 +1060,13 @@ gb_internal bool compare_exact_values(TokenKind op, ExactValue x, ExactValue y) case ExactValue_Compound: if (op != Token_CmpEq && op != Token_NotEq) { - break; + return false; } if (x.kind != y.kind) { - break; + return false; } - bool do_break = false; - bool res = compare_exact_values_compound_lit(op, x, y, &do_break); - if (do_break) { - break; - } - return res; + return compare_exact_values_compound_lit(op, x, y); } GB_PANIC("Invalid comparison: %d", x.kind); diff --git a/src/linker.cpp b/src/linker.cpp index c2a3ee928..bc6268049 100644 --- a/src/linker.cpp +++ b/src/linker.cpp @@ -174,7 +174,7 @@ try_cross_linking:; switch (build_context.linker_choice) { case Linker_Default: break; case Linker_lld: section_name = str_lit("lld-link"); break; - #if defined(GB_SYSTEM_LINUX) + #if defined(GB_SYSTEM_LINUX) || defined(GB_SYSTEM_FREEBSD) || defined(GB_SYSTEM_NETBSD) case Linker_mold: section_name = str_lit("mold-link"); break; #endif #if defined(GB_SYSTEM_WINDOWS) @@ -737,7 +737,21 @@ try_cross_linking:; } if (build_context.build_mode == BuildMode_StaticLibrary) { - compiler_error("TODO(bill): -build-mode:static on non-windows targets"); + TIME_SECTION("Static Library Creation"); + + gbString ar_command = gb_string_make(heap_allocator(), ""); + defer (gb_string_free(ar_command)); + + ar_command = gb_string_appendc(ar_command, "ar rcs "); + ar_command = gb_string_append_fmt(ar_command, "\"%.*s\" ", LIT(output_filename)); + ar_command = gb_string_appendc(ar_command, object_files); + + result = system_exec_command_line_app("ar", ar_command); + if (result) { + return result; + } + + return result; } // NOTE(dweiler): We use clang as a frontend for the linker as there are diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index 1cde65640..c15f326f8 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -239,9 +239,9 @@ gb_internal lbContextData *lb_push_context_onto_stack(lbProcedure *p, lbAddr ctx gb_internal String lb_internal_gen_name_from_type(char const *prefix, Type *type) { gbString str = gb_string_make(permanent_allocator(), prefix); - u64 hash = type_hash_canonical_type(type); - str = gb_string_appendc(str, "-"); - str = gb_string_append_fmt(str, "%llu", cast(unsigned long long)hash); + str = gb_string_appendc(str, "$$"); + gbString ct = temp_canonical_string(type); + str = gb_string_append_length(str, ct, gb_string_length(ct)); String proc_name = make_string(cast(u8 const *)str, gb_string_length(str)); return proc_name; } @@ -2045,6 +2045,11 @@ gb_internal bool lb_init_global_var(lbModule *m, lbProcedure *p, Entity *e, Ast lb_emit_store(p, data, lb_emit_conv(p, gp, t_rawptr)); lb_emit_store(p, ti, lb_typeid(p->module, var_type)); } else { + i64 sz = type_size_of(e->type); + if (sz >= 4 * 1024) { + warning(init_expr, "[Possible Code Generation Issue] Non-constant initialization is large (%lld bytes), and might cause problems with LLVM", cast(long long)sz); + } + LLVMTypeRef vt = llvm_addr_type(p->module, var.var); lbValue src0 = lb_emit_conv(p, var.init, t); LLVMValueRef src = OdinLLVMBuildTransmute(p, src0.value, vt); @@ -2111,7 +2116,7 @@ gb_internal void lb_create_startup_runtime_generate_body(lbModule *m, lbProcedur for (Entity *e : info->init_procedures) { lbValue value = lb_find_procedure_value_from_entity(m, e); - lb_emit_call(p, value, {}, ProcInlining_none); + lb_emit_call(p, value, {}, ProcInlining_none, ProcTailing_none); } @@ -2157,7 +2162,7 @@ gb_internal lbProcedure *lb_create_cleanup_runtime(lbModule *main_module) { // C for (Entity *e : info->fini_procedures) { lbValue value = lb_find_procedure_value_from_entity(main_module, e); - lb_emit_call(p, value, {}, ProcInlining_none); + lb_emit_call(p, value, {}, ProcInlining_none, ProcTailing_none); } lb_end_procedure_body(p); @@ -2850,7 +2855,7 @@ gb_internal lbProcedure *lb_create_main_procedure(lbModule *m, lbProcedure *star } lbValue startup_runtime_value = {startup_runtime->value, startup_runtime->type}; - lb_emit_call(p, startup_runtime_value, {}, ProcInlining_none); + lb_emit_call(p, startup_runtime_value, {}, ProcInlining_none, ProcTailing_none); if (build_context.command_kind == Command_test) { Type *t_Internal_Test = find_type_in_pkg(m->info, str_lit("testing"), str_lit("Internal_Test")); @@ -2917,16 +2922,16 @@ gb_internal lbProcedure *lb_create_main_procedure(lbModule *m, lbProcedure *star auto exit_args = array_make(temporary_allocator(), 1); exit_args[0] = lb_emit_select(p, result, lb_const_int(m, t_int, 0), lb_const_int(m, t_int, 1)); - lb_emit_call(p, exit_runner, exit_args, ProcInlining_none); + lb_emit_call(p, exit_runner, exit_args, ProcInlining_none, ProcTailing_none); } else { if (m->info->entry_point != nullptr) { lbValue entry_point = lb_find_procedure_value_from_entity(m, m->info->entry_point); - lb_emit_call(p, entry_point, {}, ProcInlining_no_inline); + lb_emit_call(p, entry_point, {}, ProcInlining_no_inline, ProcTailing_none); } if (call_cleanup) { lbValue cleanup_runtime_value = {cleanup_runtime->value, cleanup_runtime->type}; - lb_emit_call(p, cleanup_runtime_value, {}, ProcInlining_none); + lb_emit_call(p, cleanup_runtime_value, {}, ProcInlining_none, ProcTailing_none); } if (is_dll_main) { diff --git a/src/llvm_backend.hpp b/src/llvm_backend.hpp index da5d91f2e..3491c0d39 100644 --- a/src/llvm_backend.hpp +++ b/src/llvm_backend.hpp @@ -345,6 +345,7 @@ struct lbProcedure { Ast * body; u64 tags; ProcInlining inlining; + ProcTailing tailing; bool is_foreign; bool is_export; bool is_entry_point; @@ -484,7 +485,7 @@ gb_internal void lb_emit_defer_stmts(lbProcedure *p, lbDeferExitKind kind, lbBlo gb_internal void lb_emit_defer_stmts(lbProcedure *p, lbDeferExitKind kind, lbBlock *block, Ast *node); gb_internal lbValue lb_emit_transmute(lbProcedure *p, lbValue value, Type *t); gb_internal lbValue lb_emit_comp(lbProcedure *p, TokenKind op_kind, lbValue left, lbValue right); -gb_internal lbValue lb_emit_call(lbProcedure *p, lbValue value, Array const &args, ProcInlining inlining = ProcInlining_none); +gb_internal lbValue lb_emit_call(lbProcedure *p, lbValue value, Array const &args, ProcInlining inlining = ProcInlining_none, ProcTailing tailing = ProcTailing_none); gb_internal lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t); gb_internal lbValue lb_emit_comp_against_nil(lbProcedure *p, TokenKind op_kind, lbValue x); @@ -618,7 +619,7 @@ gb_internal LLVMValueRef lb_mem_zero_ptr_internal(lbProcedure *p, LLVMValueRef p gb_internal LLVMValueRef lb_mem_zero_ptr_internal(lbProcedure *p, LLVMValueRef ptr, usize len, unsigned alignment, bool is_volatile); gb_internal gb_inline i64 lb_max_zero_init_size(void) { - return cast(i64)(4*build_context.int_size); + return cast(i64)(8); } gb_internal LLVMTypeRef OdinLLVMGetArrayElementType(LLVMTypeRef type); @@ -670,6 +671,7 @@ enum lbCallingConventionKind : unsigned { lbCallingConvention_PreserveAll = 15, lbCallingConvention_Swift = 16, lbCallingConvention_CXX_FAST_TLS = 17, + lbCallingConvention_PreserveNone = 21, lbCallingConvention_FirstTargetCC = 64, lbCallingConvention_X86_StdCall = 64, lbCallingConvention_X86_FastCall = 65, @@ -723,6 +725,10 @@ lbCallingConventionKind const lb_calling_convention_map[ProcCC_MAX] = { lbCallingConvention_Win64, // ProcCC_Win64, lbCallingConvention_X86_64_SysV, // ProcCC_SysV, + lbCallingConvention_PreserveNone, // ProcCC_PreserveNone, + lbCallingConvention_PreserveMost, // ProcCC_PreserveMost, + lbCallingConvention_PreserveAll, // ProcCC_PreserveAll, + }; enum : LLVMDWARFTypeEncoding { diff --git a/src/llvm_backend_const.cpp b/src/llvm_backend_const.cpp index 22e124792..8ce2137ab 100644 --- a/src/llvm_backend_const.cpp +++ b/src/llvm_backend_const.cpp @@ -498,6 +498,13 @@ gb_internal LLVMValueRef lb_big_int_to_llvm(lbModule *m, Type *original_type, Bi if (big_int_is_zero(a)) { return LLVMConstNull(lb_type(m, original_type)); } + + BigInt val = {}; + big_int_init(&val, a); + + if (big_int_is_neg(&val)) { + mp_incr(&val); + } size_t sz = cast(size_t)type_size_of(original_type); u64 rop64[4] = {}; // 2 u64 is the maximum we will ever need, so doubling it will be fine :P @@ -509,7 +516,7 @@ gb_internal LLVMValueRef lb_big_int_to_llvm(lbModule *m, Type *original_type, Bi size_t nails = 0; mp_endian endian = MP_LITTLE_ENDIAN; - max_count = mp_pack_count(a, nails, size); + max_count = mp_pack_count(&val, nails, size); if (sz < max_count) { debug_print_big_int(a); gb_printf_err("%s -> %tu\n", type_to_string(original_type), sz); @@ -520,7 +527,7 @@ gb_internal LLVMValueRef lb_big_int_to_llvm(lbModule *m, Type *original_type, Bi mp_err err = mp_pack(rop, sz, &written, MP_LSB_FIRST, size, endian, nails, - a); + &val); GB_ASSERT(err == MP_OKAY); if (!is_type_endian_little(original_type)) { @@ -531,12 +538,18 @@ gb_internal LLVMValueRef lb_big_int_to_llvm(lbModule *m, Type *original_type, Bi } } + if (big_int_is_neg(a)) { + // sizeof instead of sz for sign extend to work properly + for (size_t i = 0; i < sizeof rop64; i++) { + rop[i] = ~rop[i]; + } + } + + big_int_dealloc(&val); + GB_ASSERT(!is_type_array(original_type)); LLVMValueRef value = LLVMConstIntOfArbitraryPrecision(lb_type(m, original_type), cast(unsigned)((sz+7)/8), cast(u64 *)rop); - if (big_int_is_neg(a)) { - value = LLVMConstNeg(value); - } return value; } diff --git a/src/llvm_backend_expr.cpp b/src/llvm_backend_expr.cpp index dba61df44..aba196af8 100644 --- a/src/llvm_backend_expr.cpp +++ b/src/llvm_backend_expr.cpp @@ -282,11 +282,16 @@ gb_internal lbValue lb_emit_unary_arith(lbProcedure *p, TokenKind op, lbValue x, return res; } - -gb_internal IntegerDivisionByZeroKind lb_check_for_integer_division_by_zero_behaviour(lbProcedure *p) { +gb_internal u64 lb_get_file_feature_flags(lbProcedure *p, Ast *expr = nullptr) { AstFile *file = nullptr; - if (p->body && p->body->file()) { + if (expr != nullptr) { + file = expr->file(); + } + + if (file != nullptr) { + // it is now set + } else if (p->body && p->body->file()) { file = p->body->file(); } else if (p->type_expr && p->type_expr->file()) { file = p->type_expr->file(); @@ -295,20 +300,29 @@ gb_internal IntegerDivisionByZeroKind lb_check_for_integer_division_by_zero_beha } if (file != nullptr && file->feature_flags_set) { - u64 flags = file->feature_flags; - if (flags & OptInFeatureFlag_IntegerDivisionByZero_Trap) { - return IntegerDivisionByZero_Trap; - } - if (flags & OptInFeatureFlag_IntegerDivisionByZero_Zero) { - return IntegerDivisionByZero_Zero; - } - if (flags & OptInFeatureFlag_IntegerDivisionByZero_Self) { - return IntegerDivisionByZero_Self; - } - if (flags & OptInFeatureFlag_IntegerDivisionByZero_AllBits) { - return IntegerDivisionByZero_AllBits; - } + return file->feature_flags; } + return 0; +} + + + +gb_internal IntegerDivisionByZeroKind lb_check_for_integer_division_by_zero_behaviour(lbProcedure *p) { + u64 flags = lb_get_file_feature_flags(p); + + if (flags & OptInFeatureFlag_IntegerDivisionByZero_Trap) { + return IntegerDivisionByZero_Trap; + } + if (flags & OptInFeatureFlag_IntegerDivisionByZero_Zero) { + return IntegerDivisionByZero_Zero; + } + if (flags & OptInFeatureFlag_IntegerDivisionByZero_Self) { + return IntegerDivisionByZero_Self; + } + if (flags & OptInFeatureFlag_IntegerDivisionByZero_AllBits) { + return IntegerDivisionByZero_AllBits; + } + return build_context.integer_division_by_zero_behaviour; } @@ -3802,6 +3816,17 @@ gb_internal lbValue lb_build_unary_and(lbProcedure *p, Ast *expr) { Type *type = type_of_expr(ue_expr); GB_ASSERT(!is_type_tuple(type)); + bool do_type_check = true; + if (build_context.no_type_assert) { + u64 feature_flags = lb_get_file_feature_flags(p, ue_expr); + if ((feature_flags & OptInFeatureFlag_ForceTypeAssert) == 0) { + do_type_check = false; + } + + } else if ((p->state_flags & StateFlag_no_type_assert) != 0) { + do_type_check = false; + } + lbValue e = lb_build_expr(p, ta->expr); Type *t = type_deref(e.type); if (is_type_union(t)) { @@ -3813,7 +3838,7 @@ gb_internal lbValue lb_build_unary_and(lbProcedure *p, Ast *expr) { Type *dst_type = type; - if (!build_context.no_type_assert && (p->state_flags & StateFlag_no_type_assert) == 0) { + if (do_type_check) { lbValue src_tag = {}; lbValue dst_tag = {}; if (is_type_union_maybe_pointer(src_type)) { @@ -3840,7 +3865,12 @@ gb_internal lbValue lb_build_unary_and(lbProcedure *p, Ast *expr) { args[4] = lb_typeid(p->module, src_type); args[5] = lb_typeid(p->module, dst_type); } - lb_emit_runtime_call(p, "type_assertion_check", args); + + char const *name = "type_assertion_check_contextless"; + if (p->context_stack.count > 0) { + name = "type_assertion_check_with_context"; + } + lb_emit_runtime_call(p, name, args); } lbValue data_ptr = v; @@ -3851,21 +3881,33 @@ gb_internal lbValue lb_build_unary_and(lbProcedure *p, Ast *expr) { v = lb_emit_load(p, v); } lbValue data_ptr = lb_emit_struct_ev(p, v, 0); - if (!build_context.no_type_assert && (p->state_flags & StateFlag_no_type_assert) == 0) { + if (do_type_check) { GB_ASSERT(!build_context.no_rtti); lbValue any_id = lb_emit_struct_ev(p, v, 1); + isize arg_count = 6; + if (build_context.no_rtti) { + arg_count = 4; + } + lbValue id = lb_typeid(p->module, type); lbValue ok = lb_emit_comp(p, Token_CmpEq, any_id, id); - auto args = array_make(permanent_allocator(), 6); + auto args = array_make(permanent_allocator(), arg_count); args[0] = ok; lb_set_file_line_col(p, array_slice(args, 1, args.count), pos); - args[4] = any_id; - args[5] = id; - lb_emit_runtime_call(p, "type_assertion_check", args); + if (!build_context.no_rtti) { + args[4] = any_id; + args[5] = id; + } + + char const *name = "type_assertion_check_contextless"; + if (p->context_stack.count > 0) { + name = "type_assertion_check_with_context"; + } + lb_emit_runtime_call(p, name, args); } return lb_emit_conv(p, data_ptr, tv.type); diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp index 4ebb40d96..c0e57143d 100644 --- a/src/llvm_backend_general.cpp +++ b/src/llvm_backend_general.cpp @@ -2628,6 +2628,8 @@ gb_internal bool lb_apply_thread_local_model(LLVMValueRef value, String model) { LLVMThreadLocalMode mode = LLVMGeneralDynamicTLSModel; if (model == "default") { mode = LLVMGeneralDynamicTLSModel; + } else if (model == "globaldynamic") { + mode = LLVMGeneralDynamicTLSModel; } else if (model == "localdynamic") { mode = LLVMLocalDynamicTLSModel; } else if (model == "initialexec") { diff --git a/src/llvm_backend_opt.cpp b/src/llvm_backend_opt.cpp index 4971b1f10..4131f32bf 100644 --- a/src/llvm_backend_opt.cpp +++ b/src/llvm_backend_opt.cpp @@ -309,7 +309,15 @@ gb_internal void lb_run_remove_dead_instruction_pass(lbProcedure *p) { // NOTE(bill): Explicit instructions are set here because some instructions could have side effects switch (LLVMGetInstructionOpcode(curr_instr)) { - // case LLVMAlloca: + case LLVMAlloca: + if (map_get(&p->tuple_fix_map, curr_instr) != nullptr) { + // NOTE(bill, 2025-12-27): Remove temporary tuple fix alloca instructions + // if they are never used + removal_count += 1; + LLVMInstructionEraseFromParent(curr_instr); + was_dead_instructions = true; + } + break; case LLVMLoad: if (LLVMGetVolatile(curr_instr)) { break; diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp index 27167aefd..837d7ce48 100644 --- a/src/llvm_backend_proc.cpp +++ b/src/llvm_backend_proc.cpp @@ -12,9 +12,9 @@ gb_internal void lb_mem_copy_overlapping(lbProcedure *p, lbValue dst, lbValue sr len = lb_emit_conv(p, len, t_int); char const *name = "llvm.memmove"; - if (LLVMIsConstant(len.value)) { + if (!p->is_startup && LLVMIsConstant(len.value)) { i64 const_len = cast(i64)LLVMConstIntGetSExtValue(len.value); - if (const_len <= 4*build_context.int_size) { + if (const_len <= lb_max_zero_init_size()) { name = "llvm.memmove.inline"; } } @@ -41,9 +41,9 @@ gb_internal void lb_mem_copy_non_overlapping(lbProcedure *p, lbValue dst, lbValu len = lb_emit_conv(p, len, t_int); char const *name = "llvm.memcpy"; - if (LLVMIsConstant(len.value)) { + if (!p->is_startup && LLVMIsConstant(len.value)) { i64 const_len = cast(i64)LLVMConstIntGetSExtValue(len.value); - if (const_len <= 4*build_context.int_size) { + if (const_len <= lb_max_zero_init_size()) { name = "llvm.memcpy.inline"; } } @@ -117,6 +117,7 @@ gb_internal lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool i p->type_expr = decl->type_expr; p->body = pl->body; p->inlining = pl->inlining; + p->tailing = pl->tailing; p->is_foreign = entity->Procedure.is_foreign; p->is_export = entity->Procedure.is_export; p->is_entry_point = false; @@ -152,6 +153,10 @@ gb_internal lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool i lb_ensure_abi_function_type(m, p); lb_add_function_type_attributes(p->value, p->abi_function_type, p->abi_function_type->calling_convention); + if (build_context.disable_unwind) { + lb_add_attribute_to_proc(m, p->value, "nounwind"); + } + if (pt->Proc.diverging) { lb_add_attribute_to_proc(m, p->value, "noreturn"); } @@ -346,7 +351,7 @@ gb_internal lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool i if (build_context.sanitizer_flags & SanitizerFlag_Memory && !entity->Procedure.no_sanitize_memory) { lb_add_attribute_to_proc(m, p->value, "sanitize_memory"); } - if (build_context.sanitizer_flags & SanitizerFlag_Thread) { + if (build_context.sanitizer_flags & SanitizerFlag_Thread && !entity->Procedure.no_sanitize_thread) { lb_add_attribute_to_proc(m, p->value, "sanitize_thread"); } } @@ -387,6 +392,7 @@ gb_internal lbProcedure *lb_create_dummy_procedure(lbModule *m, String link_name p->body = nullptr; p->tags = 0; p->inlining = ProcInlining_none; + p->tailing = ProcTailing_none; p->is_foreign = false; p->is_export = false; p->is_entry_point = false; @@ -855,7 +861,7 @@ gb_internal Array lb_value_to_array(lbProcedure *p, gbAllocator const & -gb_internal lbValue lb_emit_call_internal(lbProcedure *p, lbValue value, lbValue return_ptr, Array const &processed_args, Type *abi_rt, lbAddr context_ptr, ProcInlining inlining) { +gb_internal lbValue lb_emit_call_internal(lbProcedure *p, lbValue value, lbValue return_ptr, Array const &processed_args, Type *abi_rt, lbAddr context_ptr, ProcInlining inlining, ProcTailing tailing) { GB_ASSERT(p->module->ctx == LLVMGetTypeContext(LLVMTypeOf(value.value))); unsigned arg_count = cast(unsigned)processed_args.count; @@ -972,6 +978,15 @@ gb_internal lbValue lb_emit_call_internal(lbProcedure *p, lbValue value, lbValue break; } + switch (tailing) { + case ProcTailing_none: + break; + case ProcTailing_must_tail: + LLVMSetTailCall(ret, true); + LLVMSetTailCallKind(ret, LLVMTailCallKindMustTail); + break; + } + lbValue res = {}; res.value = ret; res.type = abi_rt; @@ -1045,7 +1060,7 @@ gb_internal lbValue lb_emit_conjugate(lbProcedure *p, lbValue val, Type *type) { return lb_emit_load(p, res); } -gb_internal lbValue lb_emit_call(lbProcedure *p, lbValue value, Array const &args, ProcInlining inlining) { +gb_internal lbValue lb_emit_call(lbProcedure *p, lbValue value, Array const &args, ProcInlining inlining, ProcTailing tailing) { lbModule *m = p->module; Type *pt = base_type(value.type); @@ -1168,10 +1183,10 @@ gb_internal lbValue lb_emit_call(lbProcedure *p, lbValue value, Array c if (return_by_pointer) { lbValue return_ptr = lb_add_local_generated(p, rt, true).addr; - lb_emit_call_internal(p, value, return_ptr, processed_args, nullptr, context_ptr, inlining); + lb_emit_call_internal(p, value, return_ptr, processed_args, nullptr, context_ptr, inlining, tailing); result = lb_emit_load(p, return_ptr); } else if (rt != nullptr) { - result = lb_emit_call_internal(p, value, {}, processed_args, rt, context_ptr, inlining); + result = lb_emit_call_internal(p, value, {}, processed_args, rt, context_ptr, inlining, tailing); if (ft->ret.cast_type) { result.value = OdinLLVMBuildTransmute(p, result.value, ft->ret.cast_type); } @@ -1184,7 +1199,7 @@ gb_internal lbValue lb_emit_call(lbProcedure *p, lbValue value, Array c result = lb_emit_conv(p, result, rt); } } else { - lb_emit_call_internal(p, value, {}, processed_args, nullptr, context_ptr, inlining); + lb_emit_call_internal(p, value, {}, processed_args, nullptr, context_ptr, inlining, tailing); } if (original_rt != rt) { @@ -1212,15 +1227,6 @@ gb_internal lbValue lb_emit_call(lbProcedure *p, lbValue value, Array c } tuple_fix_values[ret_count-1] = result; - #if 0 - for (isize j = 0; j < ret_count; j++) { - tuple_geps[j] = lb_emit_struct_ep(p, result_ptr, cast(i32)j); - } - for (isize j = 0; j < ret_count; j++) { - lb_emit_store(p, tuple_geps[j], tuple_fix_values[j]); - } - #endif - result = lb_emit_load(p, result_ptr); lbTupleFix tf = {tuple_fix_values}; @@ -4411,6 +4417,25 @@ gb_internal lbValue lb_build_call_expr_internal(lbProcedure *p, Ast *expr) { return lb_handle_objc_auto_send(p, expr, slice(call_args, 0, call_args.count)); } - return lb_emit_call(p, value, call_args, ce->inlining); + + ProcInlining inlining = ce->inlining; + ProcTailing tailing = ce->tailing; + + if (tailing == ProcTailing_none && + proc_entity && proc_entity->kind == Entity_Procedure && + proc_entity->decl_info && + proc_entity->decl_info->proc_lit) { + ast_node(pl, ProcLit, proc_entity->decl_info->proc_lit); + + if (pl->inlining != ProcInlining_none) { + inlining = pl->inlining; + } + + if (pl->tailing != ProcTailing_none) { + tailing = pl->tailing; + } + } + + return lb_emit_call(p, value, call_args, inlining, tailing); } diff --git a/src/llvm_backend_stmt.cpp b/src/llvm_backend_stmt.cpp index 3dbcea4fb..81755af2d 100644 --- a/src/llvm_backend_stmt.cpp +++ b/src/llvm_backend_stmt.cpp @@ -1434,12 +1434,13 @@ gb_internal void lb_build_unroll_range_stmt(lbProcedure *p, AstUnrollRangeStmt * if (unroll_count_ev.kind == ExactValue_Invalid) { - GB_ASSERT(expr->tav.mode == Addressing_Constant); Type *t = base_type(expr->tav.type); switch (t->kind) { case Type_Basic: + GB_ASSERT(expr->tav.mode == Addressing_Constant); + GB_ASSERT(is_type_string(t)); { ExactValue value = expr->tav.value; @@ -1720,7 +1721,45 @@ gb_internal void lb_build_switch_stmt(lbProcedure *p, AstSwitchStmt *ss, Scope * Ast *clause = body->stmts[i]; ast_node(cc, CaseClause, clause); - body_blocks[i] = lb_create_block(p, cc->list.count == 0 ? "switch.default.body" : "switch.case.body"); + char const *block_name = cc->list.count == 0 ? "switch.default.body" : "switch.case.body"; + + if (is_trivial && cc->list.count >= 1) { + gbString bn = gb_string_make(heap_allocator(), "switch.case."); + + Ast *first = cc->list[0]; + if (first->tav.mode == Addressing_Type) { + bn = gb_string_appendc(bn, "type."); + } else if (is_type_rune(first->tav.type)) { + bn = gb_string_appendc(bn, "rune."); + } else { + bn = gb_string_appendc(bn, "value."); + } + + for_array(i, cc->list) { + if (i > 0) { + bn = gb_string_appendc(bn, ".."); + } + + Ast *expr = cc->list[i]; + if (expr->tav.mode == Addressing_Type) { + bn = write_type_to_string(bn, expr->tav.type, false); + } else { + ExactValue value = expr->tav.value; + if (is_type_rune(expr->tav.type) && value.kind == ExactValue_Integer) { + Rune r = cast(Rune)exact_value_to_i64(value); + u8 rune_temp[6] = {}; + isize size = gb_utf8_encode_rune(rune_temp, r); + bn = gb_string_append_length(bn, rune_temp, size); + } else { + bn = write_exact_value_to_string(bn, value, 1024); + } + } + } + + block_name = cast(char const *)bn; + } + + body_blocks[i] = lb_create_block(p, block_name); if (cc->list.count == 0) { default_block = body_blocks[i]; } @@ -1962,7 +2001,7 @@ gb_internal void lb_build_type_switch_stmt(lbProcedure *p, AstTypeSwitchStmt *ss num_cases += cc->list.count; if (cc->list.count == 0) { GB_ASSERT(default_block == nullptr); - default_block = lb_create_block(p, "typeswitch.default.body"); + default_block = lb_create_block(p, "typeswitch.case.default"); else_block = default_block; } } @@ -2042,7 +2081,16 @@ gb_internal void lb_build_type_switch_stmt(lbProcedure *p, AstTypeSwitchStmt *ss continue; } - lbBlock *body = lb_create_block(p, "typeswitch.body"); + char const *body_name = "typeswitch.case"; + + if (!are_types_identical(case_entity->type, parent_base_type)) { + gbString canonical_name = temp_canonical_string(case_entity->type); + gbString bn = gb_string_make(heap_allocator(), "typeswitch.case."); + bn = gb_string_append_length(bn, canonical_name, gb_string_length(canonical_name)); + body_name = cast(char const *)bn; + } + + lbBlock *body = lb_create_block(p, body_name); if (p->debug_info != nullptr) { LLVMSetCurrentDebugLocation2(p->builder, lb_debug_location_from_ast(p, clause)); } @@ -2122,14 +2170,7 @@ gb_internal void lb_build_type_switch_stmt(lbProcedure *p, AstTypeSwitchStmt *ss gb_internal void lb_build_static_variables(lbProcedure *p, AstValueDecl *vd) { for_array(i, vd->names) { lbValue value = {}; - if (vd->values.count > 0) { - GB_ASSERT(vd->names.count == vd->values.count); - Ast *ast_value = vd->values[i]; - GB_ASSERT(ast_value->tav.mode == Addressing_Constant || - ast_value->tav.mode == Addressing_Invalid); - value = lb_const_value(p->module, ast_value->tav.type, ast_value->tav.value, LB_CONST_CONTEXT_DEFAULT_NO_LOCAL); - } Ast *ident = vd->names[i]; GB_ASSERT(!is_blank_ident(ident)); @@ -2137,6 +2178,19 @@ gb_internal void lb_build_static_variables(lbProcedure *p, AstValueDecl *vd) { GB_ASSERT(e->flags & EntityFlag_Static); String name = e->token.string; + if (vd->values.count > 0) { + GB_ASSERT(vd->names.count == vd->values.count); + Ast *ast_value = vd->values[i]; + GB_ASSERT(ast_value->tav.mode == Addressing_Constant || + ast_value->tav.mode == Addressing_Invalid); + + auto cc = LB_CONST_CONTEXT_DEFAULT_NO_LOCAL; + if (e->Variable.is_rodata) { + cc.is_rodata = true; + } + value = lb_const_value(p->module, ast_value->tav.type, ast_value->tav.value, cc); + } + String mangled_name = {}; { gbString str = gb_string_make_length(permanent_allocator(), p->name.text, p->name.len); diff --git a/src/llvm_backend_utility.cpp b/src/llvm_backend_utility.cpp index 9ddbd1f9c..929239486 100644 --- a/src/llvm_backend_utility.cpp +++ b/src/llvm_backend_utility.cpp @@ -89,7 +89,7 @@ gb_internal LLVMValueRef lb_mem_zero_ptr_internal(lbProcedure *p, LLVMValueRef p bool is_inlinable = false; i64 const_len = 0; - if (LLVMIsConstant(len)) { + if (!p->is_startup && LLVMIsConstant(len)) { const_len = cast(i64)LLVMConstIntGetSExtValue(len); // TODO(bill): Determine when it is better to do the `*.inline` versions if (const_len <= lb_max_zero_init_size()) { @@ -803,7 +803,12 @@ gb_internal lbValue lb_emit_union_cast(lbProcedure *p, lbValue value, Type *type args[5] = lb_typeid(m, dst_type); args[6] = lb_emit_conv(p, value_, t_rawptr); } - lb_emit_runtime_call(p, "type_assertion_check2", args); + + char const *name = "type_assertion_check2_contextless"; + if (p->context_stack.count > 0) { + name = "type_assertion_check2_with_context"; + } + lb_emit_runtime_call(p, name, args); } return lb_emit_load(p, lb_emit_struct_ep(p, v.addr, 0)); @@ -877,7 +882,11 @@ gb_internal lbAddr lb_emit_any_cast_addr(lbProcedure *p, lbValue value, Type *ty args[5] = dst_typeid; args[6] = lb_emit_struct_ev(p, value, 0); } - lb_emit_runtime_call(p, "type_assertion_check2", args); + char const *name = "type_assertion_check2_contextless"; + if (p->context_stack.count > 0) { + name = "type_assertion_check2_with_context"; + } + lb_emit_runtime_call(p, name, args); } return lb_addr(lb_emit_struct_ep(p, v.addr, 0)); diff --git a/src/main.cpp b/src/main.cpp index 9a5df8aea..624869e65 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -324,8 +324,6 @@ enum BuildFlagKind { BuildFlag_NoCRT, BuildFlag_NoRPath, BuildFlag_NoEntryPoint, - BuildFlag_UseLLD, - BuildFlag_UseRADLink, BuildFlag_Linker, BuildFlag_UseSeparateModules, BuildFlag_UseSingleModule, @@ -363,6 +361,8 @@ enum BuildFlagKind { BuildFlag_RelocMode, BuildFlag_DisableRedZone, + BuildFlag_DisableUnwind, + BuildFlag_DisallowDo, BuildFlag_DefaultToNilAllocator, BuildFlag_DefaultToPanicAllocator, @@ -554,8 +554,6 @@ gb_internal bool parse_build_flags(Array args) { add_flag(&build_flags, BuildFlag_NoCRT, str_lit("no-crt"), BuildFlagParam_None, Command__does_build); add_flag(&build_flags, BuildFlag_NoRPath, str_lit("no-rpath"), BuildFlagParam_None, Command__does_build); add_flag(&build_flags, BuildFlag_NoEntryPoint, str_lit("no-entry-point"), BuildFlagParam_None, Command__does_check &~ Command_test); - add_flag(&build_flags, BuildFlag_UseLLD, str_lit("lld"), BuildFlagParam_None, Command__does_build); - add_flag(&build_flags, BuildFlag_UseRADLink, str_lit("radlink"), BuildFlagParam_None, Command__does_build); add_flag(&build_flags, BuildFlag_Linker, str_lit("linker"), BuildFlagParam_String, Command__does_build); add_flag(&build_flags, BuildFlag_UseSeparateModules, str_lit("use-separate-modules"), BuildFlagParam_None, Command__does_build); add_flag(&build_flags, BuildFlag_UseSingleModule, str_lit("use-single-module"), BuildFlagParam_None, Command__does_build); @@ -592,6 +590,8 @@ gb_internal bool parse_build_flags(Array args) { add_flag(&build_flags, BuildFlag_RelocMode, str_lit("reloc-mode"), BuildFlagParam_String, Command__does_build); add_flag(&build_flags, BuildFlag_DisableRedZone, str_lit("disable-red-zone"), BuildFlagParam_None, Command__does_build); + add_flag(&build_flags, BuildFlag_DisableUnwind, str_lit("disable-unwind"), BuildFlagParam_None, Command__does_build); + add_flag(&build_flags, BuildFlag_DisallowDo, str_lit("disallow-do"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_DefaultToNilAllocator, str_lit("default-to-nil-allocator"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_DefaultToPanicAllocator, str_lit("default-to-panic-allocator"),BuildFlagParam_None, Command__does_check); @@ -1252,14 +1252,6 @@ gb_internal bool parse_build_flags(Array args) { case BuildFlag_NoThreadLocal: build_context.no_thread_local = true; break; - case BuildFlag_UseLLD: - gb_printf_err("Warning: Use of -lld has been deprecated in favour of -linker:lld\n"); - build_context.linker_choice = Linker_lld; - break; - case BuildFlag_UseRADLink: - gb_printf_err("Warning: Use of -lld has been deprecated in favour of -linker:radlink\n"); - build_context.linker_choice = Linker_radlink; - break; case BuildFlag_Linker: { GB_ASSERT(value.kind == ExactValue_String); @@ -1424,6 +1416,10 @@ gb_internal bool parse_build_flags(Array args) { case BuildFlag_DisableRedZone: build_context.disable_red_zone = true; break; + case BuildFlag_DisableUnwind: + build_context.disable_unwind = true; + break; + case BuildFlag_DisallowDo: build_context.disallow_do = true; break; @@ -2971,6 +2967,10 @@ gb_internal int print_show_help(String const arg0, String command, String option if (check) { if (print_flag("-target:")) { print_usage_line(2, "Sets the target for the executable to be built in."); + print_usage_line(2, "Examples:"); + print_usage_line(3, "-target:linux_amd64"); + print_usage_line(3, "-target:windows_amd64"); + print_usage_line(3, "-target:\"?\" for a list"); } if (print_flag("-terse-errors")) { @@ -4034,6 +4034,14 @@ int main(int arg_count, char const **arg_ptr) { remove_temp_files(gen); } + if (any_errors()) { + print_all_errors(); + return 1; + } + if (any_warnings()) { + print_all_errors(); + } + end_of_code_gen:; if (build_context.export_dependencies_format != DependenciesExportUnspecified) { diff --git a/src/parser.cpp b/src/parser.cpp index e27e184d0..360537ab7 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1230,7 +1230,7 @@ gb_internal Ast *ast_dynamic_array_type(AstFile *f, Token token, Ast *elem) { } gb_internal Ast *ast_struct_type(AstFile *f, Token token, Slice fields, isize field_count, - Ast *polymorphic_params, bool is_packed, bool is_raw_union, bool is_all_or_none, + Ast *polymorphic_params, bool is_packed, bool is_raw_union, bool is_all_or_none, bool is_simple, Ast *align, Ast *min_field_align, Ast *max_field_align, Token where_token, Array const &where_clauses) { Ast *result = alloc_ast_node(f, Ast_StructType); @@ -1241,6 +1241,7 @@ gb_internal Ast *ast_struct_type(AstFile *f, Token token, Slice fields, i result->StructType.is_packed = is_packed; result->StructType.is_raw_union = is_raw_union; result->StructType.is_all_or_none = is_all_or_none; + result->StructType.is_simple = is_simple; result->StructType.align = align; result->StructType.min_field_align = min_field_align; result->StructType.max_field_align = max_field_align; @@ -2176,38 +2177,50 @@ gb_internal bool ast_on_same_line(Token const &x, Ast *yp) { return x.pos.line == y.pos.line; } -gb_internal Ast *parse_force_inlining_operand(AstFile *f, Token token) { +gb_internal Ast *parse_inlining_or_tailing_operand(AstFile *f, Token token) { Ast *expr = parse_unary_expr(f, false); Ast *e = strip_or_return_expr(expr); if (e == nullptr) { return expr; } if (e->kind != Ast_ProcLit && e->kind != Ast_CallExpr) { - syntax_error(expr, "%.*s must be followed by a procedure literal or call, got %.*s", LIT(token.string), LIT(ast_strings[expr->kind])); + syntax_error(expr, "%.*s must be followed by a procedure literal or call, got %.*s", LIT(token.string), LIT(ast_strings[e->kind])); return ast_bad_expr(f, token, f->curr_token); } ProcInlining pi = ProcInlining_none; + ProcTailing pt = ProcTailing_none; if (token.kind == Token_Ident) { if (token.string == "force_inline") { pi = ProcInlining_inline; } else if (token.string == "force_no_inline") { pi = ProcInlining_no_inline; + } else if (token.string == "must_tail") { + pt = ProcTailing_must_tail; } } if (pi != ProcInlining_none) { if (e->kind == Ast_ProcLit) { - if (expr->ProcLit.inlining != ProcInlining_none && - expr->ProcLit.inlining != pi) { + if (e->ProcLit.inlining != ProcInlining_none && + e->ProcLit.inlining != pi) { syntax_error(expr, "Cannot apply both '#force_inline' and '#force_no_inline' to a procedure literal"); } - expr->ProcLit.inlining = pi; + e->ProcLit.inlining = pi; } else if (e->kind == Ast_CallExpr) { - if (expr->CallExpr.inlining != ProcInlining_none && - expr->CallExpr.inlining != pi) { + if (e->CallExpr.inlining != ProcInlining_none && + e->CallExpr.inlining != pi) { syntax_error(expr, "Cannot apply both '#force_inline' and '#force_no_inline' to a procedure call"); } - expr->CallExpr.inlining = pi; + e->CallExpr.inlining = pi; + } + } + + if (pt != ProcTailing_none) { + if (e->kind == Ast_ProcLit) { + syntax_error(expr, "'#must_call' can only be applied to a procedure call, not the procedure literal"); + e->ProcLit.tailing = pt; + } else if (e->kind == Ast_CallExpr) { + e->CallExpr.tailing = pt; } } @@ -2507,8 +2520,9 @@ gb_internal Ast *parse_operand(AstFile *f, bool lhs) { syntax_error(tag, "#relative types have now been removed in favour of \"core:relative\""); return ast_relative_type(f, tag, type); } else if (name.string == "force_inline" || - name.string == "force_no_inline") { - return parse_force_inlining_operand(f, name); + name.string == "force_no_inline" || + name.string == "must_tail") { + return parse_inlining_or_tailing_operand(f, name); } return ast_basic_directive(f, token, name); } @@ -2775,6 +2789,7 @@ gb_internal Ast *parse_operand(AstFile *f, bool lhs) { bool is_packed = false; bool is_all_or_none = false; bool is_raw_union = false; + bool is_simple = false; Ast *align = nullptr; Ast *min_field_align = nullptr; Ast *max_field_align = nullptr; @@ -2803,7 +2818,7 @@ gb_internal Ast *parse_operand(AstFile *f, bool lhs) { } is_packed = true; } else if (tag.string == "all_or_none") { - if (is_packed) { + if (is_all_or_none) { syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string)); } is_all_or_none = true; @@ -2856,11 +2871,16 @@ gb_internal Ast *parse_operand(AstFile *f, bool lhs) { error_line("\tSuggestion: #max_field_align(%s)", s); gb_string_free(s); } - }else if (tag.string == "raw_union") { + } else if (tag.string == "raw_union") { if (is_raw_union) { syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string)); } is_raw_union = true; + } else if (tag.string == "simple") { + if (is_simple) { + syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string)); + } + is_simple = true; } else { syntax_error(tag, "Invalid struct tag '#%.*s'", LIT(tag.string)); } @@ -2906,7 +2926,7 @@ gb_internal Ast *parse_operand(AstFile *f, bool lhs) { parser_check_polymorphic_record_parameters(f, polymorphic_params); return ast_struct_type(f, token, decls, name_count, - polymorphic_params, is_packed, is_raw_union, is_all_or_none, + polymorphic_params, is_packed, is_raw_union, is_all_or_none, is_simple, align, min_field_align, max_field_align, where_token, where_clauses); } break; @@ -4008,6 +4028,10 @@ gb_internal ProcCallingConvention string_to_calling_convention(String const &s) if (s == "win64") return ProcCC_Win64; if (s == "sysv") return ProcCC_SysV; + if (s == "preserve/none") return ProcCC_PreserveNone; + if (s == "preserve/most") return ProcCC_PreserveMost; + if (s == "preserve/all") return ProcCC_PreserveAll; + if (s == "system") { if (build_context.metrics.os == TargetOs_windows) { return ProcCC_StdCall; @@ -5054,6 +5078,10 @@ gb_internal Ast *parse_import_decl(AstFile *f, ImportDeclKind kind) { syntax_error(import_name, "'using import' is not allowed, please use the import name explicitly"); } + if (file_path.string == "\".\"") { + syntax_error(import_name, "Cannot cyclicly import packages"); + } + expect_semicolon(f); return s; } @@ -5399,8 +5427,9 @@ gb_internal Ast *parse_stmt(AstFile *f) { expect_semicolon(f); return stmt; } else if (name.string == "force_inline" || - name.string == "force_no_inline") { - Ast *expr = parse_force_inlining_operand(f, name); + name.string == "force_no_inline" || + name.string == "must_tail") { + Ast *expr = parse_inlining_or_tailing_operand(f, name); Ast *stmt = ast_expr_stmt(f, expr); expect_semicolon(f); return stmt; @@ -5818,6 +5847,11 @@ gb_internal AstPackage *try_add_import_path(Parser *p, String path, String const return nullptr; } + if (string_ends_with(path, str_lit(".odin"))) { + error(pos, "'import' declarations cannot import directories with a .odin extension/suffix"); + return nullptr; + } + isize files_with_ext = 0; isize files_to_reserve = 1; // always reserve 1 for (FileInfo fi : list) { @@ -5996,6 +6030,12 @@ gb_internal bool determine_path_from_string(BlockingMutex *file_mutex, Ast *node has_windows_drive = true; } } + + for (isize i = 0; i < original_string.len; i++) { + if (original_string.text[i] == '\\') { + original_string.text[i] = '/'; + } + } } #endif @@ -6205,9 +6245,28 @@ gb_internal String build_tag_get_token(String s, String *out) { return s; } +// returns true on failure +gb_internal bool build_require_space_after(String s, String prefix) { + GB_ASSERT(string_starts_with(s, prefix)); + + if (s.len == prefix.len) { + return false; + } + String stripped = string_trim_whitespace(substring(s, prefix.len, s.len)); + + if (s[prefix.len] != ' ' && stripped.len != 0) { + return true; + } + return false; +} + gb_internal bool parse_build_tag(Token token_for_pos, String s) { String const prefix = str_lit("build"); GB_ASSERT(string_starts_with(s, prefix)); + if (build_require_space_after(s, prefix)) { + syntax_error(token_for_pos, "Expected a space after #+%.*s", LIT(prefix)); + return true; + } s = string_trim_whitespace(substring(s, prefix.len, s.len)); if (s.len == 0) { @@ -6331,19 +6390,21 @@ gb_internal String vet_tag_get_token(String s, String *out, bool allow_colon) { } -gb_internal u64 parse_vet_tag(Token token_for_pos, String s) { +gb_internal u64 parse_vet_tag(Token token_for_pos, String s, u64 base_vet_flags) { String const prefix = str_lit("vet"); GB_ASSERT(string_starts_with(s, prefix)); + if (build_require_space_after(s, prefix)) { + syntax_error(token_for_pos, "Expected a space after #+%.*s", LIT(prefix)); + return true; + } s = string_trim_whitespace(substring(s, prefix.len, s.len)); + u64 vet_flags = base_vet_flags; + if (s.len == 0) { - return VetFlag_All; + vet_flags |= VetFlag_All; } - - u64 vet_flags = 0; - u64 vet_not_flags = 0; - while (s.len > 0) { String p = string_trim_whitespace(vet_tag_get_token(s, &s, /*allow_colon*/false)); if (p.len == 0) { @@ -6356,16 +6417,16 @@ gb_internal u64 parse_vet_tag(Token token_for_pos, String s) { p = substring(p, 1, p.len); if (p.len == 0) { syntax_error(token_for_pos, "Expected a vet flag name after '!'"); - return build_context.vet_flags; + return vet_flags; } } u64 flag = get_vet_flag_from_name(p); if (flag != VetFlag_NONE) { if (is_notted) { - vet_not_flags |= flag; + vet_flags = vet_flags &~ flag; } else { - vet_flags |= flag; + vet_flags |= flag; } } else { ERROR_BLOCK(); @@ -6383,26 +6444,20 @@ gb_internal u64 parse_vet_tag(Token token_for_pos, String s) { error_line("\tcast\n"); error_line("\ttabs\n"); error_line("\texplicit-allocators\n"); - return build_context.vet_flags; + return vet_flags; } } - if (vet_flags == 0 && vet_not_flags == 0) { - return build_context.vet_flags; - } - if (vet_flags == 0 && vet_not_flags != 0) { - return build_context.vet_flags &~ vet_not_flags; - } - if (vet_flags != 0 && vet_not_flags == 0) { - return vet_flags; - } - GB_ASSERT(vet_flags != 0 && vet_not_flags != 0); - return vet_flags &~ vet_not_flags; + return vet_flags; } gb_internal u64 parse_feature_tag(Token token_for_pos, String s) { String const prefix = str_lit("feature"); GB_ASSERT(string_starts_with(s, prefix)); + if (build_require_space_after(s, prefix)) { + syntax_error(token_for_pos, "Expected a space after #+%.*s", LIT(prefix)); + return true; + } s = string_trim_whitespace(substring(s, prefix.len, s.len)); if (s.len == 0) { @@ -6578,7 +6633,7 @@ gb_internal bool parse_file_tag(const String &lc, const Token &tok, AstFile *f) return false; } } else if (string_starts_with(lc, str_lit("vet"))) { - f->vet_flags = parse_vet_tag(tok, lc); + f->vet_flags = parse_vet_tag(tok, lc, ast_file_vet_flags(f)); f->vet_flags_set = true; } else if (string_starts_with(lc, str_lit("test"))) { if ((build_context.command_kind & Command_test) == 0) { diff --git a/src/parser.hpp b/src/parser.hpp index 71b61d95f..39f56ffae 100644 --- a/src/parser.hpp +++ b/src/parser.hpp @@ -263,12 +263,17 @@ struct ForeignFileWorkerData { -enum ProcInlining { - ProcInlining_none = 0, - ProcInlining_inline = 1, +enum ProcInlining : u8 { + ProcInlining_none = 0, + ProcInlining_inline = 1, ProcInlining_no_inline = 2, }; +enum ProcTailing : u8 { + ProcTailing_none = 0, + ProcTailing_must_tail = 1, +}; + enum ProcTag { ProcTag_bounds_check = 1<<0, ProcTag_no_bounds_check = 1<<1, @@ -296,6 +301,9 @@ enum ProcCallingConvention : i32 { ProcCC_Win64 = 9, ProcCC_SysV = 10, + ProcCC_PreserveNone = 11, + ProcCC_PreserveMost = 12, + ProcCC_PreserveAll = 13, ProcCC_MAX, @@ -315,6 +323,9 @@ gb_global char const *proc_calling_convention_strings[ProcCC_MAX] = { "inlineasm", "win64", "sysv", + "preserve/none", + "preserve/most", + "preserve/all", }; gb_internal ProcCallingConvention default_calling_convention(void) { @@ -441,6 +452,7 @@ struct AstSplitArgs { Ast *body; \ u64 tags; \ ProcInlining inlining; \ + ProcTailing tailing; \ Token where_token; \ Slice where_clauses; \ DeclInfo *decl; \ @@ -486,6 +498,7 @@ AST_KIND(_ExprBegin, "", bool) \ Token close; \ Token ellipsis; \ ProcInlining inlining; \ + ProcTailing tailing; \ bool optional_ok_one; \ bool was_selector; \ AstSplitArgs *split_args; \ @@ -767,6 +780,7 @@ AST_KIND(_TypeBegin, "", bool) \ bool is_raw_union; \ bool is_no_copy; \ bool is_all_or_none; \ + bool is_simple; \ }) \ AST_KIND(UnionType, "union type", struct { \ Scope *scope; \ diff --git a/src/string.cpp b/src/string.cpp index 9c08114a7..c26457acf 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -635,26 +635,107 @@ gb_internal String normalize_path(gbAllocator a, String const &path, String cons #elif defined(GB_SYSTEM_UNIX) || defined(GB_SYSTEM_OSX) #include + gb_internal void utf16_encode_surrogate_pair(Rune r, u16 *r1, u16 *r2) { + static Rune const _surr_self = 0x10000; + static Rune const _surr1 = 0xd800; + static Rune const _surr2 = 0xdc00; + Rune r_ = r - _surr_self; + *r1 = _surr1 + ((r_ >> 10) & 0x3ff); + *r2 = _surr2 + (r_ & 0x3ff); + } + + gb_internal isize utf16_decode(u16 const *s, isize n, Rune *r) { + static Rune const _surr1 = 0xd800; + static Rune const _surr2 = 0xdc00; + static Rune const _surr3 = 0xe000; + static Rune const _surr_self = 0x10000; + if (n < 1) { + *r = GB_RUNE_INVALID; + return 0; + } + u16 c = s[0]; + if (c < 0xd800 || c > 0xdfff) { + *r = cast(Rune)c; + return 1; + } + if (c >= 0xdc00) { + *r = GB_RUNE_INVALID; + return 1; + } + if (n < 2) { + *r = GB_RUNE_INVALID; + return 1; + } + u16 c2 = s[1]; + if (c2 < 0xdc00 || c2 > 0xdfff) { + *r = GB_RUNE_INVALID; + return 1; + } + *r = (((c-_surr1)<<10) | (c2 - _surr2)) + _surr_self; + return 2; + } + gb_internal int convert_multibyte_to_widechar(char const *multibyte_input, usize input_length, wchar_t *output, usize output_size) { - String string = copy_string(heap_allocator(), make_string(cast(u8 const*)multibyte_input, input_length)); /* Guarantee NULL terminator */ - u8* input = string.text; + u16 *out = cast(u16 *)output; + String s = make_string(cast(u8 const *)multibyte_input, input_length); + isize i = 0; + isize output_len = 0; + while (i < s.len) { + Rune r = 0; + isize width = utf8_decode(s.text + i, s.len - i, &r); + if (r == GB_RUNE_INVALID) { + return -1; + } + i += width; + if (r < 0x10000) { + if (out) { + if (cast(usize)output_len+1 > output_size) { + return -1; + } + out[output_len] = cast(u16)r; + } + output_len += 1; + } else { + if (out) { + if (cast(usize)output_len+2 > output_size) { + return -1; + } + u16 r1, r2; + utf16_encode_surrogate_pair(r, &r1, &r2); + out[output_len+0] = r1; + out[output_len+1] = r2; + } + output_len += 2; + } + } - mbstate_t ps = { 0 }; - size_t result = mbsrtowcs(output, cast(const char**)&input, output_size, &ps); - - gb_free(heap_allocator(), string.text); - return (result == (size_t)-1) ? -1 : (int)result; + return cast(int)output_len; } gb_internal int convert_widechar_to_multibyte(wchar_t const *widechar_input, usize input_length, char* output, usize output_size) { - String string = copy_string(heap_allocator(), make_string(cast(u8 const*)widechar_input, input_length)); /* Guarantee NULL terminator */ - u8* input = string.text; + u16 const *in = cast(u16 const *)widechar_input; + isize i = 0; + isize output_len = 0; + while (i < input_length) { + Rune r; + isize width = utf16_decode(in + i, input_length - i, &r); + if (r == GB_RUNE_INVALID) { + return -1; + } + i += width; - mbstate_t ps = { 0 }; - size_t result = wcsrtombs(output, cast(const wchar_t**)&input, output_size, &ps); + u8 buf[4]; + isize char_len = gb_utf8_encode_rune(buf, r); - gb_free(heap_allocator(), string.text); - return (result == (size_t)-1) ? -1 : (int)result; + if(output) { + if (cast(usize)output_len+cast(usize)char_len > output_size) { + return -1; + } + gb_memmove(output + output_len, buf, char_len); + } + output_len += char_len; + } + return cast(int)output_len; } #else #error Implement system diff --git a/src/types.cpp b/src/types.cpp index 18e3b56ac..a7f2bfda2 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -163,6 +163,7 @@ struct TypeStruct { bool is_packed : 1; bool is_raw_union : 1; bool is_all_or_none : 1; + bool is_simple : 1; bool is_poly_specialized : 1; std::atomic are_offsets_being_processed; @@ -2701,12 +2702,16 @@ gb_internal bool is_type_simple_compare(Type *t) { case Type_SoaPointer: case Type_Proc: case Type_BitSet: + case Type_BitField: return true; case Type_Matrix: return is_type_simple_compare(t->Matrix.elem); case Type_Struct: + if (t->Struct.is_simple) { + return true; + } for_array(i, t->Struct.fields) { Entity *f = t->Struct.fields[i]; if (!is_type_simple_compare(f->type)) { @@ -2728,6 +2733,16 @@ gb_internal bool is_type_simple_compare(Type *t) { case Type_SimdVector: return is_type_simple_compare(t->SimdVector.elem); + case Type_Tuple: + if (t->Tuple.variables.count == 1) { + return is_type_simple_compare(t->Tuple.variables[0]->type); + } + break; + + case Type_Slice: + case Type_DynamicArray: + case Type_Map: + return false; } return false; @@ -2757,12 +2772,16 @@ gb_internal bool is_type_nearly_simple_compare(Type *t) { case Type_SoaPointer: case Type_Proc: case Type_BitSet: + case Type_BitField: return true; case Type_Matrix: return is_type_nearly_simple_compare(t->Matrix.elem); case Type_Struct: + if (t->Struct.is_simple) { + return true; + } for_array(i, t->Struct.fields) { Entity *f = t->Struct.fields[i]; if (!is_type_nearly_simple_compare(f->type)) { @@ -2784,6 +2803,17 @@ gb_internal bool is_type_nearly_simple_compare(Type *t) { case Type_SimdVector: return is_type_nearly_simple_compare(t->SimdVector.elem); + case Type_Tuple: + if (t->Tuple.variables.count == 1) { + return is_type_nearly_simple_compare(t->Tuple.variables[0]->type); + } + break; + + case Type_Slice: + case Type_DynamicArray: + case Type_Map: + return false; + } return false; @@ -5099,9 +5129,11 @@ gb_internal gbString write_type_to_string(gbString str, Type *type, bool shortha str = gb_string_appendc(str, ")"); } - if (type->Struct.is_packed) str = gb_string_appendc(str, " #packed"); - if (type->Struct.is_raw_union) str = gb_string_appendc(str, " #raw_union"); + if (type->Struct.is_packed) str = gb_string_appendc(str, " #packed"); + if (type->Struct.is_raw_union) str = gb_string_appendc(str, " #raw_union"); if (type->Struct.custom_align != 0) str = gb_string_append_fmt(str, " #align %d", cast(int)type->Struct.custom_align); + if (type->Struct.is_all_or_none) str = gb_string_appendc(str, " #all_or_none"); + if (type->Struct.is_simple) str = gb_string_appendc(str, " #simple"); str = gb_string_appendc(str, " {"); @@ -5210,40 +5242,12 @@ gb_internal gbString write_type_to_string(gbString str, Type *type, bool shortha case Type_Proc: str = gb_string_appendc(str, "proc"); - switch (type->Proc.calling_convention) { - case ProcCC_Odin: - if (default_calling_convention() != ProcCC_Odin) { - str = gb_string_appendc(str, " \"odin\" "); - } - break; - case ProcCC_Contextless: - if (default_calling_convention() != ProcCC_Contextless) { - str = gb_string_appendc(str, " \"contextless\" "); - } - break; - case ProcCC_CDecl: - str = gb_string_appendc(str, " \"c\" "); - break; - case ProcCC_StdCall: - str = gb_string_appendc(str, " \"std\" "); - break; - case ProcCC_FastCall: - str = gb_string_appendc(str, " \"fastcall\" "); - break; - break; - case ProcCC_None: - str = gb_string_appendc(str, " \"none\" "); - break; - case ProcCC_Naked: - str = gb_string_appendc(str, " \"naked\" "); - break; - // case ProcCC_VectorCall: - // str = gb_string_appendc(str, " \"vectorcall\" "); - // break; - // case ProcCC_ClrCall: - // str = gb_string_appendc(str, " \"clrcall\" "); - // break; + if (type->Proc.calling_convention != default_calling_convention()) { + str = gb_string_appendc(str, " \""); + str = gb_string_appendc(str, proc_calling_convention_strings[type->Proc.calling_convention]); + str = gb_string_appendc(str, "\" "); } + str = gb_string_appendc(str, "("); if (type->Proc.params) { str = write_type_to_string(str, type->Proc.params, shorthand, allow_polymorphic); diff --git a/tests/benchmark/crypto/benchmark_ecc.odin b/tests/benchmark/crypto/benchmark_ecc.odin index 16ca798dc..52a1a4ac1 100644 --- a/tests/benchmark/crypto/benchmark_ecc.odin +++ b/tests/benchmark/crypto/benchmark_ecc.odin @@ -2,13 +2,14 @@ package benchmark_core_crypto import "base:runtime" import "core:encoding/hex" +import "core:log" import "core:testing" import "core:text/table" import "core:time" +import "core:crypto" +import "core:crypto/ecdh" import "core:crypto/ed25519" -import "core:crypto/x25519" -import "core:crypto/x448" @(private = "file") ECDH_ITERS :: 10000 @@ -25,6 +26,10 @@ benchmark_crypto_ecc :: proc(t: ^testing.T) { @(private = "file") bench_ecdh :: proc() { + if !crypto.HAS_RAND_BYTES { + log.warnf("ECDH benchmarks skipped, no system entropy source") + } + tbl: table.Table table.init(&tbl) defer table.destroy(&tbl) @@ -42,63 +47,37 @@ bench_ecdh :: proc() { ) } - scalar_bp, scalar := bench_x25519() - append_tbl(&tbl, "X25519", scalar_bp, scalar) + for algo in ecdh.Curve { + if algo == .Invalid { + continue + } + algo_name := ecdh.CURVE_NAMES[algo] - scalar_bp, scalar = bench_x448() - append_tbl(&tbl, "X448", scalar_bp, scalar) + priv_key_alice: ecdh.Private_Key + start := time.tick_now() + for _ in 0 ..< ECDH_ITERS { + _ = ecdh.private_key_generate(&priv_key_alice, algo) + } + bp := time.tick_since(start) / ECDH_ITERS + + pub_key_alice: ecdh.Public_Key + ecdh.public_key_set_priv(&pub_key_alice, &priv_key_alice) + + priv_key_bob: ecdh.Private_Key + _ = ecdh.private_key_generate(&priv_key_bob, algo) + ss := make([]byte, ecdh.SHARED_SECRET_SIZES[algo], context.temp_allocator) + start = time.tick_now() + for _ in 0 ..< ECDH_ITERS { + _ = ecdh.ecdh(&priv_key_bob, &pub_key_alice, ss) + } + sc := time.tick_since(start) / ECDH_ITERS + + append_tbl(&tbl, algo_name, bp, sc) + } log_table(&tbl) } -@(private = "file") -bench_x25519 :: proc() -> (bp, sc: time.Duration) { - point_str := "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" - scalar_str := "cafebabecafebabecafebabecafebabecafebabecafebabecafebabecafebabe" - - point, _ := hex.decode(transmute([]byte)(point_str), context.temp_allocator) - scalar, _ := hex.decode(transmute([]byte)(scalar_str), context.temp_allocator) - out: [x25519.POINT_SIZE]byte = --- - - start := time.tick_now() - for _ in 0 ..< ECDH_ITERS { - x25519.scalarmult_basepoint(out[:], scalar[:]) - } - bp = time.tick_since(start) / ECDH_ITERS - - start = time.tick_now() - for _ in 0 ..< ECDH_ITERS { - x25519.scalarmult(out[:], scalar[:], point[:]) - } - sc = time.tick_since(start) / ECDH_ITERS - - return -} - -@(private = "file") -bench_x448 :: proc() -> (bp, sc: time.Duration) { - point_str := "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" - scalar_str := "cafebabecafebabecafebabecafebabecafebabecafebabecafebabecafebabecafebabecafebabecafebabecafebabecafebabecafebabe" - - point, _ := hex.decode(transmute([]byte)(point_str), context.temp_allocator) - scalar, _ := hex.decode(transmute([]byte)(scalar_str), context.temp_allocator) - out: [x448.POINT_SIZE]byte = --- - - start := time.tick_now() - for _ in 0 ..< ECDH_ITERS { - x448.scalarmult_basepoint(out[:], scalar[:]) - } - bp = time.tick_since(start) / ECDH_ITERS - - start = time.tick_now() - for _ in 0 ..< ECDH_ITERS { - x448.scalarmult(out[:], scalar[:], point[:]) - } - sc = time.tick_since(start) / ECDH_ITERS - - return -} - @(private = "file") bench_dsa :: proc() { tbl: table.Table diff --git a/tests/core/container/test_core_rbtree.odin b/tests/core/container/test_core_rbtree.odin index d220b7ed6..78d710b7f 100644 --- a/tests/core/container/test_core_rbtree.odin +++ b/tests/core/container/test_core_rbtree.odin @@ -4,22 +4,15 @@ import rb "core:container/rbtree" import "core:math/rand" import "core:testing" import "base:intrinsics" -import "core:mem" import "core:slice" import "core:log" test_rbtree_integer :: proc(t: ^testing.T, $Key: typeid, $Value: typeid) { - track: mem.Tracking_Allocator - mem.tracking_allocator_init(&track, context.allocator) - track.bad_free_callback = mem.tracking_allocator_bad_free_callback_add_to_array - defer mem.tracking_allocator_destroy(&track) - context.allocator = mem.tracking_allocator(&track) - log.infof("Testing Red-Black Tree($Key=%v,$Value=%v) using random seed %v.", type_info_of(Key), type_info_of(Value), t.seed) tree: rb.Tree(Key, Value) rb.init(&tree) - testing.expect(t, rb.len(&tree) == 0, "empty: len should be 0") + testing.expect(t, rb.len(tree) == 0, "empty: len should be 0") testing.expect(t, rb.first(&tree) == nil, "empty: first should be nil") testing.expect(t, rb.last(&tree) == nil, "empty: last should be nil") iter := rb.iterator(&tree, .Forward) @@ -48,7 +41,7 @@ test_rbtree_integer :: proc(t: ^testing.T, $Key: typeid, $Value: typeid) { } entry_count := len(inserted_map) - testing.expect(t, rb.len(&tree) == entry_count, "insert: len after") + testing.expect(t, rb.len(tree) == entry_count, "insert: len after") validate_rbtree(t, &tree) first := rb.first(&tree) @@ -58,8 +51,8 @@ test_rbtree_integer :: proc(t: ^testing.T, $Key: typeid, $Value: typeid) { // Ensure that all entries can be found. for k, v in inserted_map { - testing.expect(t, v == rb.find(&tree, k), "Find(): Node") - testing.expect(t, k == v.key, "Find(): Node key") + testing.expect(t, v == rb.find(tree, k), "Find(): Node") + testing.expect(t, k == v.key, "Find(): Node key") } // Test the forward/backward iterators. @@ -97,17 +90,17 @@ test_rbtree_integer :: proc(t: ^testing.T, $Key: typeid, $Value: typeid) { (^int)(user_data)^ -= 1 } for k, i in inserted_keys { - node := rb.find(&tree, k) + node := rb.find(tree, k) testing.expect(t, node != nil, "remove: find (pre)") ok := rb.remove(&tree, k) testing.expect(t, ok, "remove: succeeds") - testing.expect(t, entry_count - (i + 1) == rb.len(&tree), "remove: len (post)") + testing.expect(t, entry_count - (i + 1) == rb.len(tree), "remove: len (post)") validate_rbtree(t, &tree) - testing.expect(t, nil == rb.find(&tree, k), "remove: find (post") + testing.expect(t, nil == rb.find(tree, k), "remove: find (post") } - testing.expect(t, rb.len(&tree) == 0, "remove: len should be 0") + testing.expect(t, rb.len(tree) == 0, "remove: len should be 0") testing.expectf(t, callback_count == 0, "remove: on_remove should've been called %v times, it was %v", entry_count, callback_count) testing.expect(t, rb.first(&tree) == nil, "remove: first should be nil") testing.expect(t, rb.last(&tree) == nil, "remove: last should be nil") @@ -129,28 +122,25 @@ test_rbtree_integer :: proc(t: ^testing.T, $Key: typeid, $Value: typeid) { ok = rb.iterator_remove(&iter) testing.expect(t, !ok, "iterator/remove: redundant removes should fail") - testing.expect(t, rb.find(&tree, k) == nil, "iterator/remove: node should be gone") + testing.expect(t, rb.find(tree, k) == nil, "iterator/remove: node should be gone") testing.expect(t, rb.iterator_get(&iter) == nil, "iterator/remove: get should return nil") // Ensure that iterator_next still works. node, ok = rb.iterator_next(&iter) - testing.expect(t, ok == (rb.len(&tree) > 0), "iterator/remove: next should return false") + testing.expect(t, ok == (rb.len(tree) > 0), "iterator/remove: next should return false") testing.expect(t, node == rb.first(&tree), "iterator/remove: next should return first") validate_rbtree(t, &tree) } - testing.expect(t, rb.len(&tree) == entry_count - 1, "iterator/remove: len should drop by 1") + testing.expect(t, rb.len(tree) == entry_count - 1, "iterator/remove: len should drop by 1") rb.destroy(&tree) - testing.expect(t, rb.len(&tree) == 0, "destroy: len should be 0") + testing.expect(t, rb.len(tree) == 0, "destroy: len should be 0") testing.expectf(t, callback_count == 0, "remove: on_remove should've been called %v times, it was %v", entry_count, callback_count) // print_tree_node(tree._root) delete(inserted_map) delete(inserted_keys) - testing.expectf(t, len(track.allocation_map) == 0, "Expected 0 leaks, have %v", len(track.allocation_map)) - testing.expectf(t, len(track.bad_free_array) == 0, "Expected 0 bad frees, have %v", len(track.bad_free_array)) - return } @(test) diff --git a/tests/core/crypto/test_core_crypto_ecdh.odin b/tests/core/crypto/test_core_crypto_ecdh.odin new file mode 100644 index 000000000..87c9e8a4d --- /dev/null +++ b/tests/core/crypto/test_core_crypto_ecdh.odin @@ -0,0 +1,154 @@ +package test_core_crypto + +import "core:encoding/hex" +import "core:testing" + +import "core:crypto/ecdh" + +@(test) +test_ecdh :: proc(t: ^testing.T) { + test_vectors := []struct { + curve: ecdh.Curve, + scalar: string, + point: string, + product: string, + } { + // X25519 Test vectors from RFC 7748 + { + .X25519, + "a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4", + "e6db6867583030db3594c1a424b15f7c726624ec26b3353b10a903a6d0ab1c4c", + "c3da55379de9c6908e94ea4df28d084f32eccf03491c71f754b4075577a28552", + }, + { + .X25519, + "4b66e9d4d1b4673c5ad22691957d6af5c11b6421e0ea01d42ca4169e7918ba0d", + "e5210f12786811d3f4b7959d0538ae2c31dbe7106fc03c3efc4cd549c715a493", + "95cbde9476e8907d7aade45cb4b873f88b595a68799fa152e6f8f7647aac7957", + }, + // X448 Test vectors from RFC 7748 + { + .X448, + "3d262fddf9ec8e88495266fea19a34d28882acef045104d0d1aae121700a779c984c24f8cdd78fbff44943eba368f54b29259a4f1c600ad3", + "06fce640fa3487bfda5f6cf2d5263f8aad88334cbd07437f020f08f9814dc031ddbdc38c19c6da2583fa5429db94ada18aa7a7fb4ef8a086", + "ce3e4ff95a60dc6697da1db1d85e6afbdf79b50a2412d7546d5f239fe14fbaadeb445fc66a01b0779d98223961111e21766282f73dd96b6f", + }, + { + .X448, + "203d494428b8399352665ddca42f9de8fef600908e0d461cb021f8c538345dd77c3e4806e25f46d3315c44e0a5b4371282dd2c8d5be3095f", + "0fbcc2f993cd56d3305b0b7d9e55d4c1a8fb5dbb52f8e9a1e9b6201b165d015894e56c4d3570bee52fe205e28a78b91cdfbde71ce8d157db", + "884a02576239ff7a2f2f63b2db6a9ff37047ac13568e1e30fe63c4a7ad1b3ee3a5700df34321d62077e63633c575c1c954514e99da7c179d", + }, + // secp256r1 Test vectors (subset) from NIST CAVP + { + .SECP256R1, + "7d7dc5f71eb29ddaf80d6214632eeae03d9058af1fb6d22ed80badb62bc1a534", + "04700c48f77f56584c5cc632ca65640db91b6bacce3a4df6b42ce7cc838833d287db71e509e3fd9b060ddb20ba5c51dcc5948d46fbf640dfe0441782cab85fa4ac", + "46fc62106420ff012e54a434fbdd2d25ccc5852060561e68040dd7778997bd7b", + }, + { + .SECP256R1, + "38f65d6dce47676044d58ce5139582d568f64bb16098d179dbab07741dd5caf5", + "04809f04289c64348c01515eb03d5ce7ac1a8cb9498f5caa50197e58d43a86a7aeb29d84e811197f25eba8f5194092cb6ff440e26d4421011372461f579271cda3", + "057d636096cb80b67a8c038c890e887d1adfa4195e9b3ce241c8a778c59cda67", + }, + } + + for v, _ in test_vectors { + raw_scalar, _ := hex.decode(transmute([]byte)(v.scalar), context.temp_allocator) + raw_point, _ := hex.decode(transmute([]byte)(v.point), context.temp_allocator) + + pub_key: ecdh.Public_Key + priv_key: ecdh.Private_Key + + ok := ecdh.private_key_set_bytes(&priv_key, v.curve, raw_scalar) + testing.expectf(t, ok, "failed to deserialize private key: %v %x", v.curve, raw_scalar) + + ok = ecdh.public_key_set_bytes(&pub_key, v.curve, raw_point) + testing.expectf(t, ok, "failed to deserialize public key: %v %x", v.curve, raw_scalar) + + shared_secret := make([]byte, ecdh.shared_secret_size(&pub_key), context.temp_allocator) + ok = ecdh.ecdh(&priv_key, &pub_key, shared_secret) + testing.expectf(t, ok, "ecdh failed: %v %v %v", v.curve, &priv_key, &pub_key) + + ss_str := string(hex.encode(shared_secret, context.temp_allocator)) + testing.expectf( + t, + ss_str == v.product, + "Expected %s for %v %s * %s, but got %s instead", + v.product, + v.curve, + v.scalar, + v.point, + ss_str, + ) + } +} + +@(test) +test_ecdh_scalar_basemult :: proc(t: ^testing.T) { + test_vectors := []struct { + curve: ecdh.Curve, + scalar : string, + point: string, + } { + // X25519 from RFC 7748 6.1 + { + .X25519, + "77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a", + "8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a", + }, + { + .X25519, + "5dab087e624a8a4b79e17f8b83800ee66f3bb1292618b6fd1c2f8b27ff88e0eb", + "de9edb7d7b7dc1b4d35b61c2ece435373f8343c85b78674dadfc7e146f882b4f", + }, + // X448 from RFC 7748 6.2 + { + .X448, + "9a8f4925d1519f5775cf46b04b5800d4ee9ee8bae8bc5565d498c28dd9c9baf574a9419744897391006382a6f127ab1d9ac2d8c0a598726b", + "9b08f7cc31b7e3e67d22d5aea121074a273bd2b83de09c63faa73d2c22c5d9bbc836647241d953d40c5b12da88120d53177f80e532c41fa0", + }, + { + .X448, + "1c306a7ac2a0e2e0990b294470cba339e6453772b075811d8fad0d1d6927c120bb5ee8972b0d3e21374c9c921b09d1b0366f10b65173992d", + "3eb7a829b0cd20f5bcfc0b599b6feccf6da4627107bdb0d4f345b43027d8b972fc3e34fb4232a13ca706dcb57aec3dae07bdc1c67bf33609", + }, + // secp256r1 Test vectors (subset) from NIST CAVP + { + .SECP256R1, + "7d7dc5f71eb29ddaf80d6214632eeae03d9058af1fb6d22ed80badb62bc1a534", + "04ead218590119e8876b29146ff89ca61770c4edbbf97d38ce385ed281d8a6b23028af61281fd35e2fa7002523acc85a429cb06ee6648325389f59edfce1405141", + }, + { + .SECP256R1, + "38f65d6dce47676044d58ce5139582d568f64bb16098d179dbab07741dd5caf5", + "04119f2f047902782ab0c9e27a54aff5eb9b964829ca99c06b02ddba95b0a3f6d08f52b726664cac366fc98ac7a012b2682cbd962e5acb544671d41b9445704d1d", + }, + } + + for v, _ in test_vectors { + raw_scalar, _ := hex.decode(transmute([]byte)(v.scalar), context.temp_allocator) + + priv_key: ecdh.Private_Key + pub_key: ecdh.Public_Key + + ok := ecdh.private_key_set_bytes(&priv_key, v.curve, raw_scalar) + testing.expectf(t, ok, "failed to deserialize private key: %v %x", v.curve, raw_scalar) + + ecdh.public_key_set_priv(&pub_key, &priv_key) + b := make([]byte, ecdh.key_size(&pub_key), context.temp_allocator) + ecdh.public_key_bytes(&pub_key, b) + + pub_str := string(hex.encode(b, context.temp_allocator)) + testing.expectf( + t, + pub_str == v.point, + "Expected %s for %v %s * G, but got %s instead", + v.point, + v.curve, + v.scalar, + pub_str, + ) + } +} \ No newline at end of file diff --git a/tests/core/crypto/test_core_crypto_edwards.odin b/tests/core/crypto/test_core_crypto_edwards.odin index 61933c00f..2da98000c 100644 --- a/tests/core/crypto/test_core_crypto_edwards.odin +++ b/tests/core/crypto/test_core_crypto_edwards.odin @@ -6,11 +6,9 @@ import "core:testing" import field "core:crypto/_fiat/field_curve25519" import "core:crypto/ed25519" import "core:crypto/ristretto255" -import "core:crypto/x25519" -import "core:crypto/x448" @(test) -test_sqrt_ratio_m1 :: proc(t: ^testing.T) { +test_edwards25519_sqrt_ratio_m1 :: proc(t: ^testing.T) { test_vectors := []struct { u: string, v: string, @@ -625,136 +623,14 @@ test_ed25519 :: proc(t: ^testing.T) { } } -@(test) -test_x25519 :: proc(t: ^testing.T) { - // Local copy of this so that the base point doesn't need to be exported. - _BASE_POINT: [32]byte = { - 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - } - - test_vectors := []struct { - scalar: string, - point: string, - product: string, - } { - // Test vectors from RFC 7748 - { - "a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4", - "e6db6867583030db3594c1a424b15f7c726624ec26b3353b10a903a6d0ab1c4c", - "c3da55379de9c6908e94ea4df28d084f32eccf03491c71f754b4075577a28552", - }, - { - "4b66e9d4d1b4673c5ad22691957d6af5c11b6421e0ea01d42ca4169e7918ba0d", - "e5210f12786811d3f4b7959d0538ae2c31dbe7106fc03c3efc4cd549c715a493", - "95cbde9476e8907d7aade45cb4b873f88b595a68799fa152e6f8f7647aac7957", - }, - } - for v, _ in test_vectors { - scalar, _ := hex.decode(transmute([]byte)(v.scalar), context.temp_allocator) - point, _ := hex.decode(transmute([]byte)(v.point), context.temp_allocator) - - derived_point: [x25519.POINT_SIZE]byte - x25519.scalarmult(derived_point[:], scalar[:], point[:]) - derived_point_str := string(hex.encode(derived_point[:], context.temp_allocator)) - - testing.expectf( - t, - derived_point_str == v.product, - "Expected %s for %s * %s, but got %s instead", - v.product, - v.scalar, - v.point, - derived_point_str, - ) - - // Abuse the test vectors to sanity-check the scalar-basepoint multiply. - p1, p2: [x25519.POINT_SIZE]byte - x25519.scalarmult_basepoint(p1[:], scalar[:]) - x25519.scalarmult(p2[:], scalar[:], _BASE_POINT[:]) - p1_str := string(hex.encode(p1[:], context.temp_allocator)) - p2_str := string(hex.encode(p2[:], context.temp_allocator)) - testing.expectf( - t, - p1_str == p2_str, - "Expected %s for %s * basepoint, but got %s instead", - p2_str, - v.scalar, - p1_str, - ) - } -} - -@(test) -test_x448 :: proc(t: ^testing.T) { - // Local copy of this so that the base point doesn't need to be exported. - _BASE_POINT: [56]byte = { - 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - } - - test_vectors := []struct { - scalar: string, - point: string, - product: string, - } { - // Test vectors from RFC 7748 - { - "3d262fddf9ec8e88495266fea19a34d28882acef045104d0d1aae121700a779c984c24f8cdd78fbff44943eba368f54b29259a4f1c600ad3", - "06fce640fa3487bfda5f6cf2d5263f8aad88334cbd07437f020f08f9814dc031ddbdc38c19c6da2583fa5429db94ada18aa7a7fb4ef8a086", - "ce3e4ff95a60dc6697da1db1d85e6afbdf79b50a2412d7546d5f239fe14fbaadeb445fc66a01b0779d98223961111e21766282f73dd96b6f", - }, - { - "203d494428b8399352665ddca42f9de8fef600908e0d461cb021f8c538345dd77c3e4806e25f46d3315c44e0a5b4371282dd2c8d5be3095f", - "0fbcc2f993cd56d3305b0b7d9e55d4c1a8fb5dbb52f8e9a1e9b6201b165d015894e56c4d3570bee52fe205e28a78b91cdfbde71ce8d157db", - "884a02576239ff7a2f2f63b2db6a9ff37047ac13568e1e30fe63c4a7ad1b3ee3a5700df34321d62077e63633c575c1c954514e99da7c179d", - }, - } - for v, _ in test_vectors { - scalar, _ := hex.decode(transmute([]byte)(v.scalar), context.temp_allocator) - point, _ := hex.decode(transmute([]byte)(v.point), context.temp_allocator) - - derived_point: [x448.POINT_SIZE]byte - x448.scalarmult(derived_point[:], scalar[:], point[:]) - derived_point_str := string(hex.encode(derived_point[:], context.temp_allocator)) - - testing.expectf( - t, - derived_point_str == v.product, - "Expected %s for %s * %s, but got %s instead", - v.product, - v.scalar, - v.point, - derived_point_str, - ) - - // Abuse the test vectors to sanity-check the scalar-basepoint multiply. - p1, p2: [x448.POINT_SIZE]byte - x448.scalarmult_basepoint(p1[:], scalar[:]) - x448.scalarmult(p2[:], scalar[:], _BASE_POINT[:]) - p1_str := string(hex.encode(p1[:], context.temp_allocator)) - p2_str := string(hex.encode(p2[:], context.temp_allocator)) - testing.expectf( - t, - p1_str == p2_str, - "Expected %s for %s * basepoint, but got %s instead", - p2_str, - v.scalar, - p1_str, - ) - } -} - -@(private) +@(private="file") ge_str :: proc(ge: ^ristretto255.Group_Element) -> string { b: [ristretto255.ELEMENT_SIZE]byte ristretto255.ge_bytes(ge, b[:]) return string(hex.encode(b[:], context.temp_allocator)) } -@(private) +@(private="file") fe_str :: proc(fe: ^field.Tight_Field_Element) -> string { b: [32]byte field.fe_to_bytes(&b, fe) diff --git a/tests/core/crypto/test_core_crypto_weierstrass.odin b/tests/core/crypto/test_core_crypto_weierstrass.odin new file mode 100644 index 000000000..206e98bd7 --- /dev/null +++ b/tests/core/crypto/test_core_crypto_weierstrass.odin @@ -0,0 +1,486 @@ +package test_core_crypto + +import ec "core:crypto/_weierstrass" +import "core:encoding/hex" +import "core:math/big" +import "core:testing" + +@(private="file") +P256_G_X :: "6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296" +@(private="file") +P256_G_Y :: "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5" + +@(private="file") +P256_G_UNCOMPRESSED :: "04" + P256_G_X + P256_G_Y + +@(test) +test_p256_a :: proc(t: ^testing.T) { + a_str := "ffffffff00000001000000000000000000000000fffffffffffffffffffffffc" + + fe, a_fe: ec.Field_Element_p256r1 + ec.fe_a(&fe) + ec.fe_a(&a_fe) + + b: [32]byte + ec.fe_bytes(b[:], &fe) + + s := (string)(hex.encode(b[:], context.temp_allocator)) + + testing.expect(t, s == a_str) + + ec.fe_zero(&fe) + ec.fe_set_bytes(&fe, b[:]) + + testing.expect(t, ec.fe_equal(&fe, &a_fe) == 1) +} + +@(test) +test_p256_b :: proc(t: ^testing.T) { + b_str := "5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b" + + fe, b_fe: ec.Field_Element_p256r1 + ec.fe_b(&fe) + ec.fe_b(&b_fe) + + b: [32]byte + ec.fe_bytes(b[:], &fe) + + s := (string)(hex.encode(b[:], context.temp_allocator)) + + testing.expect(t, s == b_str) + + ec.fe_zero(&fe) + ec.fe_set_bytes(&fe, b[:]) + + testing.expect(t, ec.fe_equal(&fe, &b_fe) == 1) +} + +@(test) +test_p256_g_x :: proc(t: ^testing.T) { + fe, x_fe: ec.Field_Element_p256r1 + ec.fe_gen_x(&fe) + ec.fe_gen_x(&x_fe) + + b: [32]byte + ec.fe_bytes(b[:], &fe) + + s := (string)(hex.encode(b[:], context.temp_allocator)) + testing.expect(t, s == P256_G_X) + + ec.fe_zero(&fe) + ec.fe_set_bytes(&fe, b[:]) + + testing.expect(t, ec.fe_equal(&fe, &x_fe) == 1) +} + +@(test) +test_p256_g_y :: proc(t: ^testing.T) { + fe, y_fe: ec.Field_Element_p256r1 + ec.fe_gen_y(&fe) + ec.fe_gen_y(&y_fe) + + b: [32]byte + ec.fe_bytes(b[:], &fe) + + s := (string)(hex.encode(b[:], context.temp_allocator)) + testing.expect(t, s == P256_G_Y) + + ec.fe_zero(&fe) + ec.fe_set_bytes(&fe, b[:]) + + testing.expect(t, ec.fe_equal(&fe, &y_fe) == 1) +} + +@(test) +test_p256_scalar_reduce :: proc(t: ^testing.T) { + test_vectors := []struct { + raw: string, + reduced: string, + } { + // n + { + "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551", + "0000000000000000000000000000000000000000000000000000000000000000", + }, + // n + 1 + { + "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632552", + "0000000000000000000000000000000000000000000000000000000000000001", + }, + // 2^384 (Sage) + { + "01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "431905529c0166ce652e96b7ccca0a99679b73e19ad16947f01cf013fc632551", + }, + // SHA384 odin-linux-amd64-dev-2026-01.tar.gz (Sage) + { + "87622f79b4b0e76001f9c99b0337b61a0bcd2b5a8e9a3937176825ad75ef0fe8742a348a251dd2682d711f76b33df3e6", + "f66db86e28d903033d1e17d818c0eb13fe3d1ae095b4d2ecbcd1a1eccf9f2f8c", + }, + // SHA512 odin-linux-amd64-dev-2026-01.tar.gz (Sage) + { + "6f85507cec3a35fdb3d4f40d23583681144561e77bc4ea88ab0ea219d5c17b7c9178f5f5a6296a2d18eddd4bdf19e61830fc85d7de23fd4fbde31c4cf6694719", + "3217ecbee32c8b0dfcca0f10a884fe43658fbe91458f25d0f1bf2075759c5ebe", + }, + } + + for v, _ in test_vectors { + raw_bytes, _ := hex.decode(transmute([]byte)(v.raw), context.temp_allocator) + + sc: ec.Scalar_p256r1 + _ = ec.sc_set_bytes(&sc, raw_bytes) + + b: [ec.SC_SIZE_P256R1]byte + ec.sc_bytes(b[:], &sc) + s := (string)(hex.encode(b[:], context.temp_allocator)) + + testing.expectf(t, v.reduced == s, "sc: raw %s reduced: %s, expected: %s", v.raw, s, v.reduced) + } +} + +@(test) +test_p256_scalar_mul :: proc(t: ^testing.T) { + test_vectors := []struct { + scalar: string, // NOTE: Base 10 + x, y: string, + } { + // Test vectors from http://point-at-infinity.org/ecc/nisttv + { + "1", + "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296", + "4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5", + + }, + { + "2", + "7CF27B188D034F7E8A52380304B51AC3C08969E277F21B35A60B48FC47669978", + "07775510DB8ED040293D9AC69F7430DBBA7DADE63CE982299E04B79D227873D1", + }, + { + "3", + "5ECBE4D1A6330A44C8F7EF951D4BF165E6C6B721EFADA985FB41661BC6E7FD6C", + "8734640C4998FF7E374B06CE1A64A2ECD82AB036384FB83D9A79B127A27D5032", + }, + { + "4", + "E2534A3532D08FBBA02DDE659EE62BD0031FE2DB785596EF509302446B030852", + "E0F1575A4C633CC719DFEE5FDA862D764EFC96C3F30EE0055C42C23F184ED8C6", + }, + { + "5", + "51590B7A515140D2D784C85608668FDFEF8C82FD1F5BE52421554A0DC3D033ED", + "E0C17DA8904A727D8AE1BF36BF8A79260D012F00D4D80888D1D0BB44FDA16DA4", + }, + { + "6", + "B01A172A76A4602C92D3242CB897DDE3024C740DEBB215B4C6B0AAE93C2291A9", + "E85C10743237DAD56FEC0E2DFBA703791C00F7701C7E16BDFD7C48538FC77FE2", + }, + { + "7", + "8E533B6FA0BF7B4625BB30667C01FB607EF9F8B8A80FEF5B300628703187B2A3", + "73EB1DBDE03318366D069F83A6F5900053C73633CB041B21C55E1A86C1F400B4", + }, + { + "8", + "62D9779DBEE9B0534042742D3AB54CADC1D238980FCE97DBB4DD9DC1DB6FB393", + "AD5ACCBD91E9D8244FF15D771167CEE0A2ED51F6BBE76A78DA540A6A0F09957E", + }, + { + "9", + "EA68D7B6FEDF0B71878938D51D71F8729E0ACB8C2C6DF8B3D79E8A4B90949EE0", + "2A2744C972C9FCE787014A964A8EA0C84D714FEAA4DE823FE85A224A4DD048FA", + }, + { + "10", + "CEF66D6B2A3A993E591214D1EA223FB545CA6C471C48306E4C36069404C5723F", + "878662A229AAAE906E123CDD9D3B4C10590DED29FE751EEECA34BBAA44AF0773", + }, + { + "11", + "3ED113B7883B4C590638379DB0C21CDA16742ED0255048BF433391D374BC21D1", + "9099209ACCC4C8A224C843AFA4F4C68A090D04DA5E9889DAE2F8EEFCE82A3740", + }, + { + "12", + "741DD5BDA817D95E4626537320E5D55179983028B2F82C99D500C5EE8624E3C4", + "0770B46A9C385FDC567383554887B1548EEB912C35BA5CA71995FF22CD4481D3", + }, + { + "13", + "177C837AE0AC495A61805DF2D85EE2FC792E284B65EAD58A98E15D9D46072C01", + "63BB58CD4EBEA558A24091ADB40F4E7226EE14C3A1FB4DF39C43BBE2EFC7BFD8", + }, + { + "14", + "54E77A001C3862B97A76647F4336DF3CF126ACBE7A069C5E5709277324D2920B", + "F599F1BB29F4317542121F8C05A2E7C37171EA77735090081BA7C82F60D0B375", + }, + { + "15", + "F0454DC6971ABAE7ADFB378999888265AE03AF92DE3A0EF163668C63E59B9D5F", + "B5B93EE3592E2D1F4E6594E51F9643E62A3B21CE75B5FA3F47E59CDE0D034F36", + }, + { + "16", + "76A94D138A6B41858B821C629836315FCD28392EFF6CA038A5EB4787E1277C6E", + "A985FE61341F260E6CB0A1B5E11E87208599A0040FC78BAA0E9DDD724B8C5110", + }, + { + "17", + "47776904C0F1CC3A9C0984B66F75301A5FA68678F0D64AF8BA1ABCE34738A73E", + "AA005EE6B5B957286231856577648E8381B2804428D5733F32F787FF71F1FCDC", + }, + { + "18", + "1057E0AB5780F470DEFC9378D1C7C87437BB4C6F9EA55C63D936266DBD781FDA", + "F6F1645A15CBE5DC9FA9B7DFD96EE5A7DCC11B5C5EF4F1F78D83B3393C6A45A2", + }, + { + "19", + "CB6D2861102C0C25CE39B7C17108C507782C452257884895C1FC7B74AB03ED83", + "58D7614B24D9EF515C35E7100D6D6CE4A496716E30FA3E03E39150752BCECDAA", + }, + { + "20", + "83A01A9378395BAB9BCD6A0AD03CC56D56E6B19250465A94A234DC4C6B28DA9A", + "76E49B6DE2F73234AE6A5EB9D612B75C9F2202BB6923F54FF8240AAA86F640B8", + }, + { + "112233445566778899", + "339150844EC15234807FE862A86BE77977DBFB3AE3D96F4C22795513AEAAB82F", + "B1C14DDFDC8EC1B2583F51E85A5EB3A155840F2034730E9B5ADA38B674336A21", + }, + { + "112233445566778899112233445566778899", + "1B7E046A076CC25E6D7FA5003F6729F665CC3241B5ADAB12B498CD32F2803264", + "BFEA79BE2B666B073DB69A2A241ADAB0738FE9D2DD28B5604EB8C8CF097C457B", + }, + { + "029852220098221261079183923314599206100666902414330245206392788703677545185283", + "9EACE8F4B071E677C5350B02F2BB2B384AAE89D58AA72CA97A170572E0FB222F", + "1BBDAEC2430B09B93F7CB08678636CE12EAAFD58390699B5FD2F6E1188FC2A78", + }, + { + "057896042899961394862005778464643882389978449576758748073725983489954366354431", + "878F22CC6DB6048D2B767268F22FFAD8E56AB8E2DC615F7BD89F1E350500DD8D", + "714A5D7BB901C9C5853400D12341A892EF45D87FC553786756C4F0C9391D763E", + }, + { + "57896042899961394862005778464643882389978449576758748073725983489954366354431", + "878F22CC6DB6048D2B767268F22FFAD8E56AB8E2DC615F7BD89F1E350500DD8D", + "714A5D7BB901C9C5853400D12341A892EF45D87FC553786756C4F0C9391D763E", + }, + { + "1766845392945710151501889105729049882997660004824848915955419660366636031", + "659A379625AB122F2512B8DADA02C6348D53B54452DFF67AC7ACE4E8856295CA", + "49D81AB97B648464D0B4A288BD7818FAB41A16426E943527C4FED8736C53D0F6", + }, + { + "28948025760307534517734791687894775804466072615242963443097661355606862201087", + "CBCEAAA8A4DD44BBCE58E8DB7740A5510EC2CB7EA8DA8D8F036B3FB04CDA4DE4", + "4BD7AA301A80D7F59FD983FEDBE59BB7B2863FE46494935E3745B360E32332FA", + }, + { + "113078210460870548944811695960290644973229224625838436424477095834645696384", + "F0C4A0576154FF3A33A3460D42EAED806E854DFA37125221D37935124BA462A4", + "5B392FA964434D29EEC6C9DBC261CF116796864AA2FAADB984A2DF38D1AEF7A3", + }, + { + "12078056106883488161242983286051341125085761470677906721917479268909056", + "5E6C8524B6369530B12C62D31EC53E0288173BD662BDF680B53A41ECBCAD00CC", + "447FE742C2BFEF4D0DB14B5B83A2682309B5618E0064A94804E9282179FE089F", + }, + { + "57782969857385448082319957860328652998540760998293976083718804450708503920639", + "03792E541BC209076A3D7920A915021ECD396A6EB5C3960024BE5575F3223484", + "FC774AE092403101563B712F68170312304F20C80B40C06282063DB25F268DE4", + }, + { + "57896017119460046759583662757090100341435943767777707906455551163257755533312", + "2379FF85AB693CDF901D6CE6F2473F39C04A2FE3DCD842CE7AAB0E002095BCF8", + "F8B476530A634589D5129E46F322B02FBC610A703D80875EE70D7CE1877436A1", + }, + { + "452312848374287284681282171017647412726433684238464212999305864837160993279", + "C1E4072C529BF2F44DA769EFC934472848003B3AF2C0F5AA8F8DDBD53E12ED7C", + "39A6EE77812BB37E8079CD01ED649D3830FCA46F718C1D3993E4A591824ABCDB", + }, + { + "904571339174065134293634407946054000774746055866917729876676367558469746684", + "34DFBC09404C21E250A9B40FA8772897AC63A094877DB65862B61BD1507B34F3", + "CF6F8A876C6F99CEAEC87148F18C7E1E0DA6E165FFC8ED82ABB65955215F77D3", + }, + { + "115792089210356248762697446949407573529996955224135760342422259061068512044349", + "83A01A9378395BAB9BCD6A0AD03CC56D56E6B19250465A94A234DC4C6B28DA9A", + "891B64911D08CDCC5195A14629ED48A360DDFD4596DC0AB007DBF5557909BF47", + }, + { + "115792089210356248762697446949407573529996955224135760342422259061068512044350", + "CB6D2861102C0C25CE39B7C17108C507782C452257884895C1FC7B74AB03ED83", + "A7289EB3DB2610AFA3CA18EFF292931B5B698E92CF05C1FC1C6EAF8AD4313255", + }, + { + "115792089210356248762697446949407573529996955224135760342422259061068512044351", + "1057E0AB5780F470DEFC9378D1C7C87437BB4C6F9EA55C63D936266DBD781FDA", + "090E9BA4EA341A246056482026911A58233EE4A4A10B0E08727C4CC6C395BA5D", + }, + { + "115792089210356248762697446949407573529996955224135760342422259061068512044352", + "47776904C0F1CC3A9C0984B66F75301A5FA68678F0D64AF8BA1ABCE34738A73E", + "55FFA1184A46A8D89DCE7A9A889B717C7E4D7FBCD72A8CC0CD0878008E0E0323", + }, + { + "115792089210356248762697446949407573529996955224135760342422259061068512044353", + "76A94D138A6B41858B821C629836315FCD28392EFF6CA038A5EB4787E1277C6E", + "567A019DCBE0D9F2934F5E4A1EE178DF7A665FFCF0387455F162228DB473AEEF", + }, + { + "115792089210356248762697446949407573529996955224135760342422259061068512044354", + "F0454DC6971ABAE7ADFB378999888265AE03AF92DE3A0EF163668C63E59B9D5F", + "4A46C11BA6D1D2E1B19A6B1AE069BC19D5C4DE328A4A05C0B81A6321F2FCB0C9", + }, + { + "115792089210356248762697446949407573529996955224135760342422259061068512044355", + "54E77A001C3862B97A76647F4336DF3CF126ACBE7A069C5E5709277324D2920B", + "0A660E43D60BCE8BBDEDE073FA5D183C8E8E15898CAF6FF7E45837D09F2F4C8A", + }, + { + "115792089210356248762697446949407573529996955224135760342422259061068512044356", + "177C837AE0AC495A61805DF2D85EE2FC792E284B65EAD58A98E15D9D46072C01", + "9C44A731B1415AA85DBF6E524BF0B18DD911EB3D5E04B20C63BC441D10384027", + }, + { + "115792089210356248762697446949407573529996955224135760342422259061068512044357", + "741DD5BDA817D95E4626537320E5D55179983028B2F82C99D500C5EE8624E3C4", + "F88F4B9463C7A024A98C7CAAB7784EAB71146ED4CA45A358E66A00DD32BB7E2C", + }, + { + "115792089210356248762697446949407573529996955224135760342422259061068512044358", + "3ED113B7883B4C590638379DB0C21CDA16742ED0255048BF433391D374BC21D1", + "6F66DF64333B375EDB37BC505B0B3975F6F2FB26A16776251D07110317D5C8BF", + }, + { + "115792089210356248762697446949407573529996955224135760342422259061068512044359", + "CEF66D6B2A3A993E591214D1EA223FB545CA6C471C48306E4C36069404C5723F", + "78799D5CD655517091EDC32262C4B3EFA6F212D7018AE11135CB4455BB50F88C", + }, + { + "115792089210356248762697446949407573529996955224135760342422259061068512044360", + "EA68D7B6FEDF0B71878938D51D71F8729E0ACB8C2C6DF8B3D79E8A4B90949EE0", + "D5D8BB358D36031978FEB569B5715F37B28EB0165B217DC017A5DDB5B22FB705", + }, + { + "115792089210356248762697446949407573529996955224135760342422259061068512044361", + "62D9779DBEE9B0534042742D3AB54CADC1D238980FCE97DBB4DD9DC1DB6FB393", + "52A533416E1627DCB00EA288EE98311F5D12AE0A4418958725ABF595F0F66A81", + }, + { + "115792089210356248762697446949407573529996955224135760342422259061068512044362", + "8E533B6FA0BF7B4625BB30667C01FB607EF9F8B8A80FEF5B300628703187B2A3", + "8C14E2411FCCE7CA92F9607C590A6FFFAC38C9CD34FBE4DE3AA1E5793E0BFF4B", + }, + { + "115792089210356248762697446949407573529996955224135760342422259061068512044363", + "B01A172A76A4602C92D3242CB897DDE3024C740DEBB215B4C6B0AAE93C2291A9", + "17A3EF8ACDC8252B9013F1D20458FC86E3FF0890E381E9420283B7AC7038801D", + }, + { + "115792089210356248762697446949407573529996955224135760342422259061068512044364", + "51590B7A515140D2D784C85608668FDFEF8C82FD1F5BE52421554A0DC3D033ED", + "1F3E82566FB58D83751E40C9407586D9F2FED1002B27F7772E2F44BB025E925B", + }, + { + "115792089210356248762697446949407573529996955224135760342422259061068512044365", + "E2534A3532D08FBBA02DDE659EE62BD0031FE2DB785596EF509302446B030852", + "1F0EA8A4B39CC339E62011A02579D289B103693D0CF11FFAA3BD3DC0E7B12739", + }, + { + "115792089210356248762697446949407573529996955224135760342422259061068512044366", + "5ECBE4D1A6330A44C8F7EF951D4BF165E6C6B721EFADA985FB41661BC6E7FD6C", + "78CB9BF2B6670082C8B4F931E59B5D1327D54FCAC7B047C265864ED85D82AFCD", + }, + { + "115792089210356248762697446949407573529996955224135760342422259061068512044367", + "7CF27B188D034F7E8A52380304B51AC3C08969E277F21B35A60B48FC47669978", + "F888AAEE24712FC0D6C26539608BCF244582521AC3167DD661FB4862DD878C2E", + }, + { + "115792089210356248762697446949407573529996955224135760342422259061068512044368", + "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296", + "B01CBD1C01E58065711814B583F061E9D431CCA994CEA1313449BF97C840AE0A", + }, + } + + for v, _ in test_vectors { + x_bytes, _ := hex.decode(transmute([]byte)(v.x), context.temp_allocator) + y_bytes, _ := hex.decode(transmute([]byte)(v.y), context.temp_allocator) + + k_big: big.Int + err := big.set(&k_big, v.scalar, 10, context.temp_allocator) + testing.expectf(t, err == nil, "failed to parse k", err) + + k_sz: int + k_sz, err = big.int_to_bytes_size(&k_big, allocator = context.temp_allocator) + testing.expect(t, err == nil) + + k_bytes := make([]byte, k_sz, context.temp_allocator) + err = big.int_to_bytes_big(&k_big, k_bytes, allocator = context.temp_allocator) + + p, q, expected, g: ec.Point_p256r1 + sc: ec.Scalar_p256r1 + + _ = ec.sc_set_bytes(&sc, k_bytes) + + ec.pt_generator(&g) + ok := ec.pt_set_xy_bytes(&expected, x_bytes, y_bytes) + testing.expectf(t, ok, "failed to set point; %s, %s", v.x, v.y) + + ec.pt_scalar_mul(&p, &g, &sc) + ec.pt_scalar_mul_generator(&q, &sc) + ec.pt_rescale(&p, &p) + ec.pt_rescale(&q, &q) + + testing.expect(t, ec.pt_equal(&p, &q) == 1) + testing.expectf(t, ec.pt_equal(&p, &expected) == 1, "sc: %s actual: %v expected: %v", v.scalar, &p, &expected) + } +} + +@(test) +test_p256_s11n_sec_identity ::proc(t: ^testing.T) { + p: ec.Point_p256r1 + + ec.pt_generator(&p) + ok := ec.pt_set_sec_bytes(&p, []byte{0x00}) + testing.expect(t, ok) + testing.expectf(t, ec.pt_is_identity(&p) == 1, "%v", p) + + b := []byte{0xff} + ok = ec.pt_sec_bytes(b, &p, true) + testing.expect(t, ok) + testing.expect(t, b[0] == 0x00) + + b = []byte{0xff} + ok = ec.pt_sec_bytes(b, &p, false) + testing.expect(t, ok) + testing.expect(t, b[0] == 0x00) +} + +@(test) +test_p256_s11n_sec_generator ::proc(t: ^testing.T) { + p, g: ec.Point_p256r1 + + ec.pt_generator(&g) + ec.pt_identity(&p) + + b: [65]byte + ok := ec.pt_sec_bytes(b[:], &g, false) + testing.expect(t, ok) + s := (string)(hex.encode(b[:], context.temp_allocator)) + testing.expectf(t, s == P256_G_UNCOMPRESSED, "g: %v bytes: %v, %v", g, P256_G_UNCOMPRESSED, s) + + ok = ec.pt_set_sec_bytes(&p, b[:]) + testing.expectf(t, ok, "%s", s) + testing.expect(t, ec.pt_equal(&g, &p) == 1) +} diff --git a/tests/core/encoding/base32/base32.odin b/tests/core/encoding/base32/base32.odin index f757e99e5..2abb244ca 100644 --- a/tests/core/encoding/base32/base32.odin +++ b/tests/core/encoding/base32/base32.odin @@ -1,4 +1,3 @@ -#+test package test_encoding_base32 import "core:testing" @@ -83,7 +82,16 @@ test_base32_decode_invalid :: proc(t: ^testing.T) { // Section 3.2 - Padding requirements { - // Padding must only be at end + // Padding in middle without trailing padding + input := "MZ===YTBMZXW6YTB" // '===' in middle, no trailing padding + output, err := base32.decode(input) + if output != nil { + defer delete(output) + } + testing.expect_value(t, err, Error.Malformed_Input) + } + { + // Padding must only be at end (with trailing padding) input := "MZ=Q====" output, err := base32.decode(input) if output != nil { @@ -228,4 +236,4 @@ test_base32_custom_alphabet :: proc(t: ^testing.T) { } testing.expect_value(t, err, Error.Invalid_Character) } -} \ No newline at end of file +} diff --git a/tests/core/encoding/base64/base64.odin b/tests/core/encoding/base64/base64.odin index ed1bee8af..93b3afb59 100644 --- a/tests/core/encoding/base64/base64.odin +++ b/tests/core/encoding/base64/base64.odin @@ -50,4 +50,19 @@ test_roundtrip :: proc(t: ^testing.T) { for v, i in decoded { testing.expect_value(t, v, values[i]) } -} \ No newline at end of file +} + +@(test) +test_base64url :: proc(t: ^testing.T) { + plain := ">>>" + url := "Pj4-" + + encoded := base64.encode(transmute([]byte)plain, base64.ENC_URL_TABLE) + defer delete(encoded) + testing.expect_value(t, encoded, url) + + decoded := string(base64.decode(url, base64.DEC_URL_TABLE)) + defer delete(decoded) + testing.expect_value(t, decoded, plain) + +} diff --git a/tests/core/encoding/xml/test_core_xml.odin b/tests/core/encoding/xml/test_core_xml.odin index 409a8c9c0..09cca4a63 100644 --- a/tests/core/encoding/xml/test_core_xml.odin +++ b/tests/core/encoding/xml/test_core_xml.odin @@ -114,7 +114,7 @@ xml_test_entities :: proc(t: ^testing.T) { }, expected_doctype = "html", }, - crc32 = 0x48f41216, + crc32 = 0x98791215, }) } @@ -128,7 +128,7 @@ xml_test_entities_unbox :: proc(t: ^testing.T) { }, expected_doctype = "html", }, - crc32 = 0xd0567818, + crc32 = 0x5fd5ab4e, }) } @@ -142,7 +142,7 @@ xml_test_entities_unbox_decode :: proc(t: ^testing.T) { }, expected_doctype = "html", }, - crc32 = 0x68d2571e, + crc32 = 0xda1ac384, }) } @@ -298,4 +298,4 @@ doc_to_string :: proc(doc: ^xml.Document) -> (result: string) { print(strings.to_writer(&buf), doc) return strings.clone(strings.to_string(buf)) -} \ No newline at end of file +} diff --git a/tests/core/nbio/fs.odin b/tests/core/nbio/fs.odin new file mode 100644 index 000000000..6e079f96e --- /dev/null +++ b/tests/core/nbio/fs.odin @@ -0,0 +1,100 @@ +package tests_nbio + +import "core:nbio" +import "core:testing" +import "core:time" +import os "core:os/os2" + +@(test) +close_invalid_handle :: proc(t: ^testing.T) { + if event_loop_guard(t) { + testing.set_fail_timeout(t, time.Minute) + + nbio.close(max(nbio.Handle)) + + ev(t, nbio.run(), nil) + } +} + +@(test) +write_read_close :: proc(t: ^testing.T) { + if event_loop_guard(t) { + testing.set_fail_timeout(t, time.Minute) + + @static content := [20]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20} + @static result: [20]byte + + FILENAME :: "test_write_read_close" + + nbio.open_poly(FILENAME, t, on_open, mode={.Read, .Write, .Create, .Trunc}) + + on_open :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.open.err, nil) + + nbio.write_poly(op.open.handle, 0, content[:], t, on_write) + } + + on_write :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.write.err, nil) + ev(t, op.write.written, len(content)) + + nbio.read_poly(op.write.handle, 0, result[:], t, on_read, all=true) + } + + on_read :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.read.err, nil) + ev(t, op.read.read, len(result)) + ev(t, result, content) + + nbio.close_poly(op.read.handle, t, on_close) + } + + on_close :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.close.err, nil) + os.remove(FILENAME) + } + + ev(t, nbio.run(), nil) + } +} + +@(test) +read_empty_file :: proc(t: ^testing.T) { + if event_loop_guard(t) { + testing.set_fail_timeout(t, time.Minute) + + FILENAME :: "test_read_empty_file" + + handle, err := nbio.open_sync(FILENAME, mode={.Read, .Write, .Create, .Trunc}) + ev(t, err, nil) + + buf: [128]byte + nbio.read_poly(handle, 0, buf[:], t, proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.read.err, nbio.FS_Error.EOF) + ev(t, op.read.read, 0) + + nbio.close_poly(op.read.handle, t, proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.close.err, nil) + os.remove(FILENAME) + }) + }) + + ev(t, nbio.run(), nil) + } +} + +@(test) +read_entire_file :: proc(t: ^testing.T) { + if event_loop_guard(t) { + testing.set_fail_timeout(t, time.Minute) + + nbio.read_entire_file(#file, t, on_read) + + on_read :: proc(t: rawptr, data: []byte, err: nbio.Read_Entire_File_Error) { + t := (^testing.T)(t) + ev(t, err.value, nil) + ev(t, string(data), #load(#file, string)) + delete(data) + } + } +} diff --git a/tests/core/nbio/nbio.odin b/tests/core/nbio/nbio.odin new file mode 100644 index 000000000..2f454f55b --- /dev/null +++ b/tests/core/nbio/nbio.odin @@ -0,0 +1,258 @@ +package tests_nbio + +import "core:log" +import "core:nbio" +import "core:testing" +import "core:thread" +import "core:time" +import os "core:os/os2" + +ev :: testing.expect_value +e :: testing.expect + +@(deferred_in=event_loop_guard_exit) +event_loop_guard :: proc(t: ^testing.T) -> bool { + err := nbio.acquire_thread_event_loop() + if err == .Unsupported || !nbio.FULLY_SUPPORTED { + log.warn("nbio unsupported, skipping") + return false + } + + ev(t, err, nil) + return true +} + +event_loop_guard_exit :: proc(t: ^testing.T) { + ev(t, nbio.run(), nil) // Could have some things to clean up from a `defer` in the test. + nbio.release_thread_event_loop() +} + +// Tests that all poly variants are correctly passing through arguments, and that +// all procs eventually get their callback called. +// +// This is important because the poly procs are only checked when they are called, +// So this will also catch any typos in their implementations. +@(test) +all_poly_work :: proc(tt: ^testing.T) { + if event_loop_guard(tt) { + testing.set_fail_timeout(tt, time.Minute) + + @static t: ^testing.T + t = tt + + @static n: int + n = 0 + NUM_TESTS :: 39 + + UDP_SOCKET :: max(nbio.UDP_Socket) + TCP_SOCKET :: max(nbio.TCP_Socket) + + tmp, terr := os.create_temp_file("", "tests_nbio_poly*", {.Non_Blocking}) + ev(t, terr, nil) + defer os.close(tmp) + + HANDLE, aerr := nbio.associate_handle(os.fd(tmp)) + ev(t, aerr, nil) + + _buf: [1]byte + buf := _buf[:] + + one :: proc(op: ^nbio.Operation, one: int) { + n += 1 + ev(t, one, 1) + } + + two :: proc(op: ^nbio.Operation, one: int, two: int) { + n += 1 + ev(t, one, 1) + ev(t, two, 2) + } + + three :: proc(op: ^nbio.Operation, one: int, two: int, three: int) { + n += 1 + ev(t, one, 1) + ev(t, two, 2) + ev(t, three, 3) + } + + nbio.accept_poly(TCP_SOCKET, 1, one) + nbio.accept_poly2(TCP_SOCKET, 1, 2, two) + nbio.accept_poly3(TCP_SOCKET, 1, 2, 3, three) + + nbio.close_poly(max(nbio.Handle), 1, one) + nbio.close_poly2(max(nbio.Handle), 1, 2, two) + nbio.close_poly3(max(nbio.Handle), 1, 2, 3, three) + + nbio.dial_poly({nbio.IP4_Address{127, 0, 0, 1}, 0}, 1, one) + nbio.dial_poly2({nbio.IP4_Address{127, 0, 0, 1}, 0}, 1, 2, two) + nbio.dial_poly3({nbio.IP4_Address{127, 0, 0, 1}, 0}, 1, 2, 3, three) + + nbio.recv_poly(TCP_SOCKET, {buf}, 1, one) + nbio.recv_poly2(TCP_SOCKET, {buf}, 1, 2, two) + nbio.recv_poly3(TCP_SOCKET, {buf}, 1, 2, 3, three) + + nbio.send_poly(TCP_SOCKET, {buf}, 1, one) + nbio.send_poly2(TCP_SOCKET, {buf}, 1, 2, two) + nbio.send_poly3(TCP_SOCKET, {buf}, 1, 2, 3, three) + + nbio.sendfile_poly(TCP_SOCKET, HANDLE, 1, one) + nbio.sendfile_poly2(TCP_SOCKET, HANDLE, 1, 2, two) + nbio.sendfile_poly3(TCP_SOCKET, HANDLE, 1, 2, 3, three) + + nbio.read_poly(HANDLE, 0, buf, 1, one) + nbio.read_poly2(HANDLE, 0, buf, 1, 2, two) + nbio.read_poly3(HANDLE, 0, buf, 1, 2, 3, three) + + nbio.write_poly(HANDLE, 0, buf, 1, one) + nbio.write_poly2(HANDLE, 0, buf, 1, 2, two) + nbio.write_poly3(HANDLE, 0, buf, 1, 2, 3, three) + + nbio.next_tick_poly(1, one) + nbio.next_tick_poly2(1, 2, two) + nbio.next_tick_poly3(1, 2, 3, three) + + nbio.timeout_poly(1, 1, one) + nbio.timeout_poly2(1, 1, 2, two) + nbio.timeout_poly3(1, 1, 2, 3, three) + + nbio.poll_poly(TCP_SOCKET, .Receive, 1, one) + nbio.poll_poly2(TCP_SOCKET, .Receive, 1, 2, two) + nbio.poll_poly3(TCP_SOCKET, .Receive, 1, 2, 3, three) + + nbio.open_poly("", 1, one) + nbio.open_poly2("", 1, 2, two) + nbio.open_poly3("", 1, 2, 3, three) + + nbio.stat_poly(HANDLE, 1, one) + nbio.stat_poly2(HANDLE, 1, 2, two) + nbio.stat_poly3(HANDLE, 1, 2, 3, three) + + ev(t, n, 0) // Test that no callbacks are ran before the loop is ticked. + ev(t, nbio.run(), nil) + ev(t, n, NUM_TESTS) // Test that all callbacks have ran. + } +} + +@(test) +two_ops_at_the_same_time :: proc(t: ^testing.T) { + if event_loop_guard(t) { + testing.set_fail_timeout(t, time.Minute) + + server, err := nbio.create_udp_socket(.IP4) + ev(t, err, nil) + defer nbio.close(server) + + berr := nbio.bind(server, {nbio.IP4_Loopback, 0}) + ev(t, berr, nil) + ep, eperr := nbio.bound_endpoint(server) + ev(t, eperr, nil) + + // Server. + { + nbio.poll_poly(server, .Receive, t, on_poll) + + on_poll :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.poll.result, nbio.Poll_Result.Ready) + } + + buf: [128]byte + nbio.recv_poly(server, {buf[:]}, t, on_recv) + + on_recv :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.recv.err, nil) + } + } + + // Client. + { + sock, cerr := nbio.create_udp_socket(.IP4) + ev(t, cerr, nil) + + // Make sure the server would block. + nbio.timeout_poly3(time.Millisecond*10, t, sock, ep.port, on_timeout) + + on_timeout :: proc(op: ^nbio.Operation, t: ^testing.T, sock: nbio.UDP_Socket, port: int) { + nbio.send_poly(sock, {transmute([]byte)string("Hiya")}, t, on_send, {nbio.IP4_Loopback, port}) + } + + on_send :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.send.err, nil) + ev(t, op.send.sent, 4) + + // Do another send after a bit, some backends don't trigger both ops when one was enough to + // use up the socket. + nbio.timeout_poly3(time.Millisecond*10, t, op.send.socket.(nbio.UDP_Socket), op.send.endpoint.port, on_timeout2) + } + + on_timeout2 :: proc(op: ^nbio.Operation, t: ^testing.T, sock: nbio.UDP_Socket, port: int) { + nbio.send_poly(sock, {transmute([]byte)string("Hiya")}, t, on_send2, {nbio.IP4_Loopback, port}) + } + + on_send2 :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.send.err, nil) + ev(t, op.send.sent, 4) + + nbio.close(op.send.socket.(nbio.UDP_Socket)) + } + } + + ev(t, nbio.run(), nil) + } +} + +@(test) +timeout :: proc(t: ^testing.T) { + if event_loop_guard(t) { + testing.set_fail_timeout(t, time.Minute) + + start := time.now() + + nbio.timeout_poly2(time.Millisecond*20, t, start, on_timeout) + + on_timeout :: proc(op: ^nbio.Operation, t: ^testing.T, start: time.Time) { + since := time.since(start) + log.infof("timeout ran after: %v", since) + testing.expect(t, since >= time.Millisecond*19) // A ms grace, for some reason it is sometimes ran after 19.8ms. + if since < 20 { + log.warnf("timeout ran after: %v", since) + } + } + + ev(t, nbio.run(), nil) + } +} + +@(test) +wake_up :: proc(t: ^testing.T) { + testing.set_fail_timeout(t, time.Minute) + if event_loop_guard(t) { + for _ in 0..<2 { + sock, _ := open_next_available_local_port(t) + + // Add an accept, with nobody dialling this should block the event loop forever. + accept := nbio.accept(sock, proc(op: ^nbio.Operation) { + log.error("shouldn't be called") + }) + + // Make sure the accept is in progress. + ev(t, nbio.tick(timeout=0), nil) + + hit: bool + thr := thread.create_and_start_with_poly_data2(nbio.current_thread_event_loop(), &hit, proc(l: ^nbio.Event_Loop, hit: ^bool) { + hit^ = true + nbio.wake_up(l) + }, context) + defer thread.destroy(thr) + + // Should block forever until the thread calling wake_up will make it return. + ev(t, nbio.tick(), nil) + e(t, hit) + + nbio.remove(accept) + nbio.close(sock) + + ev(t, nbio.run(), nil) + ev(t, nbio.tick(timeout=0), nil) + } + } +} diff --git a/tests/core/nbio/net.odin b/tests/core/nbio/net.odin new file mode 100644 index 000000000..688ee0b45 --- /dev/null +++ b/tests/core/nbio/net.odin @@ -0,0 +1,400 @@ +package tests_nbio + +import "core:mem" +import "core:nbio" +import "core:net" +import "core:testing" +import "core:time" +import "core:log" + +open_next_available_local_port :: proc(t: ^testing.T, addr: net.Address = net.IP4_Loopback, loc := #caller_location) -> (sock: net.TCP_Socket, ep: net.Endpoint) { + err: net.Network_Error + sock, err = nbio.listen_tcp({addr, 0}) + if err != nil { + log.errorf("listen_tcp: %v", err, location=loc) + return + } + + ep, err = net.bound_endpoint(sock) + if err != nil { + log.errorf("bound_endpoint: %v", err, location=loc) + } + + return +} + +@(test) +client_and_server_send_recv :: proc(t: ^testing.T) { + if event_loop_guard(t) { + testing.set_fail_timeout(t, time.Minute) + + server, ep := open_next_available_local_port(t) + + CONTENT :: [20]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20} + + State :: struct { + server: net.TCP_Socket, + server_client: net.TCP_Socket, + client: net.TCP_Socket, + recv_buf: [20]byte, + send_buf: [20]byte, + } + + state := State{ + server = server, + send_buf = CONTENT, + } + + close_ok :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.close.err, nil) + } + + // Server + { + nbio.accept_poly2(server, t, &state, on_accept) + + on_accept :: proc(op: ^nbio.Operation, t: ^testing.T, state: ^State) { + ev(t, op.accept.err, nil) + + state.server_client = op.accept.client + + log.debugf("accepted connection from: %v", op.accept.client_endpoint) + + nbio.recv_poly2(state.server_client, {state.recv_buf[:]}, t, state, on_recv) + } + + on_recv :: proc(op: ^nbio.Operation, t: ^testing.T, state: ^State) { + ev(t, op.recv.err, nil) + ev(t, op.recv.received, 20) + ev(t, state.recv_buf, CONTENT) + + nbio.close_poly(state.server_client, t, close_ok) + nbio.close_poly(state.server, t, close_ok) + } + + ev(t, nbio.tick(0), nil) + } + + // Client + { + nbio.dial_poly2(ep, t, &state, on_dial) + + on_dial :: proc(op: ^nbio.Operation, t: ^testing.T, state: ^State) { + ev(t, op.dial.err, nil) + + state.client = op.dial.socket + + nbio.send_poly2(state.client, {state.send_buf[:]}, t, state, on_send) + } + + on_send :: proc(op: ^nbio.Operation, t: ^testing.T, state: ^State) { + ev(t, op.send.err, nil) + ev(t, op.send.sent, 20) + + nbio.close_poly(state.client, t, close_ok) + } + } + + ev(t, nbio.run(), nil) + } +} + +@(test) +close_and_remove_accept :: proc(t: ^testing.T) { + if event_loop_guard(t) { + testing.set_fail_timeout(t, time.Minute) + + server, _ := open_next_available_local_port(t) + + accept := nbio.accept_poly(server, t, proc(_: ^nbio.Operation, t: ^testing.T) { + testing.fail_now(t) + }) + + ev(t, nbio.tick(0), nil) + + nbio.close_poly(server, t, proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.close.err, nil) + }) + + nbio.remove(accept) + ev(t, nbio.run(), nil) + } +} + +// Tests that when a client calls `close` on it's socket, `recv` returns with `0, nil` (connection closed). +@(test) +close_errors_recv :: proc(t: ^testing.T) { + if event_loop_guard(t) { + testing.set_fail_timeout(t, time.Minute) + + server, ep := open_next_available_local_port(t) + + // Server + { + nbio.accept_poly(server, t, on_accept) + + on_accept :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.accept.err, nil) + + bytes := make([]byte, 128, context.temp_allocator) + nbio.recv_poly(op.accept.client, {bytes}, t, on_recv) + } + + on_recv :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.recv.received, 0) + ev(t, op.recv.err, nil) + } + + ev(t, nbio.tick(0), nil) + } + + // Client + { + nbio.dial_poly(ep, t, on_dial) + + on_dial :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.dial.err, nil) + nbio.close_poly(op.dial.socket, t, on_close) + } + + on_close :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.close.err, nil) + } + } + + ev(t, nbio.run(), nil) + } +} + +@(test) +ipv6 :: proc(t: ^testing.T) { + if event_loop_guard(t) { + testing.set_fail_timeout(t, time.Minute) + + server, ep := open_next_available_local_port(t, net.IP6_Loopback) + + nbio.accept_poly(server, t, on_accept) + on_accept :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.accept.err, nil) + addr, is_ipv6 := op.accept.client_endpoint.address.(net.IP6_Address) + e(t, is_ipv6) + ev(t, addr, net.IP6_Loopback) + e(t, op.accept.client_endpoint.port != 0) + nbio.close(op.accept.client) + nbio.close(op.accept.socket) + } + + nbio.dial_poly(ep, t, on_dial) + on_dial :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.dial.err, nil) + nbio.close(op.dial.socket) + } + + ev(t, nbio.run(), nil) + } +} + +@(test) +accept_timeout :: proc(t: ^testing.T) { + if event_loop_guard(t) { + testing.set_fail_timeout(t, time.Minute) + + sock, _ := open_next_available_local_port(t) + + hit: bool + nbio.accept_poly2(sock, t, &hit, on_accept, timeout=time.Millisecond) + + on_accept :: proc(op: ^nbio.Operation, t: ^testing.T, hit: ^bool) { + hit^ = true + ev(t, op.accept.err, net.Accept_Error.Timeout) + nbio.close(op.accept.socket) + } + + ev(t, nbio.run(), nil) + + e(t, hit) + } +} + +@(test) +poll_timeout :: proc(t: ^testing.T) { + if event_loop_guard(t) { + testing.set_fail_timeout(t, time.Minute) + + sock, err := nbio.create_udp_socket(.IP4) + ev(t, err, nil) + berr := nbio.bind(sock, {nbio.IP4_Loopback, 0}) + ev(t, berr, nil) + + nbio.poll_poly(sock, .Receive, t, on_poll, time.Millisecond) + on_poll :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.poll.result, nbio.Poll_Result.Timeout) + } + + ev(t, nbio.run(), nil) + } +} + +/* +This test walks through the scenario where a user wants to `poll` in order to check if some other package (in this case `core:net`), +would be able to do an operation without blocking. + +It also tests whether a poll can be issues when it is already in a ready state. +And it tests big send/recv buffers being handled properly. +*/ +@(test) +poll :: proc(t: ^testing.T) { + if event_loop_guard(t) { +// testing.set_fail_timeout(t, time.Minute) + + can_recv: bool + + sock, ep := open_next_available_local_port(t) + + // Server + { + nbio.accept_poly2(sock, t, &can_recv, on_accept) + + on_accept :: proc(op: ^nbio.Operation, t: ^testing.T, can_recv: ^bool) { + ev(t, op.accept.err, nil) + + check_recv :: proc(op: ^nbio.Operation, t: ^testing.T, can_recv: ^bool, client: net.TCP_Socket) { + // Not ready to unblock the client yet, requeue for after 10ms. + if !can_recv^ { + nbio.timeout_poly3(time.Millisecond * 10, t, can_recv, client, check_recv) + return + } + + free_all(context.temp_allocator) + + // Connection was closed by client, close server. + if op.type == .Recv && op.recv.received == 0 && op.recv.err == nil { + nbio.close(client) + return + } + + if op.type == .Recv { + log.debugf("received %M this time", op.recv.received) + } + + // Receive some data to unblock the client, which should complete the poll it does, allowing it to send data again. + buf, mem_err := make([]byte, mem.Gigabyte, context.temp_allocator) + ev(t, mem_err, nil) + nbio.recv_poly3(client, {buf}, t, can_recv, client, check_recv) + } + nbio.timeout_poly3(time.Millisecond * 10, t, can_recv, op.accept.client, check_recv) + } + + ev(t, nbio.tick(0), nil) + } + + // Client + { + nbio.dial_poly2(ep, t, &can_recv, on_dial) + + on_dial :: proc(op: ^nbio.Operation, t: ^testing.T, can_recv: ^bool) { + ev(t, op.dial.err, nil) + + // Do a poll even though we know it's ready, so we can test that all implementations can handle that. + nbio.poll_poly2(op.dial.socket, .Send, t, can_recv, on_poll1) + } + + on_poll1 :: proc(op: ^nbio.Operation, t: ^testing.T, can_recv: ^bool) { + ev(t, op.poll.result, nil) + + // Send 4 GB of data, which in my experience causes a Would_Block error because we filled up the internal buffer. + buf, mem_err := make([]byte, mem.Gigabyte*4, context.temp_allocator) + ev(t, mem_err, nil) + + // Use `core:net` as example external code that doesn't care about the event loop. + net.set_blocking(op.poll.socket, false) + n, send_err := net.send(op.poll.socket, buf) + ev(t, send_err, net.TCP_Send_Error.Would_Block) + + log.debugf("blocking after %M", n) + + // Tell the server it can start issueing recv calls, so it unblocks us. + can_recv^ = true + + // Now poll again, when the server reads enough data it should complete, telling us we can send without blocking again. + nbio.poll_poly(op.poll.socket, .Send, t, on_poll2) + } + + on_poll2 :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.poll.result, nil) + + buf: [128]byte + bytes_written, send_err := net.send(op.poll.socket, buf[:]) + ev(t, bytes_written, 128) + ev(t, send_err, nil) + + nbio.close(op.poll.socket.(net.TCP_Socket)) + } + } + + ev(t, nbio.run(), nil) + nbio.close(sock) + ev(t, nbio.run(), nil) + } +} + +@(test) +sendfile :: proc(t: ^testing.T) { + if event_loop_guard(t) { + testing.set_fail_timeout(t, time.Minute) + + CONTENT :: #load(#file) + + sock, ep := open_next_available_local_port(t) + + // Server + { + nbio.accept_poly(sock, t, on_accept) + + on_accept :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.accept.err, nil) + e(t, op.accept.client != 0) + + log.debugf("connection from: %v", op.accept.client_endpoint) + nbio.open_poly3(#file, t, op.accept.socket, op.accept.client, on_open) + } + + on_open :: proc(op: ^nbio.Operation, t: ^testing.T, server, client: net.TCP_Socket) { + ev(t, op.open.err, nil) + + nbio.sendfile_poly2(client, op.open.handle, t, server, on_sendfile) + } + + on_sendfile :: proc(op: ^nbio.Operation, t: ^testing.T, server: net.TCP_Socket) { + ev(t, op.sendfile.err, nil) + ev(t, op.sendfile.sent, len(CONTENT)) + + nbio.close(op.sendfile.file) + nbio.close(op.sendfile.socket) + nbio.close(server) + } + } + + // Client + { + nbio.dial_poly(ep, t, on_dial) + + on_dial :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.dial.err, nil) + + buf := make([]byte, len(CONTENT), context.temp_allocator) + nbio.recv_poly(op.dial.socket, {buf}, t, on_recv, all=true) + } + + on_recv :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.recv.err, nil) + ev(t, op.recv.received, len(CONTENT)) + ev(t, string(op.recv.bufs[0]), string(CONTENT)) + + nbio.close(op.recv.socket.(net.TCP_Socket)) + } + } + + ev(t, nbio.run(), nil) + } +} diff --git a/tests/core/nbio/remove.odin b/tests/core/nbio/remove.odin new file mode 100644 index 000000000..063c2cf58 --- /dev/null +++ b/tests/core/nbio/remove.odin @@ -0,0 +1,247 @@ +package tests_nbio + +import "core:nbio" +import "core:net" +import "core:testing" +import "core:time" +import "core:log" + +// Removals are pretty complex. + +@(test) +immediate_remove_of_sendfile :: proc(t: ^testing.T) { + if event_loop_guard(t) { + testing.set_fail_timeout(t, time.Minute) + + sock, ep := open_next_available_local_port(t) + + // Server + { + nbio.accept_poly(sock, t, on_accept) + + on_accept :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.accept.err, nil) + e(t, op.accept.client != 0) + + log.debugf("connection from: %v", op.accept.client_endpoint) + nbio.open_poly3(#file, t, op.accept.socket, op.accept.client, on_open) + } + + on_open :: proc(op: ^nbio.Operation, t: ^testing.T, server, client: net.TCP_Socket) { + ev(t, op.open.err, nil) + e(t, op.open.handle != 0) + + sendfile_op := nbio.sendfile_poly2(client, op.open.handle, t, server, on_sendfile) + + // oh no changed my mind. + nbio.remove(sendfile_op) + + nbio.close(op.open.handle) + nbio.close(client) + nbio.close(server) + } + + on_sendfile :: proc(op: ^nbio.Operation, t: ^testing.T, server: net.TCP_Socket) { + log.error("on_sendfile shouldn't be called") + } + } + + // Client + { + nbio.dial_poly(ep, t, on_dial) + + on_dial :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.dial.err, nil) + + buf := make([]byte, 128, context.temp_allocator) + nbio.recv_poly(op.dial.socket, {buf}, t, on_recv) + } + + on_recv :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.recv.err, nil) + + nbio.close(op.recv.socket.(net.TCP_Socket)) + } + } + + ev(t, nbio.run(), nil) + } +} + +@(test) +immediate_remove_of_sendfile_without_stat :: proc(t: ^testing.T) { + if event_loop_guard(t) { + testing.set_fail_timeout(t, time.Minute) + + sock, ep := open_next_available_local_port(t) + + // Server + { + nbio.accept_poly(sock, t, on_accept) + + on_accept :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.accept.err, nil) + e(t, op.accept.client != 0) + + log.debugf("connection from: %v", op.accept.client_endpoint) + nbio.open_poly3(#file, t, op.accept.socket, op.accept.client, on_open) + } + + on_open :: proc(op: ^nbio.Operation, t: ^testing.T, server, client: net.TCP_Socket) { + ev(t, op.open.err, nil) + e(t, op.open.handle != 0) + + nbio.stat_poly3(op.open.handle, t, server, client, on_stat) + } + + on_stat :: proc(op: ^nbio.Operation, t: ^testing.T, server, client: net.TCP_Socket) { + ev(t, op.stat.err, nil) + + sendfile_op := nbio.sendfile_poly2(client, op.stat.handle, t, server, on_sendfile, nbytes=int(op.stat.size)) + + // oh no changed my mind. + nbio.remove(sendfile_op) + + nbio.timeout_poly3(time.Millisecond * 10, op.stat.handle, client, server, proc(op: ^nbio.Operation, p1: nbio.Handle, p2, p3: net.TCP_Socket){ + nbio.close(p1) + nbio.close(p2) + nbio.close(p3) + }) + } + + on_sendfile :: proc(op: ^nbio.Operation, t: ^testing.T, server: net.TCP_Socket) { + log.error("on_sendfile shouldn't be called") + } + } + + // Client + { + nbio.dial_poly(ep, t, on_dial) + + on_dial :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.dial.err, nil) + + buf := make([]byte, 128, context.temp_allocator) + nbio.recv_poly(op.dial.socket, {buf}, t, on_recv) + } + + on_recv :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.recv.err, nil) + + nbio.close(op.recv.socket.(net.TCP_Socket)) + } + } + + ev(t, nbio.run(), nil) + } +} + +// Open should free the temporary memory allocated for the path when removed. +// Can't really test that though, so should be checked manually that the internal callback is called but not the external. +@(test) +remove_open :: proc(t: ^testing.T) { + if event_loop_guard(t) { + testing.set_fail_timeout(t, time.Minute) + + open := nbio.open(#file, on_open) + nbio.remove(open) + + on_open :: proc(op: ^nbio.Operation) { + log.error("on_open shouldn't be called") + } + + ev(t, nbio.run(), nil) + } +} + +// Dial should close the socket when removed. +// Can't really test that though, so should be checked manually that the internal callback is called but not the external. +@(test) +remove_dial :: proc(t: ^testing.T) { + if event_loop_guard(t) { + testing.set_fail_timeout(t, time.Minute) + + sock, ep := open_next_available_local_port(t) + defer nbio.close(sock) + + dial := nbio.dial(ep, on_dial) + nbio.remove(dial) + + on_dial :: proc(op: ^nbio.Operation) { + log.error("on_dial shouldn't be called") + } + + ev(t, nbio.run(), nil) + } +} + +@(test) +remove_next_tick :: proc(t: ^testing.T) { + if event_loop_guard(t) { + testing.set_fail_timeout(t, time.Minute) + + nt := nbio.next_tick_poly(t, proc(op: ^nbio.Operation, t: ^testing.T) { + log.error("shouldn't be called") + }) + nbio.remove(nt) + + ev(t, nbio.run(), nil) + } +} + +@(test) +remove_timeout :: proc(t: ^testing.T) { + if event_loop_guard(t) { + testing.set_fail_timeout(t, time.Minute) + + hit: bool + timeout := nbio.timeout_poly(time.Second, &hit, proc(_: ^nbio.Operation, hit: ^bool) { + hit^ = true + }) + + nbio.remove(timeout) + + ev(t, nbio.run(), nil) + + e(t, !hit) + } +} + +@(test) +remove_multiple_poll :: proc(t: ^testing.T) { + if event_loop_guard(t) { + testing.set_fail_timeout(t, time.Minute) + + sock, ep := open_next_available_local_port(t) + defer nbio.close(sock) + + hit: bool + + first := nbio.poll(sock, .Receive, on_poll) + nbio.poll_poly2(sock, .Receive, t, &hit, on_poll2) + + on_poll :: proc(op: ^nbio.Operation) { + log.error("shouldn't be called") + } + + on_poll2 :: proc(op: ^nbio.Operation, t: ^testing.T, hit: ^bool) { + ev(t, op.poll.result, nbio.Poll_Result.Ready) + hit^ = true + } + + ev(t, nbio.tick(0), nil) + + nbio.remove(first) + + ev(t, nbio.tick(0), nil) + + nbio.dial_poly(ep, t, on_dial) + + on_dial :: proc(op: ^nbio.Operation, t: ^testing.T) { + ev(t, op.dial.err, nil) + } + + ev(t, nbio.run(), nil) + e(t, hit) + } +} diff --git a/tests/core/net/test_core_net.odin b/tests/core/net/test_core_net.odin index ec45744f3..55fe6671d 100644 --- a/tests/core/net/test_core_net.odin +++ b/tests/core/net/test_core_net.odin @@ -10,8 +10,6 @@ A test suite for `core:net` */ -#+build !netbsd -#+build !openbsd #+feature dynamic-literals package test_core_net @@ -624,6 +622,41 @@ test_nonblocking_option :: proc(t: ^testing.T) { } } +// Test that when the server closes it's connection, the client's next receive is `0, nil` to indicate a correct close. +@(test) +test_connection_close :: proc(t: ^testing.T) { + server, listen_err := net.listen_tcp({address=net.IP4_Address{127, 0, 0, 1}, port=0}) + testing.expect_value(t, listen_err, nil) + defer net.close(server) + + server_ep, bound_endpoint_err := net.bound_endpoint(server) + testing.expect_value(t, bound_endpoint_err, nil) + + client, dial_err := net.dial_tcp(server_ep) + testing.expect_value(t, dial_err, nil) + defer net.close(client) + + server_client, _, accept_err := net.accept_tcp(server) + testing.expect_value(t, accept_err, nil) + + send_buf: [512]byte = 1 + sent, send_err := net.send(server_client, send_buf[:]) + testing.expect_value(t, sent, 512) + testing.expect_value(t, send_err, nil) + net.close(server_client) + + recv_buf: [512]byte = --- + received, recv_err := net.recv(client, recv_buf[:]) + testing.expect_value(t, received, 512) + testing.expect_value(t, recv_err, nil) + + testing.expect_value(t, recv_buf, send_buf) + + received, recv_err = net.recv(client, recv_buf[:]) + testing.expect_value(t, received, 0) + testing.expect_value(t, recv_err, nil) +} + @(private) address_to_binstr :: proc(address: net.Address) -> (binstr: string) { switch t in address { diff --git a/tests/core/normal.odin b/tests/core/normal.odin index e8b61fee8..d0889bf89 100644 --- a/tests/core/normal.odin +++ b/tests/core/normal.odin @@ -32,6 +32,7 @@ download_assets :: proc "contextless" () { @(require) import "math/noise" @(require) import "math/rand" @(require) import "mem" +@(require) import "nbio" @(require) import "net" @(require) import "odin" @(require) import "os" @@ -45,6 +46,7 @@ download_assets :: proc "contextless" () { @(require) import "sync" @(require) import "sync/chan" @(require) import "sys/posix" +@(require) import "sys/kqueue" @(require) import "sys/windows" @(require) import "text/i18n" @(require) import "text/match" diff --git a/tests/core/sys/kqueue/structs.odin b/tests/core/sys/kqueue/structs.odin new file mode 100644 index 000000000..edf1fdd1e --- /dev/null +++ b/tests/core/sys/kqueue/structs.odin @@ -0,0 +1,56 @@ +#+build darwin, freebsd, openbsd, netbsd +package tests_core_sys_kqueue + +import "core:strings" +import "core:testing" +import os "core:os/os2" + +@(test) +structs :: proc(t: ^testing.T) { + { + c_compiler := os.get_env("CC", context.temp_allocator) + if c_compiler == "" { + c_compiler = "clang" + } + + c_compilation, c_start_err := os.process_start({ + command = {c_compiler, #directory + "/structs/structs.c", "-o", #directory + "/structs/c_structs"}, + stdout = os.stdout, + stderr = os.stderr, + }) + testing.expect_value(t, c_start_err, nil) + + o_compilation, o_start_err := os.process_start({ + command = {ODIN_ROOT + "/odin", "build", #directory + "/structs", "-out:" + #directory + "/structs/odin_structs"}, + stdout = os.stdout, + stderr = os.stderr, + }) + testing.expect_value(t, o_start_err, nil) + + c_status, c_err := os.process_wait(c_compilation) + testing.expect_value(t, c_err, nil) + testing.expect_value(t, c_status.exit_code, 0) + + o_status, o_err := os.process_wait(o_compilation) + testing.expect_value(t, o_err, nil) + testing.expect_value(t, o_status.exit_code, 0) + } + + c_status, c_stdout, c_stderr, c_err := os.process_exec({command={#directory + "/structs/c_structs"}}, context.temp_allocator) + testing.expect_value(t, c_err, nil) + testing.expect_value(t, c_status.exit_code, 0) + testing.expect_value(t, string(c_stderr), "") + + o_status, o_stdout, o_stderr, o_err := os.process_exec({command={#directory + "/structs/odin_structs"}}, context.temp_allocator) + testing.expect_value(t, o_err, nil) + testing.expect_value(t, o_status.exit_code, 0) + testing.expect_value(t, string(o_stderr), "") + + testing.expect(t, strings.trim_space(string(c_stdout)) != "") + + testing.expect_value( + t, + strings.trim_space(string(o_stdout)), + strings.trim_space(string(c_stdout)), + ) +} diff --git a/tests/core/sys/kqueue/structs/structs.c b/tests/core/sys/kqueue/structs/structs.c new file mode 100644 index 000000000..e7620c994 --- /dev/null +++ b/tests/core/sys/kqueue/structs/structs.c @@ -0,0 +1,63 @@ +#include +#include +#include + +int main(int argc, char *argv[]) +{ + printf("kevent %zu %zu\n", sizeof(struct kevent), _Alignof(struct kevent)); + printf("kevent.ident %zu\n", offsetof(struct kevent, ident)); + printf("kevent.filter %zu\n", offsetof(struct kevent, filter)); + printf("kevent.flags %zu\n", offsetof(struct kevent, flags)); + printf("kevent.fflags %zu\n", offsetof(struct kevent, fflags)); + printf("kevent.data %zu\n", offsetof(struct kevent, data)); + printf("kevent.udata %zu\n", offsetof(struct kevent, udata)); + + printf("EV_ADD %d\n", EV_ADD); + printf("EV_DELETE %d\n", EV_DELETE); + printf("EV_ENABLE %d\n", EV_ENABLE); + printf("EV_DISABLE %d\n", EV_DISABLE); + printf("EV_ONESHOT %d\n", EV_ONESHOT); + printf("EV_CLEAR %d\n", EV_CLEAR); + printf("EV_RECEIPT %d\n", EV_RECEIPT); + printf("EV_DISPATCH %d\n", EV_DISPATCH); + printf("EV_ERROR %d\n", EV_ERROR); + printf("EV_EOF %d\n", EV_EOF); + + printf("EVFILT_READ %d\n", EVFILT_READ); + printf("EVFILT_WRITE %d\n", EVFILT_WRITE); + printf("EVFILT_AIO %d\n", EVFILT_AIO); + printf("EVFILT_VNODE %d\n", EVFILT_VNODE); + printf("EVFILT_PROC %d\n", EVFILT_PROC); + printf("EVFILT_SIGNAL %d\n", EVFILT_SIGNAL); + printf("EVFILT_TIMER %d\n", EVFILT_TIMER); + printf("EVFILT_USER %d\n", EVFILT_USER); + + printf("NOTE_SECONDS %u\n", NOTE_SECONDS); + printf("NOTE_USECONDS %u\n", NOTE_USECONDS); + printf("NOTE_NSECONDS %u\n", NOTE_NSECONDS); +#if defined(NOTE_ABSOLUTE) + printf("NOTE_ABSOLUTE %u\n", NOTE_ABSOLUTE); +#else + printf("NOTE_ABSOLUTE %u\n", NOTE_ABSTIME); +#endif + + printf("NOTE_LOWAT %u\n", NOTE_LOWAT); + + printf("NOTE_DELETE %u\n", NOTE_DELETE); + printf("NOTE_WRITE %u\n", NOTE_WRITE); + printf("NOTE_EXTEND %u\n", NOTE_EXTEND); + printf("NOTE_ATTRIB %u\n", NOTE_ATTRIB); + printf("NOTE_LINK %u\n", NOTE_LINK); + printf("NOTE_RENAME %u\n", NOTE_RENAME); + printf("NOTE_REVOKE %u\n", NOTE_REVOKE); + + printf("NOTE_EXIT %u\n", NOTE_EXIT); + printf("NOTE_FORK %u\n", NOTE_FORK); + printf("NOTE_EXEC %u\n", NOTE_EXEC); + + printf("NOTE_TRIGGER %u\n", NOTE_TRIGGER); + printf("NOTE_FFAND %u\n", NOTE_FFAND); + printf("NOTE_FFOR %u\n", NOTE_FFOR); + printf("NOTE_FFCOPY %u\n", NOTE_FFCOPY); + return 0; +} diff --git a/tests/core/sys/kqueue/structs/structs.odin b/tests/core/sys/kqueue/structs/structs.odin new file mode 100644 index 000000000..4886f63e4 --- /dev/null +++ b/tests/core/sys/kqueue/structs/structs.odin @@ -0,0 +1,58 @@ +package main + +import "core:fmt" +import "core:sys/kqueue" + +main :: proc() { + fmt.println("kevent", size_of(kqueue.KEvent), align_of(kqueue.KEvent)) + fmt.println("kevent.ident", offset_of(kqueue.KEvent, ident)) + fmt.println("kevent.filter", offset_of(kqueue.KEvent, filter)) + fmt.println("kevent.flags", offset_of(kqueue.KEvent, flags)) + fmt.println("kevent.fflags", offset_of(kqueue.KEvent, fflags)) + fmt.println("kevent.data", offset_of(kqueue.KEvent, data)) + fmt.println("kevent.udata", offset_of(kqueue.KEvent, udata)) + + fmt.println("EV_ADD", transmute(kqueue._Flags_Backing)kqueue.Flags{.Add}) + fmt.println("EV_DELETE", transmute(kqueue._Flags_Backing)kqueue.Flags{.Delete}) + fmt.println("EV_ENABLE", transmute(kqueue._Flags_Backing)kqueue.Flags{.Enable}) + fmt.println("EV_DISABLE", transmute(kqueue._Flags_Backing)kqueue.Flags{.Disable}) + fmt.println("EV_ONESHOT", transmute(kqueue._Flags_Backing)kqueue.Flags{.One_Shot}) + fmt.println("EV_CLEAR", transmute(kqueue._Flags_Backing)kqueue.Flags{.Clear}) + fmt.println("EV_RECEIPT", transmute(kqueue._Flags_Backing)kqueue.Flags{.Receipt}) + fmt.println("EV_DISPATCH", transmute(kqueue._Flags_Backing)kqueue.Flags{.Dispatch}) + fmt.println("EV_ERROR", transmute(kqueue._Flags_Backing)kqueue.Flags{.Error}) + fmt.println("EV_EOF", transmute(kqueue._Flags_Backing)kqueue.Flags{.EOF}) + + fmt.println("EVFILT_READ", int(kqueue.Filter.Read)) + fmt.println("EVFILT_WRITE", int(kqueue.Filter.Write)) + fmt.println("EVFILT_AIO", int(kqueue.Filter.AIO)) + fmt.println("EVFILT_VNODE", int(kqueue.Filter.VNode)) + fmt.println("EVFILT_PROC", int(kqueue.Filter.Proc)) + fmt.println("EVFILT_SIGNAL", int(kqueue.Filter.Signal)) + fmt.println("EVFILT_TIMER", int(kqueue.Filter.Timer)) + fmt.println("EVFILT_USER", int(kqueue.Filter.User)) + + fmt.println("NOTE_SECONDS", transmute(u32)kqueue.Timer_Flags{.Seconds}) + fmt.println("NOTE_USECONDS", transmute(u32)kqueue.Timer_Flags{.USeconds}) + fmt.println("NOTE_NSECONDS", transmute(u32)kqueue.TIMER_FLAGS_NSECONDS) + fmt.println("NOTE_ABSOLUTE", transmute(u32)kqueue.Timer_Flags{.Absolute}) + + fmt.println("NOTE_LOWAT", transmute(u32)kqueue.RW_Flags{.Low_Water_Mark}) + + fmt.println("NOTE_DELETE", transmute(u32)kqueue.VNode_Flags{.Delete}) + fmt.println("NOTE_WRITE", transmute(u32)kqueue.VNode_Flags{.Write}) + fmt.println("NOTE_EXTEND", transmute(u32)kqueue.VNode_Flags{.Extend}) + fmt.println("NOTE_ATTRIB", transmute(u32)kqueue.VNode_Flags{.Attrib}) + fmt.println("NOTE_LINK", transmute(u32)kqueue.VNode_Flags{.Link}) + fmt.println("NOTE_RENAME", transmute(u32)kqueue.VNode_Flags{.Rename}) + fmt.println("NOTE_REVOKE", transmute(u32)kqueue.VNode_Flags{.Revoke}) + + fmt.println("NOTE_EXIT", transmute(u32)kqueue.Proc_Flags{.Exit}) + fmt.println("NOTE_FORK", transmute(u32)kqueue.Proc_Flags{.Fork}) + fmt.println("NOTE_EXEC", transmute(u32)kqueue.Proc_Flags{.Exec}) + + fmt.println("NOTE_TRIGGER", transmute(u32)kqueue.User_Flags{.Trigger}) + fmt.println("NOTE_FFAND", transmute(u32)kqueue.User_Flags{.FFAnd}) + fmt.println("NOTE_FFOR", transmute(u32)kqueue.User_Flags{.FFOr}) + fmt.println("NOTE_FFCOPY", transmute(u32)kqueue.USER_FLAGS_COPY) +} diff --git a/tests/internal/test_imported_proc_groups.odin b/tests/internal/test_imported_proc_groups.odin new file mode 100644 index 000000000..e91af4bf5 --- /dev/null +++ b/tests/internal/test_imported_proc_groups.odin @@ -0,0 +1,11 @@ +package test_internal + +import "core:testing" +import "test_imported_proc_groups" + +// https://github.com/odin-lang/Odin/pull/6119 +@test +test_use_imported_proc_group_as_argument :: proc(t: ^testing.T) { + use_proc :: proc(proc()) { } + use_proc(test_imported_proc_groups.proc_group) +} diff --git a/tests/internal/test_imported_proc_groups/proc_group.odin b/tests/internal/test_imported_proc_groups/proc_group.odin new file mode 100644 index 000000000..59519ab9c --- /dev/null +++ b/tests/internal/test_imported_proc_groups/proc_group.odin @@ -0,0 +1,4 @@ +package test_imported_proc_groups + +proc_group :: proc{empty_proc} +empty_proc :: proc() { } diff --git a/tests/issues/run.bat b/tests/issues/run.bat index bbd7cbc90..f17f646a6 100644 --- a/tests/issues/run.bat +++ b/tests/issues/run.bat @@ -26,6 +26,9 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused ..\..\..\odin build ..\test_issue_5097-2.odin %COMMON% || exit /b ..\..\..\odin build ..\test_issue_5265.odin %COMMON% || exit /b ..\..\..\odin test ..\test_issue_5699.odin %COMMON% || exit /b +..\..\..\odin test ..\test_issue_6068.odin %COMMON% || exit /b +..\..\..\odin test ..\test_issue_6101.odin %COMMON% || exit /b +..\..\..\odin test ..\test_issue_6165.odin %COMMON% || exit /b @echo off diff --git a/tests/issues/run.sh b/tests/issues/run.sh index a9a4bb88d..73d0d9587 100755 --- a/tests/issues/run.sh +++ b/tests/issues/run.sh @@ -33,7 +33,9 @@ $ODIN build ../test_issue_5097.odin $COMMON $ODIN build ../test_issue_5097-2.odin $COMMON $ODIN build ../test_issue_5265.odin $COMMON $ODIN test ../test_issue_5699.odin $COMMON - +$ODIN test ../test_issue_6068.odin $COMMON +$ODIN test ../test_issue_6101.odin $COMMON +$ODIN test ../test_issue_6165.odin $COMMON set +x popd diff --git a/tests/issues/test_issue_6068.odin b/tests/issues/test_issue_6068.odin new file mode 100644 index 000000000..88a21ee27 --- /dev/null +++ b/tests/issues/test_issue_6068.odin @@ -0,0 +1,92 @@ +// Tests issue #6068 https://github.com/odin-lang/Odin/issues/6068 +package test_issues + +import "core:testing" + +@test +test_issue_6068 :: proc(t: ^testing.T) { + { + check_be : i128be = -1 + check_le : i128le = -1 + value := -1 + reverse := i128be(value) + + // test variable + testing.expect(t, i128be(value) == check_be) + testing.expect(t, i128be(-1) == check_be) + testing.expect(t, cast(i128be)value == check_be) + testing.expect(t, cast(i128be)-1 == check_be) + testing.expect(t, i128be(int(-1)) == check_be) + testing.expect(t, cast(i128be)int(-1) == check_be) + testing.expect(t, i128le(value) == check_le) + testing.expect(t, i128le(-1) == check_le) + testing.expect(t, cast(i128le)value == check_le) + testing.expect(t, cast(i128le)-1 == check_le) + testing.expect(t, i128le(int(-1)) == check_le) + testing.expect(t, cast(i128le)int(-1) == check_le) + testing.expect(t, i128le(reverse) == check_le) + testing.expect(t, cast(i128le)reverse == check_le) + + // test literal + testing.expect(t, i128be(value) == -1) + testing.expect(t, i128be(-1) == -1) + testing.expect(t, cast(i128be)value == -1) + testing.expect(t, cast(i128be)-1 == -1) + testing.expect(t, i128be(int(-1)) == -1) + testing.expect(t, cast(i128be)int(-1) == -1) + testing.expect(t, i128le(value) == -1) + testing.expect(t, i128le(-1) == -1) + testing.expect(t, cast(i128le)value == -1) + testing.expect(t, cast(i128le)-1 == -1) + testing.expect(t, i128le(int(-1)) == -1) + testing.expect(t, cast(i128le)int(-1) == -1) + testing.expect(t, i128le(reverse) == -1) + testing.expect(t, cast(i128le)reverse == -1) + } + + // NOTE(ske): [llvm_backend_const.cpp:lb_big_int_to_llvm] + // floats behaved wonky when I tested because I forgot to sign extend whole + // rop so I added more tests here to be safe + { + check_be : f64be = -1.234 + check_le : f64le = -1.234 + value : f64 = -1.234 + reverse := f64be(value) + + // test variable + testing.expect(t, f64be(value) == check_be) + testing.expect(t, f64be(-1.234) == check_be) + testing.expect(t, cast(f64be)value == check_be) + testing.expect(t, cast(f64be)-1.234 == check_be) + testing.expect(t, f64be(f64(-1.234)) == check_be) + testing.expect(t, cast(f64be)f64(-1.234) == check_be) + testing.expect(t, f64le(value) == check_le) + testing.expect(t, f64le(-1.234) == check_le) + testing.expect(t, cast(f64le)value == check_le) + testing.expect(t, cast(f64le)-1.234 == check_le) + testing.expect(t, f64le(f64(-1.234)) == check_le) + testing.expect(t, cast(f64le)f64(-1.234) == check_le) + testing.expect(t, f64le(reverse) == check_le) + testing.expect(t, cast(f64le)reverse == check_le) + + // test literal + testing.expect(t, f64be(value) == -1.234) + testing.expect(t, f64be(-1.234) == -1.234) + testing.expect(t, cast(f64be)value == -1.234) + testing.expect(t, cast(f64be)-1.234 == -1.234) + testing.expect(t, f64be(f64(-1.234)) == -1.234) + testing.expect(t, cast(f64be)f64(-1.234) == -1.234) + testing.expect(t, f64le(value) == -1.234) + testing.expect(t, f64le(-1.234) == -1.234) + testing.expect(t, cast(f64le)value == -1.234) + testing.expect(t, cast(f64le)-1.234 == -1.234) + testing.expect(t, f64le(f64(-1.234)) == -1.234) + testing.expect(t, cast(f64le)f64(-1.234) == -1.234) + testing.expect(t, f64le(reverse) == -1.234) + testing.expect(t, cast(f64le)reverse == -1.234) + } + + testing.expect(t, i64be(-1) + i64be(1) == 0) + testing.expect(t, i64le(-1) + i64le(i64be(1)) == 0) + testing.expect(t, i64be(-7) * i64be(7) == -49) +} diff --git a/tests/issues/test_issue_6101.odin b/tests/issues/test_issue_6101.odin new file mode 100644 index 000000000..9f24ade52 --- /dev/null +++ b/tests/issues/test_issue_6101.odin @@ -0,0 +1,23 @@ +// Tests issue #6101 https://github.com/odin-lang/Odin/issues/6101 +package test_issues + +import "core:testing" + +@(test) +test_issue_6101_bmp :: proc(t: ^testing.T) { + s := string16("\u732b") + testing.expect_value(t, len(s), 1) + + u := transmute([]u16)s + testing.expect_value(t, u[0], 0x732b) +} + +@(test) +test_issue_6101_non_bmp :: proc(t: ^testing.T) { + s := string16("\U0001F63A") + testing.expect_value(t, len(s), 2) + + u := transmute([]u16)s + testing.expect_value(t, u[0], 0xD83D) + testing.expect_value(t, u[1], 0xDE3A) +} diff --git a/tests/issues/test_issue_6165.odin b/tests/issues/test_issue_6165.odin new file mode 100644 index 000000000..b16995f0e --- /dev/null +++ b/tests/issues/test_issue_6165.odin @@ -0,0 +1,13 @@ +// Tests issue #6165 https://github.com/odin-lang/Odin/issues/6165 +package test_issues + +import "core:testing" + +@(test) +test_issue_6165 :: proc(t: ^testing.T) { + TXT :: #load(ODIN_ROOT + "LICENSE") + + // We don't really care about the length. The test is whether this compiles, or + // if the compiler says it can't find the file we know to exist. + assert(len(TXT) > 0) +} \ No newline at end of file diff --git a/vendor/box2d/box2d_wasm.odin b/vendor/box2d/box2d_wasm.odin index 0fcaf753f..1bbe9b8bc 100644 --- a/vendor/box2d/box2d_wasm.odin +++ b/vendor/box2d/box2d_wasm.odin @@ -1,4 +1,4 @@ #+build wasm32, wasm64p32 package vendor_box2d -@(require) import _ "vendor:libc" +@(require) import _ "vendor:libc-shim" diff --git a/vendor/box2d/wasm.Makefile b/vendor/box2d/wasm.Makefile index 80dd2ba14..5cce30ad1 100644 --- a/vendor/box2d/wasm.Makefile +++ b/vendor/box2d/wasm.Makefile @@ -11,7 +11,7 @@ VERSION = 3.1.1 SRCS = $(wildcard box2d-$(VERSION)/src/*.c) OBJS_SIMD = $(SRCS:.c=_simd.o) OBJS = $(SRCS:.c=.o) -SYSROOT = $(shell odin root)/vendor/libc +SYSROOT = $(shell odin root)/vendor/libc-shim CFLAGS = -Ibox2d-$(VERSION)/include --target=wasm32 -D__EMSCRIPTEN__ -DNDEBUG -O3 --sysroot=$(SYSROOT) all: lib/box2d_wasm.o lib/box2d_wasm_simd.o diff --git a/vendor/cgltf/cgltf_wasm.odin b/vendor/cgltf/cgltf_wasm.odin index fb612b2ac..1404fc592 100644 --- a/vendor/cgltf/cgltf_wasm.odin +++ b/vendor/cgltf/cgltf_wasm.odin @@ -1,4 +1,4 @@ #+build wasm32, wasm64p32 package cgltf -@(require) import _ "vendor:libc" +@(require) import _ "vendor:libc-shim" diff --git a/vendor/cgltf/src/Makefile b/vendor/cgltf/src/Makefile index 0dd450ce0..f4dc8c12c 100644 --- a/vendor/cgltf/src/Makefile +++ b/vendor/cgltf/src/Makefile @@ -8,7 +8,7 @@ endif wasm: mkdir -p ../lib - $(CC) -c -Os --target=wasm32 --sysroot=$(shell odin root)/vendor/libc cgltf.c -o ../lib/cgltf_wasm.o + $(CC) -c -Os --target=wasm32 --sysroot=$(shell odin root)/vendor/libc-shim cgltf.c -o ../lib/cgltf_wasm.o unix: mkdir -p ../lib diff --git a/vendor/compress/lz4/lz4.odin b/vendor/compress/lz4/lz4.odin index 19476c8c4..f3b0fcb0d 100644 --- a/vendor/compress/lz4/lz4.odin +++ b/vendor/compress/lz4/lz4.odin @@ -4,6 +4,8 @@ package vendor_compress_lz4 when ODIN_OS == .Windows { @(extra_linker_flags="/NODEFAULTLIB:libcmt") foreign import lib { "lib/liblz4_static.lib", "system:ucrt.lib" } +} else { + foreign import lib "system:lz4" } import "core:c" diff --git a/vendor/curl/curl.odin b/vendor/curl/curl.odin index ce10c443f..41ecbcb75 100644 --- a/vendor/curl/curl.odin +++ b/vendor/curl/curl.odin @@ -14,15 +14,6 @@ when ODIN_OS == .Windows { "system:Ws2_32.lib", "system:iphlpapi.lib", } -} else when ODIN_OS == .Linux { - @(export) - foreign import lib { - "system:curl", - "system:mbedtls", - "system:mbedx509", - "system:mbedcrypto", - "system:z", - } } else when ODIN_OS == .Darwin { @(export) foreign import lib { @@ -32,6 +23,15 @@ when ODIN_OS == .Windows { "system:z", "system:SystemConfiguration.framework", } +} else { + @(export) + foreign import lib { + "system:curl", + "system:mbedtls", + "system:mbedx509", + "system:mbedcrypto", + "system:z", + } } off_t :: i64 diff --git a/vendor/directx/d3d11/d3d11.odin b/vendor/directx/d3d11/d3d11.odin index 835655bbf..517146c8a 100644 --- a/vendor/directx/d3d11/d3d11.odin +++ b/vendor/directx/d3d11/d3d11.odin @@ -20,6 +20,7 @@ BOOL :: dxgi.BOOL UINT :: dxgi.UINT INT :: dxgi.INT +LPCSTR :: windows.LPCSTR LPCWSTR :: windows.LPCWSTR RECT :: dxgi.RECT @@ -950,7 +951,7 @@ INPUT_CLASSIFICATION :: enum i32 { } INPUT_ELEMENT_DESC :: struct { - SemanticName: cstring, + SemanticName: LPCSTR, SemanticIndex: u32, Format: dxgi.FORMAT, InputSlot: u32, @@ -972,7 +973,7 @@ CULL_MODE :: enum i32 { SO_DECLARATION_ENTRY :: struct { Stream: u32, - SemanticName: cstring, + SemanticName: LPCSTR, SemanticIndex: u32, StartComponent: u8, ComponentCount: u8, @@ -2172,8 +2173,8 @@ IClassLinkage :: struct #raw_union { } IClassLinkage_VTable :: struct { using id3d11devicechild_vtable: IDeviceChild_VTable, - GetClassInstance: proc "system" (this: ^IClassLinkage, pClassInstanceName: cstring, InstanceIndex: u32, ppInstance: ^^IClassInstance) -> HRESULT, - CreateClassInstance: proc "system" (this: ^IClassLinkage, pClassTypeName: cstring, ConstantBufferOffset: u32, ConstantVectorOffset: u32, TextureOffset: u32, SamplerOffset: u32, ppInstance: ^^IClassInstance) -> HRESULT, + GetClassInstance: proc "system" (this: ^IClassLinkage, pClassInstanceName: LPCSTR, InstanceIndex: u32, ppInstance: ^^IClassInstance) -> HRESULT, + CreateClassInstance: proc "system" (this: ^IClassLinkage, pClassTypeName: LPCSTR, ConstantBufferOffset: u32, ConstantVectorOffset: u32, TextureOffset: u32, SamplerOffset: u32, ppInstance: ^^IClassInstance) -> HRESULT, } @@ -3407,7 +3408,7 @@ SHADER_VERSION_TYPE :: enum i32 { } SIGNATURE_PARAMETER_DESC :: struct { - SemanticName: cstring, + SemanticName: LPCSTR, SemanticIndex: u32, Register: u32, SystemValueType: NAME, @@ -3421,7 +3422,7 @@ SIGNATURE_PARAMETER_DESC :: struct { } SHADER_BUFFER_DESC :: struct { - Name: cstring, + Name: LPCSTR, Type: CBUFFER_TYPE, Variables: u32, Size: u32, @@ -3429,7 +3430,7 @@ SHADER_BUFFER_DESC :: struct { } SHADER_VARIABLE_DESC :: struct { - Name: cstring, + Name: LPCSTR, StartOffset: u32, Size: u32, uFlags: SHADER_VARIABLE_FLAGS, @@ -3448,12 +3449,12 @@ SHADER_TYPE_DESC :: struct { Elements: u32, Members: u32, Offset: u32, - Name: cstring, + Name: LPCSTR, } SHADER_DESC :: struct { Version: u32, - Creator: cstring, + Creator: LPCSTR, Flags: u32, ConstantBuffers: u32, @@ -3496,7 +3497,7 @@ SHADER_DESC :: struct { } SHADER_INPUT_BIND_DESC :: struct { - Name: cstring, + Name: LPCSTR, Type: SHADER_INPUT_TYPE, BindPoint: u32, BindCount: u32, @@ -3508,14 +3509,14 @@ SHADER_INPUT_BIND_DESC :: struct { } LIBRARY_DESC :: struct { - Creator: cstring, + Creator: LPCSTR, Flags: u32, FunctionCount: u32, } FUNCTION_DESC :: struct { Version: u32, - Creator: cstring, + Creator: LPCSTR, Flags: u32, ConstantBuffers: u32, @@ -3545,7 +3546,7 @@ FUNCTION_DESC :: struct { MinFeatureLevel: FEATURE_LEVEL, RequiredFeatureFlags: SHADER_REQUIRES_FLAGS, - Name: cstring, + Name: LPCSTR, FunctionParameterCount: i32, HasReturn: BOOL, Has10Level9VertexShader: BOOL, @@ -3553,8 +3554,8 @@ FUNCTION_DESC :: struct { } PARAMETER_DESC :: struct { - Name: cstring, - SemanticName: cstring, + Name: LPCSTR, + SemanticName: LPCSTR, Type: SHADER_VARIABLE_TYPE, Class: SHADER_VARIABLE_CLASS, Rows: u32, @@ -3576,8 +3577,8 @@ IShaderReflectionType :: struct { IShaderReflectionType_VTable :: struct { GetDesc: proc "system" (this: ^IShaderReflectionType, pDesc: ^SHADER_TYPE_DESC) -> HRESULT, GetMemberTypeByIndex: proc "system" (this: ^IShaderReflectionType, Index: u32) -> ^IShaderReflectionType, - GetMemberTypeByName: proc "system" (this: ^IShaderReflectionType, Name: cstring) -> ^IShaderReflectionType, - GetMemberTypeName: proc "system" (this: ^IShaderReflectionType, Index: u32) -> cstring, + GetMemberTypeByName: proc "system" (this: ^IShaderReflectionType, Name: LPCSTR) -> ^IShaderReflectionType, + GetMemberTypeName: proc "system" (this: ^IShaderReflectionType, Index: u32) -> LPCSTR, IsEqual: proc "system" (this: ^IShaderReflectionType, pType: ^IShaderReflectionType) -> HRESULT, GetSubType: proc "system" (this: ^IShaderReflectionType) -> ^IShaderReflectionType, GetBaseClass: proc "system" (this: ^IShaderReflectionType) -> ^IShaderReflectionType, @@ -3607,7 +3608,7 @@ IShaderReflectionConstantBuffer :: struct { IShaderReflectionConstantBuffer_VTable :: struct { GetDesc: proc "system" (this: ^IShaderReflectionConstantBuffer, pDesc: ^SHADER_BUFFER_DESC) -> HRESULT, GetVariableByIndex: proc "system" (this: ^IShaderReflectionConstantBuffer, Index: u32) -> ^IShaderReflectionVariable, - GetVariableByName: proc "system" (this: ^IShaderReflectionConstantBuffer, Name: cstring) -> ^IShaderReflectionVariable, + GetVariableByName: proc "system" (this: ^IShaderReflectionConstantBuffer, Name: LPCSTR) -> ^IShaderReflectionVariable, } @@ -3621,13 +3622,13 @@ IShaderReflection_VTable :: struct { using iunknown_vtable: IUnknown_VTable, GetDesc: proc "system" (this: ^IShaderReflection, pDesc: ^SHADER_DESC) -> HRESULT, GetConstantBufferByIndex: proc "system" (this: ^IShaderReflection, Index: u32) -> ^IShaderReflectionConstantBuffer, - GetConstantBufferByName: proc "system" (this: ^IShaderReflection, Name: cstring) -> ^IShaderReflectionConstantBuffer, + GetConstantBufferByName: proc "system" (this: ^IShaderReflection, Name: LPCSTR) -> ^IShaderReflectionConstantBuffer, GetResourceBindingDesc: proc "system" (this: ^IShaderReflection, ResourceIndex: u32, pDesc: ^SHADER_INPUT_BIND_DESC) -> HRESULT, GetInputParameterDesc: proc "system" (this: ^IShaderReflection, ParameterIndex: u32, pDesc: ^SIGNATURE_PARAMETER_DESC) -> HRESULT, GetOutputParameterDesc: proc "system" (this: ^IShaderReflection, ParameterIndex: u32, pDesc: ^SIGNATURE_PARAMETER_DESC) -> HRESULT, GetPatchConstantParameterDesc: proc "system" (this: ^IShaderReflection, ParameterIndex: u32, pDesc: ^SIGNATURE_PARAMETER_DESC) -> HRESULT, - GetVariableByName: proc "system" (this: ^IShaderReflection, Name: cstring) -> ^IShaderReflectionVariable, - GetResourceBindingDescByName: proc "system" (this: ^IShaderReflection, Name: cstring, pDesc: ^SHADER_INPUT_BIND_DESC) -> HRESULT, + GetVariableByName: proc "system" (this: ^IShaderReflection, Name: LPCSTR) -> ^IShaderReflectionVariable, + GetResourceBindingDescByName: proc "system" (this: ^IShaderReflection, Name: LPCSTR, pDesc: ^SHADER_INPUT_BIND_DESC) -> HRESULT, GetMovInstructionCount: proc "system" (this: ^IShaderReflection) -> u32, GetMovcInstructionCount: proc "system" (this: ^IShaderReflection) -> u32, GetConversionInstructionCount: proc "system" (this: ^IShaderReflection) -> u32, @@ -3661,10 +3662,10 @@ IFunctionReflection :: struct { IFunctionReflection_VTable :: struct { GetDesc: proc "system" (this: ^IFunctionReflection, pDesc: ^FUNCTION_DESC) -> HRESULT, GetConstantBufferByIndex: proc "system" (this: ^IFunctionReflection, BufferIndex: u32) -> ^IShaderReflectionConstantBuffer, - GetConstantBufferByName: proc "system" (this: ^IFunctionReflection, Name: cstring) -> ^IShaderReflectionConstantBuffer, + GetConstantBufferByName: proc "system" (this: ^IFunctionReflection, Name: LPCSTR) -> ^IShaderReflectionConstantBuffer, GetResourceBindingDesc: proc "system" (this: ^IFunctionReflection, ResourceIndex: u32, pDesc: ^SHADER_INPUT_BIND_DESC) -> HRESULT, - GetVariableByName: proc "system" (this: ^IFunctionReflection, Name: cstring) -> ^IShaderReflectionVariable, - GetResourceBindingDescByName: proc "system" (this: ^IFunctionReflection, Name: cstring, pDesc: ^SHADER_INPUT_BIND_DESC) -> HRESULT, + GetVariableByName: proc "system" (this: ^IFunctionReflection, Name: LPCSTR) -> ^IShaderReflectionVariable, + GetResourceBindingDescByName: proc "system" (this: ^IFunctionReflection, Name: LPCSTR, pDesc: ^SHADER_INPUT_BIND_DESC) -> HRESULT, GetFunctionParameter: proc "system" (this: ^IFunctionReflection, ParameterIndex: i32) -> ^IFunctionParameterReflection, } @@ -3691,7 +3692,7 @@ IFunctionLinkingGraph_VTable :: struct { CreateModuleInstance: proc "system" (this: ^IFunctionLinkingGraph, ppModuleInstance: ^^IModuleInstance, ppErrorBuffer: ^^IBlob) -> HRESULT, SetInputSignature: proc "system" (this: ^IFunctionLinkingGraph, pInputParameters: [^]PARAMETER_DESC, cInputParameters: u32, ppInputNode: ^^ILinkingNode) -> HRESULT, SetOutputSignature: proc "system" (this: ^IFunctionLinkingGraph, pOutputParameters: [^]PARAMETER_DESC, cOutputParameters: u32, ppOutputNode: ^^ILinkingNode) -> HRESULT, - CallFunction: proc "system" (this: ^IFunctionLinkingGraph, pModuleInstanceNamespace: cstring, pModuleWithFunctionPrototype: ^IModule, pFunctionName: cstring, ppCallNode: ^^ILinkingNode) -> HRESULT, + CallFunction: proc "system" (this: ^IFunctionLinkingGraph, pModuleInstanceNamespace: LPCSTR, pModuleWithFunctionPrototype: ^IModule, pFunctionName: LPCSTR, ppCallNode: ^^ILinkingNode) -> HRESULT, PassValue: proc "system" (this: ^IFunctionLinkingGraph, pSrcNode: ^ILinkingNode, SrcParameterIndex: i32, pDstNode: ^ILinkingNode, DstParameterIndex: i32) -> HRESULT, PassValueWithSwizzle: proc "system" (this: ^IFunctionLinkingGraph, pSrcNode: ^ILinkingNode, SrcParameterIndex: i32, pSrcSwizzle: ^u8, pDstNode: ^ILinkingNode, DstParameterIndex: i32, pDstSwizzle: ^u8) -> HRESULT, GetLastError: proc "system" (this: ^IFunctionLinkingGraph, ppErrorBuffer: ^^IBlob) -> HRESULT, @@ -3814,8 +3815,8 @@ IInfoQueue_VTable :: struct { PushRetrievalFilter: proc "system" (this: ^IInfoQueue, pFilter: ^INFO_QUEUE_FILTER) -> HRESULT, PopRetrievalFilter: proc "system" (this: ^IInfoQueue), GetRetrievalFilterStackSize: proc "system" (this: ^IInfoQueue) -> u64, - AddMessage: proc "system" (this: ^IInfoQueue, Category: MESSAGE_CATEGORY, Severity: MESSAGE_SEVERITY, ID: MESSAGE_ID, pDescription: cstring) -> HRESULT, - AddApplicationMessage: proc "system" (this: ^IInfoQueue, Severity: MESSAGE_SEVERITY, pDescription: cstring) -> HRESULT, + AddMessage: proc "system" (this: ^IInfoQueue, Category: MESSAGE_CATEGORY, Severity: MESSAGE_SEVERITY, ID: MESSAGE_ID, pDescription: LPCSTR) -> HRESULT, + AddApplicationMessage: proc "system" (this: ^IInfoQueue, Severity: MESSAGE_SEVERITY, pDescription: LPCSTR) -> HRESULT, SetBreakOnCategory: proc "system" (this: ^IInfoQueue, Category: MESSAGE_CATEGORY, bEnable: BOOL) -> HRESULT, SetBreakOnSeverity: proc "system" (this: ^IInfoQueue, Severity: MESSAGE_SEVERITY, bEnable: BOOL) -> HRESULT, SetBreakOnID: proc "system" (this: ^IInfoQueue, ID: MESSAGE_ID, bEnable: BOOL) -> HRESULT, diff --git a/vendor/directx/d3d12/d3d12.odin b/vendor/directx/d3d12/d3d12.odin index a0e020d1a..efa323733 100644 --- a/vendor/directx/d3d12/d3d12.odin +++ b/vendor/directx/d3d12/d3d12.odin @@ -23,6 +23,7 @@ BOOL :: dxgi.BOOL RECT :: dxgi.RECT +LPCSTR :: win32.LPCSTR LPCWSTR :: win32.LPCWSTR IModuleInstance :: d3d_compiler.ID3D11ModuleInstance @@ -467,7 +468,7 @@ INPUT_CLASSIFICATION :: enum i32 { } INPUT_ELEMENT_DESC :: struct { - SemanticName: cstring, + SemanticName: LPCSTR, SemanticIndex: u32, Format: dxgi.FORMAT, InputSlot: u32, @@ -489,7 +490,7 @@ CULL_MODE :: enum i32 { SO_DECLARATION_ENTRY :: struct { Stream: u32, - SemanticName: cstring, + SemanticName: LPCSTR, SemanticIndex: u32, StartComponent: u8, ComponentCount: u8, @@ -3153,13 +3154,13 @@ EXISTING_COLLECTION_DESC :: struct { SUBOBJECT_TO_EXPORTS_ASSOCIATION :: struct { pSubobjectToAssociate: ^STATE_SUBOBJECT, NumExports: u32, - pExports: [^]cstring16 `fmt:"v,NumExports"`, + pExports: [^]LPCWSTR `fmt:"v,NumExports"`, } DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION :: struct { - SubobjectToAssociate: cstring16, + SubobjectToAssociate: LPCWSTR, NumExports: u32, - pExports: [^]cstring16 `fmt:"v,NumExports"`, + pExports: [^]LPCWSTR `fmt:"v,NumExports"`, } HIT_GROUP_TYPE :: enum i32 { @@ -3168,11 +3169,11 @@ HIT_GROUP_TYPE :: enum i32 { } HIT_GROUP_DESC :: struct { - HitGroupExport: cstring16, + HitGroupExport: LPCWSTR, Type: HIT_GROUP_TYPE, - AnyHitShaderImport: cstring16, - ClosestHitShaderImport: cstring16, - IntersectionShaderImport: cstring16, + AnyHitShaderImport: LPCWSTR, + ClosestHitShaderImport: LPCWSTR, + IntersectionShaderImport: LPCWSTR, } RAYTRACING_SHADER_CONFIG :: struct { @@ -5222,8 +5223,8 @@ IInfoQueue_VTable :: struct { PushRetrievalFilter: proc "system" (this: ^IInfoQueue, pFilter: ^INFO_QUEUE_FILTER) -> HRESULT, PopRetrievalFilter: proc "system" (this: ^IInfoQueue), GetRetrievalFilterStackSize: proc "system" (this: ^IInfoQueue) -> u32, - AddMessage: proc "system" (this: ^IInfoQueue, Category: MESSAGE_CATEGORY, Severity: MESSAGE_SEVERITY, ID: MESSAGE_ID, pDescription: cstring) -> HRESULT, - AddApplicationMessage: proc "system" (this: ^IInfoQueue, Severity: MESSAGE_SEVERITY, pDescription: cstring) -> HRESULT, + AddMessage: proc "system" (this: ^IInfoQueue, Category: MESSAGE_CATEGORY, Severity: MESSAGE_SEVERITY, ID: MESSAGE_ID, pDescription: LPCSTR) -> HRESULT, + AddApplicationMessage: proc "system" (this: ^IInfoQueue, Severity: MESSAGE_SEVERITY, pDescription: LPCSTR) -> HRESULT, SetBreakOnCategory: proc "system" (this: ^IInfoQueue, Category: MESSAGE_CATEGORY, bEnable: BOOL) -> HRESULT, SetBreakOnSeverity: proc "system" (this: ^IInfoQueue, Severity: MESSAGE_SEVERITY, bEnable: BOOL) -> HRESULT, SetBreakOnID: proc "system" (this: ^IInfoQueue, ID: MESSAGE_ID, bEnable: BOOL) -> HRESULT, @@ -5239,7 +5240,7 @@ MESSAGE_CALLBACK_FLAG :: enum { IGNORE_FILTERS = 0, } -PFN_MESSAGE_CALLBACK :: #type proc "c" (Category: MESSAGE_CATEGORY, Severity: MESSAGE_SEVERITY, ID: MESSAGE_ID, pDescription: cstring, pContext: rawptr) +PFN_MESSAGE_CALLBACK :: #type proc "c" (Category: MESSAGE_CATEGORY, Severity: MESSAGE_SEVERITY, ID: MESSAGE_ID, pDescription: LPCSTR, pContext: rawptr) IInfoQueue1_UUID_STRING :: "2852dd88-b484-4c0c-b6b1-67168500e600" IInfoQueue1_UUID := &IID{0x2852dd88, 0xb484, 0x4c0c, {0xb6, 0xb1, 0x67, 0x16, 0x85, 0x00, 0xe6, 0x00}} @@ -5262,7 +5263,7 @@ ISDKConfiguration :: struct #raw_union { } ISDKConfiguration_VTable :: struct { using iunknown_vtable: IUnknown_VTable, - SetSDKVersion: proc "system" (this: ^ISDKConfiguration, SDKVersion: u32, SDKPath: cstring) -> HRESULT, + SetSDKVersion: proc "system" (this: ^ISDKConfiguration, SDKVersion: u32, SDKPath: LPCSTR) -> HRESULT, } @@ -5361,7 +5362,7 @@ shver_get_minor :: proc "contextless" (version: u32) -> u8 { } SIGNATURE_PARAMETER_DESC :: struct { - SemanticName: cstring, + SemanticName: LPCSTR, SemanticIndex: u32, Register: u32, SystemValueType: NAME, @@ -5375,7 +5376,7 @@ SIGNATURE_PARAMETER_DESC :: struct { } SHADER_BUFFER_DESC :: struct { - Name: cstring, + Name: LPCSTR, Type: CBUFFER_TYPE, Variables: u32, Size: u32, @@ -5383,7 +5384,7 @@ SHADER_BUFFER_DESC :: struct { } SHADER_VARIABLE_DESC :: struct { - Name: cstring, + Name: LPCSTR, StartOffset: u32, Size: u32, uFlags: u32, @@ -5402,12 +5403,12 @@ SHADER_TYPE_DESC :: struct { Elements: u32, Members: u32, Offset: u32, - Name: cstring, + Name: LPCSTR, } SHADER_DESC :: struct { Version: u32, - Creator: cstring, + Creator: LPCSTR, Flags: u32, ConstantBuffers: u32, @@ -5450,7 +5451,7 @@ SHADER_DESC :: struct { } SHADER_INPUT_BIND_DESC :: struct { - Name: cstring, + Name: LPCSTR, Type: SHADER_INPUT_TYPE, BindPoint: u32, BindCount: u32, @@ -5497,14 +5498,14 @@ SHADER_REQUIRES :: enum u64 { } LIBRARY_DESC :: struct { - Creator: cstring, + Creator: LPCSTR, Flags: u32, FunctionCount: u32, } FUNCTION_DESC :: struct { Version: u32, - Creator: cstring, + Creator: LPCSTR, Flags: u32, ConstantBuffers: u32, @@ -5534,7 +5535,7 @@ FUNCTION_DESC :: struct { MinFeatureLevel: FEATURE_LEVEL, RequiredFeatureFlags: u64, - Name: cstring, + Name: LPCSTR, FunctionParameterCount: i32, HasReturn: BOOL, Has10Level9VertexShader: BOOL, @@ -5542,8 +5543,8 @@ FUNCTION_DESC :: struct { } PARAMETER_DESC :: struct { - Name: cstring, - SemanticName: cstring, + Name: LPCSTR, + SemanticName: LPCSTR, Type: SHADER_VARIABLE_TYPE, Class: SHADER_VARIABLE_CLASS, Rows: u32, @@ -5565,8 +5566,8 @@ IShaderReflectionType :: struct { IShaderReflectionType_VTable :: struct { GetDesc: proc "system" (this: ^IShaderReflectionType, pDesc: ^SHADER_TYPE_DESC) -> HRESULT, GetMemberTypeByIndex: proc "system" (this: ^IShaderReflectionType, Index: u32) -> ^IShaderReflectionType, - GetMemberTypeByName: proc "system" (this: ^IShaderReflectionType, Name: cstring) -> ^IShaderReflectionType, - GetMemberTypeName: proc "system" (this: ^IShaderReflectionType, Index: u32) -> cstring, + GetMemberTypeByName: proc "system" (this: ^IShaderReflectionType, Name: LPCSTR) -> ^IShaderReflectionType, + GetMemberTypeName: proc "system" (this: ^IShaderReflectionType, Index: u32) -> LPCSTR, IsEqual: proc "system" (this: ^IShaderReflectionType, pType: ^IShaderReflectionType) -> HRESULT, GetSubType: proc "system" (this: ^IShaderReflectionType) -> ^IShaderReflectionType, GetBaseClass: proc "system" (this: ^IShaderReflectionType) -> ^IShaderReflectionType, @@ -5596,7 +5597,7 @@ IShaderReflectionConstantBuffer :: struct { IShaderReflectionConstantBuffer_VTable :: struct { GetDesc: proc "system" (this: ^IShaderReflectionConstantBuffer, pDesc: ^SHADER_BUFFER_DESC) -> HRESULT, GetVariableByIndex: proc "system" (this: ^IShaderReflectionConstantBuffer, Index: u32) -> ^IShaderReflectionVariable, - GetVariableByName: proc "system" (this: ^IShaderReflectionConstantBuffer, Name: cstring) -> ^IShaderReflectionVariable, + GetVariableByName: proc "system" (this: ^IShaderReflectionConstantBuffer, Name: LPCSTR) -> ^IShaderReflectionVariable, } IShaderReflection_UUID_STRING :: "5A58797D-A72C-478D-8BA2-EFC6B0EFE88E" @@ -5609,13 +5610,13 @@ IShaderReflection_VTable :: struct { using iunknown_vtable: IUnknown_VTable, GetDesc: proc "system" (this: ^IShaderReflection, pDesc: ^SHADER_DESC) -> HRESULT, GetConstantBufferByIndex: proc "system" (this: ^IShaderReflection, Index: u32) -> ^IShaderReflectionConstantBuffer, - GetConstantBufferByName: proc "system" (this: ^IShaderReflection, Name: cstring) -> ^IShaderReflectionConstantBuffer, + GetConstantBufferByName: proc "system" (this: ^IShaderReflection, Name: LPCSTR) -> ^IShaderReflectionConstantBuffer, GetResourceBindingDesc: proc "system" (this: ^IShaderReflection, ResourceIndex: u32, pDesc: ^SHADER_INPUT_BIND_DESC) -> HRESULT, GetInputParameterDesc: proc "system" (this: ^IShaderReflection, ParameterIndex: u32, pDesc: ^SIGNATURE_PARAMETER_DESC) -> HRESULT, GetOutputParameterDesc: proc "system" (this: ^IShaderReflection, ParameterIndex: u32, pDesc: ^SIGNATURE_PARAMETER_DESC) -> HRESULT, GetPatchConstantParameterDesc: proc "system" (this: ^IShaderReflection, ParameterIndex: u32, pDesc: ^SIGNATURE_PARAMETER_DESC) -> HRESULT, - GetVariableByName: proc "system" (this: ^IShaderReflection, Name: cstring) -> ^IShaderReflectionVariable, - GetResourceBindingDescByName: proc "system" (this: ^IShaderReflection, Name: cstring, pDesc: ^SHADER_INPUT_BIND_DESC) -> HRESULT, + GetVariableByName: proc "system" (this: ^IShaderReflection, Name: LPCSTR) -> ^IShaderReflectionVariable, + GetResourceBindingDescByName: proc "system" (this: ^IShaderReflection, Name: LPCSTR, pDesc: ^SHADER_INPUT_BIND_DESC) -> HRESULT, GetMovInstructionCount: proc "system" (this: ^IShaderReflection) -> u32, GetMovcInstructionCount: proc "system" (this: ^IShaderReflection) -> u32, GetConversionInstructionCount: proc "system" (this: ^IShaderReflection) -> u32, @@ -5648,10 +5649,10 @@ IFunctionReflection :: struct { IFunctionReflection_VTable :: struct { GetDesc: proc "system" (this: ^IFunctionReflection, pDesc: ^FUNCTION_DESC) -> HRESULT, GetConstantBufferByIndex: proc "system" (this: ^IFunctionReflection, BufferIndex: u32) -> ^IShaderReflectionConstantBuffer, - GetConstantBufferByName: proc "system" (this: ^IFunctionReflection, Name: cstring) -> ^IShaderReflectionConstantBuffer, + GetConstantBufferByName: proc "system" (this: ^IFunctionReflection, Name: LPCSTR) -> ^IShaderReflectionConstantBuffer, GetResourceBindingDesc: proc "system" (this: ^IFunctionReflection, ResourceIndex: u32, pDesc: ^SHADER_INPUT_BIND_DESC) -> HRESULT, - GetVariableByName: proc "system" (this: ^IFunctionReflection, Name: cstring) -> ^IShaderReflectionVariable, - GetResourceBindingDescByName: proc "system" (this: ^IFunctionReflection, Name: cstring, pDesc: ^SHADER_INPUT_BIND_DESC) -> HRESULT, + GetVariableByName: proc "system" (this: ^IFunctionReflection, Name: LPCSTR) -> ^IShaderReflectionVariable, + GetResourceBindingDescByName: proc "system" (this: ^IFunctionReflection, Name: LPCSTR, pDesc: ^SHADER_INPUT_BIND_DESC) -> HRESULT, GetFunctionParameter: proc "system" (this: ^IFunctionReflection, ParameterIndex: i32) -> ^IFunctionParameterReflection, } diff --git a/vendor/directx/d3d_compiler/d3d_compiler.odin b/vendor/directx/d3d_compiler/d3d_compiler.odin index 6f9f3fe89..17a835f23 100644 --- a/vendor/directx/d3d_compiler/d3d_compiler.odin +++ b/vendor/directx/d3d_compiler/d3d_compiler.odin @@ -2,6 +2,7 @@ package directx_d3d_compiler foreign import d3dcompiler "d3dcompiler_47.lib" +import win32 "core:sys/windows" D3DCOMPILER_DLL_A :: "d3dcompiler_47.dll" COMPILER_VERSION :: 47 @@ -16,19 +17,22 @@ HRESULT :: dxgi.HRESULT IUnknown :: dxgi.IUnknown IUnknown_VTable :: dxgi.IUnknown_VTable +LPCSTR :: win32.LPCSTR +LPCWSTR :: win32.LPCWSTR + @(default_calling_convention="system", link_prefix="D3D") foreign d3dcompiler { - ReadFileToBlob :: proc(pFileName: [^]u16, ppContents: ^^ID3DBlob) -> HRESULT --- - WriteBlobToFile :: proc(pBlob: ^ID3DBlob, pFileName: [^]u16, bOverwrite: BOOL) -> HRESULT --- - Compile :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, pSourceName: cstring, pDefines: ^SHADER_MACRO, pInclude: ^ID3DInclude, pEntrypoint: cstring, pTarget: cstring, Flags1: u32, Flags2: u32, ppCode: ^^ID3DBlob, ppErrorMsgs: ^^ID3DBlob) -> HRESULT --- - Compile2 :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, pSourceName: cstring, pDefines: ^SHADER_MACRO, pInclude: ^ID3DInclude, pEntrypoint: cstring, pTarget: cstring, Flags1: u32, Flags2: u32, SecondaryDataFlags: u32, pSecondaryData: rawptr, SecondaryDataSize: SIZE_T, ppCode: ^^ID3DBlob, ppErrorMsgs: ^^ID3DBlob) -> HRESULT --- - CompileFromFile :: proc(pFileName: [^]u16, pDefines: ^SHADER_MACRO, pInclude: ^ID3DInclude, pEntrypoint: cstring, pTarget: cstring, Flags1: u32, Flags2: u32, ppCode: ^^ID3DBlob, ppErrorMsgs: ^^ID3DBlob) -> HRESULT --- - Preprocess :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, pSourceName: cstring, pDefines: ^SHADER_MACRO, pInclude: ^ID3DInclude, ppCodeText: ^^ID3DBlob, ppErrorMsgs: ^^ID3DBlob) -> HRESULT --- + ReadFileToBlob :: proc(pFileName: LPCWSTR, ppContents: ^^ID3DBlob) -> HRESULT --- + WriteBlobToFile :: proc(pBlob: ^ID3DBlob, pFileName: LPCWSTR, bOverwrite: BOOL) -> HRESULT --- + Compile :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, pSourceName: LPCSTR, pDefines: ^SHADER_MACRO, pInclude: ^ID3DInclude, pEntrypoint: LPCSTR, pTarget: LPCSTR, Flags1: u32, Flags2: u32, ppCode: ^^ID3DBlob, ppErrorMsgs: ^^ID3DBlob) -> HRESULT --- + Compile2 :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, pSourceName: LPCSTR, pDefines: ^SHADER_MACRO, pInclude: ^ID3DInclude, pEntrypoint: LPCSTR, pTarget: LPCSTR, Flags1: u32, Flags2: u32, SecondaryDataFlags: u32, pSecondaryData: rawptr, SecondaryDataSize: SIZE_T, ppCode: ^^ID3DBlob, ppErrorMsgs: ^^ID3DBlob) -> HRESULT --- + CompileFromFile :: proc(pFileName: LPCWSTR, pDefines: ^SHADER_MACRO, pInclude: ^ID3DInclude, pEntrypoint: LPCSTR, pTarget: LPCSTR, Flags1: u32, Flags2: u32, ppCode: ^^ID3DBlob, ppErrorMsgs: ^^ID3DBlob) -> HRESULT --- + Preprocess :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, pSourceName: LPCSTR, pDefines: ^SHADER_MACRO, pInclude: ^ID3DInclude, ppCodeText: ^^ID3DBlob, ppErrorMsgs: ^^ID3DBlob) -> HRESULT --- GetDebugInfo :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, ppDebugInfo: ^^ID3DBlob) -> HRESULT --- Reflect :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, pInterface: ^IID, ppReflector: ^rawptr) -> HRESULT --- ReflectLibrary :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, riid: ^IID, ppReflector: ^rawptr) -> HRESULT --- - Disassemble :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, Flags: u32, szComments: cstring, ppDisassembly: ^^ID3DBlob) -> HRESULT --- - DisassembleRegion :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, Flags: u32, szComments: cstring, StartByteOffset: SIZE_T, NumInsts: SIZE_T, pFinishByteOffset: ^SIZE_T, ppDisassembly: ^^ID3DBlob) -> HRESULT --- + Disassemble :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, Flags: u32, szComments: LPCSTR, ppDisassembly: ^^ID3DBlob) -> HRESULT --- + DisassembleRegion :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, Flags: u32, szComments: LPCSTR, StartByteOffset: SIZE_T, NumInsts: SIZE_T, pFinishByteOffset: ^SIZE_T, ppDisassembly: ^^ID3DBlob) -> HRESULT --- CreateLinker :: proc(ppLinker: ^^ID3D11Linker) -> HRESULT --- LoadModule :: proc(pSrcData: rawptr, cbSrcDataSize: SIZE_T, ppModule: ^^ID3D11Module) -> HRESULT --- GetTraceInstructionOffsets :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, Flags: u32, StartInstIndex: SIZE_T, NumInsts: SIZE_T, pOffsets: ^SIZE_T, pTotalInsts: ^SIZE_T) -> HRESULT --- @@ -113,8 +117,8 @@ GET_INST_OFFSETS_INCLUDE_NON_EXECUTABLE :: 0x00000001 COMPRESS_SHADER_KEEP_ALL_PARTS :: 0x00000001 SHADER_MACRO :: struct { - Name: cstring, - Definition: cstring, + Name: LPCSTR, + Definition: LPCSTR, } ID3D10Blob_UUID_STRING :: "8BA5FB08-5195-40E2-AC58-0D989C3A0102" @@ -146,7 +150,7 @@ ID3DInclude :: struct { vtable: ^ID3DInclude_VTable, } ID3DInclude_VTable :: struct { - Open: proc "system" (this: ^ID3DInclude, IncludeType: INCLUDE_TYPE, pFileName: cstring, pParentData: rawptr, ppData: ^rawptr, pBytes: ^u32) -> HRESULT, + Open: proc "system" (this: ^ID3DInclude, IncludeType: INCLUDE_TYPE, pFileName: LPCSTR, pParentData: rawptr, ppData: ^rawptr, pBytes: ^u32) -> HRESULT, Close: proc "system" (this: ^ID3DInclude, pData: rawptr) -> HRESULT, } @@ -160,7 +164,7 @@ ID3D11Module :: struct #raw_union { } ID3D11Module_VTable :: struct { using iunknown_vtable: IUnknown_VTable, - CreateInstance: proc "system" (this: ^ID3D11Module, pNamespace: cstring, ppModuleInstance: ^^ID3D11ModuleInstance) -> HRESULT, + CreateInstance: proc "system" (this: ^ID3D11Module, pNamespace: LPCSTR, ppModuleInstance: ^^ID3D11ModuleInstance) -> HRESULT, } @@ -171,15 +175,15 @@ ID3D11ModuleInstance :: struct #raw_union { ID3D11ModuleInstance_VTable :: struct { using iunknown_vtable: IUnknown_VTable, BindConstantBuffer: proc "system" (this: ^ID3D11ModuleInstance, uSrcSlot: u32, uDstSlot: u32, cbDstOffset: u32) -> HRESULT, - BindConstantBufferByName: proc "system" (this: ^ID3D11ModuleInstance, pName: cstring, uDstSlot: u32, cbDstOffset: u32) -> HRESULT, + BindConstantBufferByName: proc "system" (this: ^ID3D11ModuleInstance, pName: LPCSTR, uDstSlot: u32, cbDstOffset: u32) -> HRESULT, BindResource: proc "system" (this: ^ID3D11ModuleInstance, uSrcSlot: u32, uDstSlot: u32, uCount: u32) -> HRESULT, - BindResourceByName: proc "system" (this: ^ID3D11ModuleInstance, pName: cstring, uDstSlot: u32, uCount: u32) -> HRESULT, + BindResourceByName: proc "system" (this: ^ID3D11ModuleInstance, pName: LPCSTR, uDstSlot: u32, uCount: u32) -> HRESULT, BindSampler: proc "system" (this: ^ID3D11ModuleInstance, uSrcSlot: u32, uDstSlot: u32, uCount: u32) -> HRESULT, - BindSamplerByName: proc "system" (this: ^ID3D11ModuleInstance, pName: cstring, uDstSlot: u32, uCount: u32) -> HRESULT, + BindSamplerByName: proc "system" (this: ^ID3D11ModuleInstance, pName: LPCSTR, uDstSlot: u32, uCount: u32) -> HRESULT, BindUnorderedAccessView: proc "system" (this: ^ID3D11ModuleInstance, uSrcSlot: u32, uDstSlot: u32, uCount: u32) -> HRESULT, - BindUnorderedAccessViewByName: proc "system" (this: ^ID3D11ModuleInstance, pName: cstring, uDstSlot: u32, uCount: u32) -> HRESULT, + BindUnorderedAccessViewByName: proc "system" (this: ^ID3D11ModuleInstance, pName: LPCSTR, uDstSlot: u32, uCount: u32) -> HRESULT, BindResourceAsUnorderedAccessView: proc "system" (this: ^ID3D11ModuleInstance, uSrcSrvSlot: u32, uDstUavSlot: u32, uCount: u32) -> HRESULT, - BindResourceAsUnorderedAccessViewByName: proc "system" (this: ^ID3D11ModuleInstance, pSrvName: cstring, uDstUavSlot: u32, uCount: u32) -> HRESULT, + BindResourceAsUnorderedAccessViewByName: proc "system" (this: ^ID3D11ModuleInstance, pSrvName: LPCSTR, uDstUavSlot: u32, uCount: u32) -> HRESULT, } @@ -189,15 +193,15 @@ ID3D11Linker :: struct #raw_union { } ID3D11Linker_VTable :: struct { using iunknown_vtable: IUnknown_VTable, - Link: proc "system" (this: ^ID3D11Linker, pEntry: ^ID3D11ModuleInstance, pEntryName: cstring, pTargetName: cstring, uFlags: u32, ppShaderBlob: ^^ID3DBlob, ppErrorBuffer: ^^ID3DBlob) -> HRESULT, + Link: proc "system" (this: ^ID3D11Linker, pEntry: ^ID3D11ModuleInstance, pEntryName: LPCSTR, pTargetName: LPCSTR, uFlags: u32, ppShaderBlob: ^^ID3DBlob, ppErrorBuffer: ^^ID3DBlob) -> HRESULT, UseLibrary: proc "system" (this: ^ID3D11Linker, pLibraryMI: ^ID3D11ModuleInstance) -> HRESULT, AddClipPlaneFromCBuffer: proc "system" (this: ^ID3D11Linker, uCBufferSlot: u32, uCBufferEntry: u32) -> HRESULT, } -pD3DCompile :: #type proc "c" (a0: rawptr, a1: SIZE_T, a2: cstring, a3: ^SHADER_MACRO, a4: ^ID3DInclude, a5: cstring, a6: cstring, a7: u32, a8: u32, a9: ^^ID3DBlob, a10: ^^ID3DBlob) -> HRESULT -pD3DPreprocess :: #type proc "c" (a0: rawptr, a1: SIZE_T, a2: cstring, a3: ^SHADER_MACRO, a4: ^ID3DInclude, a5: ^^ID3DBlob, a6: ^^ID3DBlob) -> HRESULT -pD3DDisassemble :: #type proc "c" (a0: rawptr, a1: SIZE_T, a2: u32, a3: cstring, a4: ^^ID3DBlob) -> HRESULT +pD3DCompile :: #type proc "c" (a0: rawptr, a1: SIZE_T, a2: LPCSTR, a3: ^SHADER_MACRO, a4: ^ID3DInclude, a5: LPCSTR, a6: LPCSTR, a7: u32, a8: u32, a9: ^^ID3DBlob, a10: ^^ID3DBlob) -> HRESULT +pD3DPreprocess :: #type proc "c" (a0: rawptr, a1: SIZE_T, a2: LPCSTR, a3: ^SHADER_MACRO, a4: ^ID3DInclude, a5: ^^ID3DBlob, a6: ^^ID3DBlob) -> HRESULT +pD3DDisassemble :: #type proc "c" (a0: rawptr, a1: SIZE_T, a2: u32, a3: LPCSTR, a4: ^^ID3DBlob) -> HRESULT D3DCOMPILER_STRIP_FLAGS :: distinct bit_set[D3DCOMPILER_STRIP_FLAG; u32] D3DCOMPILER_STRIP_FLAG :: enum u32 { diff --git a/vendor/libc/README.md b/vendor/libc-shim/README.md similarity index 79% rename from vendor/libc/README.md rename to vendor/libc-shim/README.md index 1dd50c5a9..9b44984f6 100644 --- a/vendor/libc/README.md +++ b/vendor/libc-shim/README.md @@ -1,11 +1,11 @@ -# vendor:libc +# vendor:libc-shim A (very small) subset of a libc implementation over Odin libraries. This is mainly intended for use in Odin WASM builds to allow using libraries like box2d, cgltf etc. without emscripten hacks. -You can use this with clang by doing `clang -c --target=wasm32 --sysroot=$(odin root)/vendor/libc` (+ all other flags and inputs). +You can use this with clang by doing `clang -c --target=wasm32 --sysroot=$(odin root)/vendor/libc-shim` (+ all other flags and inputs). This will (if all the libc usage of the library is implemented) spit out a `.o` file you can use with the foreign import system. -If you then also make sure this package is included in the Odin side of the project (`@(require) import "vendor:libc"`) you will be able +If you then also make sure this package is included in the Odin side of the project (`@(require) import "vendor:libc-shim"`) you will be able compile to WASM like Odin expects. This is currently used by `vendor:box2d`, `vendor:stb/image`, `vendor:stb/truetype`, `vendor:stb/rect_pack`, and `vendor:cgltf`. diff --git a/vendor/libc/assert.odin b/vendor/libc-shim/assert.odin similarity index 100% rename from vendor/libc/assert.odin rename to vendor/libc-shim/assert.odin diff --git a/vendor/libc/ctype.odin b/vendor/libc-shim/ctype.odin similarity index 100% rename from vendor/libc/ctype.odin rename to vendor/libc-shim/ctype.odin diff --git a/vendor/libc/include/alloca.h b/vendor/libc-shim/include/alloca.h similarity index 100% rename from vendor/libc/include/alloca.h rename to vendor/libc-shim/include/alloca.h diff --git a/vendor/libc/include/assert.h b/vendor/libc-shim/include/assert.h similarity index 100% rename from vendor/libc/include/assert.h rename to vendor/libc-shim/include/assert.h diff --git a/vendor/libc/include/ctype.h b/vendor/libc-shim/include/ctype.h similarity index 100% rename from vendor/libc/include/ctype.h rename to vendor/libc-shim/include/ctype.h diff --git a/vendor/libc/include/inttypes.h b/vendor/libc-shim/include/inttypes.h similarity index 100% rename from vendor/libc/include/inttypes.h rename to vendor/libc-shim/include/inttypes.h diff --git a/vendor/libc/include/math.h b/vendor/libc-shim/include/math.h similarity index 100% rename from vendor/libc/include/math.h rename to vendor/libc-shim/include/math.h diff --git a/vendor/libc/include/sched.h b/vendor/libc-shim/include/sched.h similarity index 100% rename from vendor/libc/include/sched.h rename to vendor/libc-shim/include/sched.h diff --git a/vendor/libc/include/stdio.h b/vendor/libc-shim/include/stdio.h similarity index 100% rename from vendor/libc/include/stdio.h rename to vendor/libc-shim/include/stdio.h diff --git a/vendor/libc/include/stdlib.h b/vendor/libc-shim/include/stdlib.h similarity index 100% rename from vendor/libc/include/stdlib.h rename to vendor/libc-shim/include/stdlib.h diff --git a/vendor/libc/include/string.h b/vendor/libc-shim/include/string.h similarity index 100% rename from vendor/libc/include/string.h rename to vendor/libc-shim/include/string.h diff --git a/vendor/libc/include/time.h b/vendor/libc-shim/include/time.h similarity index 100% rename from vendor/libc/include/time.h rename to vendor/libc-shim/include/time.h diff --git a/vendor/libc-shim/libc.odin b/vendor/libc-shim/libc.odin new file mode 100644 index 000000000..a5508e14f --- /dev/null +++ b/vendor/libc-shim/libc.odin @@ -0,0 +1,26 @@ +package odin_libc + +import "base:runtime" + +import "core:mem" + +@(private) +g_ctx: runtime.Context +@(private) +g_allocator: mem.Compat_Allocator + +@(init) +init_context :: proc "contextless" () { + g_ctx = runtime.default_context() + context = g_ctx + + // Wrapping the allocator with the mem.Compat_Allocator so we can + // mimic the realloc semantics. + mem.compat_allocator_init(&g_allocator, g_ctx.allocator) + g_ctx.allocator = mem.compat_allocator(&g_allocator) +} + +// NOTE: the allocator must respect an `old_size` of `-1` on resizes! +set_context :: proc(ctx := context) { + g_ctx = ctx +} diff --git a/vendor/libc/math.odin b/vendor/libc-shim/math.odin similarity index 100% rename from vendor/libc/math.odin rename to vendor/libc-shim/math.odin diff --git a/vendor/libc/sched.odin b/vendor/libc-shim/sched.odin similarity index 100% rename from vendor/libc/sched.odin rename to vendor/libc-shim/sched.odin diff --git a/vendor/libc/stdio.odin b/vendor/libc-shim/stdio.odin similarity index 98% rename from vendor/libc/stdio.odin rename to vendor/libc-shim/stdio.odin index d41f790ee..e269b8986 100644 --- a/vendor/libc/stdio.odin +++ b/vendor/libc-shim/stdio.odin @@ -17,7 +17,7 @@ EOF :: -1 @(require, linkage="strong", link_name="fopen") fopen :: proc "c" (path: cstring, mode: cstring) -> FILE { context = g_ctx - unimplemented("vendor/libc: fopen") + unimplemented("vendor/libc-shim: fopen") } @(require, linkage="strong", link_name="fseek") @@ -366,7 +366,7 @@ _sscanf :: proc "c" (str, fmt: [^]byte, orig_ptrs: [^]rawptr) -> i32 { i = 0 k = t == 'c' ? width + 1 : 31 if size == .l { - unimplemented("vendor/libc: sscanf wide character support") + unimplemented("vendor/libc-shim: sscanf wide character support") } else if alloc { s = make([^]byte, k) if s == nil { diff --git a/vendor/libc/stdlib.odin b/vendor/libc-shim/stdlib.odin similarity index 100% rename from vendor/libc/stdlib.odin rename to vendor/libc-shim/stdlib.odin diff --git a/vendor/libc/string.odin b/vendor/libc-shim/string.odin similarity index 100% rename from vendor/libc/string.odin rename to vendor/libc-shim/string.odin diff --git a/vendor/libc/time.odin b/vendor/libc-shim/time.odin similarity index 100% rename from vendor/libc/time.odin rename to vendor/libc-shim/time.odin diff --git a/vendor/libc/libc.odin b/vendor/libc/libc.odin index a5508e14f..7af35b090 100644 --- a/vendor/libc/libc.odin +++ b/vendor/libc/libc.odin @@ -1,26 +1,3 @@ package odin_libc -import "base:runtime" - -import "core:mem" - -@(private) -g_ctx: runtime.Context -@(private) -g_allocator: mem.Compat_Allocator - -@(init) -init_context :: proc "contextless" () { - g_ctx = runtime.default_context() - context = g_ctx - - // Wrapping the allocator with the mem.Compat_Allocator so we can - // mimic the realloc semantics. - mem.compat_allocator_init(&g_allocator, g_ctx.allocator) - g_ctx.allocator = mem.compat_allocator(&g_allocator) -} - -// NOTE: the allocator must respect an `old_size` of `-1` on resizes! -set_context :: proc(ctx := context) { - g_ctx = ctx -} +#panic("`vendor:libc` has been moved, use `vendor:libc-shim` instead.") diff --git a/vendor/sdl3/SDL3.dll b/vendor/sdl3/SDL3.dll index 63f5b22ec..510825b26 100644 Binary files a/vendor/sdl3/SDL3.dll and b/vendor/sdl3/SDL3.dll differ diff --git a/vendor/sdl3/SDL3.lib b/vendor/sdl3/SDL3.lib index 164aeb9f1..f52b064ce 100644 Binary files a/vendor/sdl3/SDL3.lib and b/vendor/sdl3/SDL3.lib differ diff --git a/vendor/sdl3/image/LICENSE.libpng.txt b/vendor/sdl3/image/LICENSE.libpng.txt new file mode 100644 index 000000000..ea6df986c --- /dev/null +++ b/vendor/sdl3/image/LICENSE.libpng.txt @@ -0,0 +1,134 @@ +COPYRIGHT NOTICE, DISCLAIMER, and LICENSE +========================================= + +PNG Reference Library License version 2 +--------------------------------------- + + * Copyright (c) 1995-2025 The PNG Reference Library Authors. + * Copyright (c) 2018-2025 Cosmin Truta. + * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson. + * Copyright (c) 1996-1997 Andreas Dilger. + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. + +The software is supplied "as is", without warranty of any kind, +express or implied, including, without limitation, the warranties +of merchantability, fitness for a particular purpose, title, and +non-infringement. In no event shall the Copyright owners, or +anyone distributing the software, be liable for any damages or +other liability, whether in contract, tort or otherwise, arising +from, out of, or in connection with the software, or the use or +other dealings in the software, even if advised of the possibility +of such damage. + +Permission is hereby granted to use, copy, modify, and distribute +this software, or portions hereof, for any purpose, without fee, +subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you + must not claim that you wrote the original software. If you + use this software in a product, an acknowledgment in the product + documentation would be appreciated, but is not required. + + 2. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 3. This Copyright notice may not be removed or altered from any + source or altered source distribution. + + +PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35) +----------------------------------------------------------------------- + +libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are +Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are +derived from libpng-1.0.6, and are distributed according to the same +disclaimer and license as libpng-1.0.6 with the following individuals +added to the list of Contributing Authors: + + Simon-Pierre Cadieux + Eric S. Raymond + Mans Rullgard + Cosmin Truta + Gilles Vollant + James Yu + Mandar Sahastrabuddhe + Google Inc. + Vadim Barkov + +and with the following additions to the disclaimer: + + There is no warranty against interference with your enjoyment of + the library or against infringement. There is no warranty that our + efforts or the library will fulfill any of your particular purposes + or needs. This library is provided with all faults, and the entire + risk of satisfactory quality, performance, accuracy, and effort is + with the user. + +Some files in the "contrib" directory and some configure-generated +files that are distributed with libpng have other copyright owners, and +are released under other open source licenses. + +libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are +Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from +libpng-0.96, and are distributed according to the same disclaimer and +license as libpng-0.96, with the following individuals added to the +list of Contributing Authors: + + Tom Lane + Glenn Randers-Pehrson + Willem van Schaik + +libpng versions 0.89, June 1996, through 0.96, May 1997, are +Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88, +and are distributed according to the same disclaimer and license as +libpng-0.88, with the following individuals added to the list of +Contributing Authors: + + John Bowler + Kevin Bracey + Sam Bushell + Magnus Holmgren + Greg Roelofs + Tom Tanner + +Some files in the "scripts" directory have other copyright owners, +but are released under this license. + +libpng versions 0.5, May 1995, through 0.88, January 1996, are +Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. + +For the purposes of this copyright and license, "Contributing Authors" +is defined as the following set of individuals: + + Andreas Dilger + Dave Martindale + Guy Eric Schalnat + Paul Schmidt + Tim Wegner + +The PNG Reference Library is supplied "AS IS". The Contributing +Authors and Group 42, Inc. disclaim all warranties, expressed or +implied, including, without limitation, the warranties of +merchantability and of fitness for any purpose. The Contributing +Authors and Group 42, Inc. assume no liability for direct, indirect, +incidental, special, exemplary, or consequential damages, which may +result from the use of the PNG Reference Library, even if advised of +the possibility of such damage. + +Permission is hereby granted to use, copy, modify, and distribute this +source code, or portions hereof, for any purpose, without fee, subject +to the following restrictions: + + 1. The origin of this source code must not be misrepresented. + + 2. Altered versions must be plainly marked as such and must not + be misrepresented as being the original source. + + 3. This Copyright notice may not be removed or altered from any + source or altered source distribution. + +The Contributing Authors and Group 42, Inc. specifically permit, +without fee, and encourage the use of this source code as a component +to supporting the PNG file format in commercial products. If you use +this source code in a product, acknowledgment is not required but would +be appreciated. diff --git a/vendor/sdl3/image/LICENSE.txt b/vendor/sdl3/image/LICENSE.txt index 52d0ed38b..acaf5b21b 100644 --- a/vendor/sdl3/image/LICENSE.txt +++ b/vendor/sdl3/image/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (C) 1997-2025 Sam Lantinga +Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vendor/sdl3/image/SDL3_image.dll b/vendor/sdl3/image/SDL3_image.dll index 2ba20a7cf..ea48dab75 100644 Binary files a/vendor/sdl3/image/SDL3_image.dll and b/vendor/sdl3/image/SDL3_image.dll differ diff --git a/vendor/sdl3/image/SDL3_image.lib b/vendor/sdl3/image/SDL3_image.lib index 4e9913b4c..7db2f734a 100644 Binary files a/vendor/sdl3/image/SDL3_image.lib and b/vendor/sdl3/image/SDL3_image.lib differ diff --git a/vendor/sdl3/image/include/SDL_image.h b/vendor/sdl3/image/include/SDL_image.h index 60d041fe6..19d9f2e02 100644 --- a/vendor/sdl3/image/include/SDL_image.h +++ b/vendor/sdl3/image/include/SDL_image.h @@ -1,6 +1,6 @@ /* SDL_image: An example image loading library for use with SDL - Copyright (C) 1997-2025 Sam Lantinga + Copyright (C) 1997-2026 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -44,8 +44,8 @@ extern "C" { * Printable format: "%d.%d.%d", MAJOR, MINOR, MICRO */ #define SDL_IMAGE_MAJOR_VERSION 3 -#define SDL_IMAGE_MINOR_VERSION 2 -#define SDL_IMAGE_MICRO_VERSION 4 +#define SDL_IMAGE_MINOR_VERSION 4 +#define SDL_IMAGE_MICRO_VERSION 0 /** * This is the version number macro for the current SDL_image version. @@ -70,6 +70,103 @@ extern "C" { */ extern SDL_DECLSPEC int SDLCALL IMG_Version(void); +/** + * Load an image from a filesystem path into a software surface. + * + * An SDL_Surface is a buffer of pixels in memory accessible by the CPU. Use + * this if you plan to hand the data to something else or manipulate it + * further in code. + * + * There are no guarantees about what format the new SDL_Surface data will be; + * in many cases, SDL_image will attempt to supply a surface that exactly + * matches the provided image, but in others it might have to convert (either + * because the image is in a format that SDL doesn't directly support or + * because it's compressed data that could reasonably uncompress to various + * formats and SDL_image had to pick one). You can inspect an SDL_Surface for + * its specifics, and use SDL_ConvertSurface to then migrate to any supported + * format. + * + * If the image format supports a transparent pixel, SDL will set the colorkey + * for the surface. You can enable RLE acceleration on the surface afterwards + * by calling: SDL_SetSurfaceColorKey(image, SDL_RLEACCEL, + * image->format->colorkey); + * + * There is a separate function to read files from an SDL_IOStream, if you + * need an i/o abstraction to provide data from anywhere instead of a simple + * filesystem read; that function is IMG_Load_IO(). + * + * If you are using SDL's 2D rendering API, there is an equivalent call to + * load images directly into an SDL_Texture for use by the GPU without using a + * software surface: call IMG_LoadTexture() instead. + * + * When done with the returned surface, the app should dispose of it with a + * call to + * [SDL_DestroySurface](https://wiki.libsdl.org/SDL3/SDL_DestroySurface) + * (). + * + * \param file a path on the filesystem to load an image from. + * \returns a new SDL surface, or NULL on error. + * + * \since This function is available since SDL_image 3.0.0. + * + * \sa IMG_LoadTyped_IO + * \sa IMG_Load_IO + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_Load(const char *file); + +/** + * Load an image from an SDL data source into a software surface. + * + * An SDL_Surface is a buffer of pixels in memory accessible by the CPU. Use + * this if you plan to hand the data to something else or manipulate it + * further in code. + * + * There are no guarantees about what format the new SDL_Surface data will be; + * in many cases, SDL_image will attempt to supply a surface that exactly + * matches the provided image, but in others it might have to convert (either + * because the image is in a format that SDL doesn't directly support or + * because it's compressed data that could reasonably uncompress to various + * formats and SDL_image had to pick one). You can inspect an SDL_Surface for + * its specifics, and use SDL_ConvertSurface to then migrate to any supported + * format. + * + * If the image format supports a transparent pixel, SDL will set the colorkey + * for the surface. You can enable RLE acceleration on the surface afterwards + * by calling: SDL_SetSurfaceColorKey(image, SDL_RLEACCEL, + * image->format->colorkey); + * + * If `closeio` is true, `src` will be closed before returning, whether this + * function succeeds or not. SDL_image reads everything it needs from `src` + * during this call in any case. + * + * There is a separate function to read files from disk without having to deal + * with SDL_IOStream: `IMG_Load("filename.jpg")` will call this function and + * manage those details for you, determining the file type from the filename's + * extension. + * + * There is also IMG_LoadTyped_IO(), which is equivalent to this function + * except a file extension (like "BMP", "JPG", etc) can be specified, in case + * SDL_image cannot autodetect the file format. + * + * If you are using SDL's 2D rendering API, there is an equivalent call to + * load images directly into an SDL_Texture for use by the GPU without using a + * software surface: call IMG_LoadTexture_IO() instead. + * + * When done with the returned surface, the app should dispose of it with a + * call to SDL_DestroySurface(). + * + * \param src an SDL_IOStream that data will be read from. + * \param closeio true to close/free the SDL_IOStream before returning, false + * to leave it open. + * \returns a new SDL surface, or NULL on error. + * + * \since This function is available since SDL_image 3.0.0. + * + * \sa IMG_Load + * \sa IMG_LoadTyped_IO + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_Load_IO(SDL_IOStream *src, bool closeio); + /** * Load an image from an SDL data source into a software surface. * @@ -128,111 +225,11 @@ extern SDL_DECLSPEC int SDLCALL IMG_Version(void); * * \sa IMG_Load * \sa IMG_Load_IO - * \sa SDL_DestroySurface */ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadTyped_IO(SDL_IOStream *src, bool closeio, const char *type); /** - * Load an image from a filesystem path into a software surface. - * - * An SDL_Surface is a buffer of pixels in memory accessible by the CPU. Use - * this if you plan to hand the data to something else or manipulate it - * further in code. - * - * There are no guarantees about what format the new SDL_Surface data will be; - * in many cases, SDL_image will attempt to supply a surface that exactly - * matches the provided image, but in others it might have to convert (either - * because the image is in a format that SDL doesn't directly support or - * because it's compressed data that could reasonably uncompress to various - * formats and SDL_image had to pick one). You can inspect an SDL_Surface for - * its specifics, and use SDL_ConvertSurface to then migrate to any supported - * format. - * - * If the image format supports a transparent pixel, SDL will set the colorkey - * for the surface. You can enable RLE acceleration on the surface afterwards - * by calling: SDL_SetSurfaceColorKey(image, SDL_RLEACCEL, - * image->format->colorkey); - * - * There is a separate function to read files from an SDL_IOStream, if you - * need an i/o abstraction to provide data from anywhere instead of a simple - * filesystem read; that function is IMG_Load_IO(). - * - * If you are using SDL's 2D rendering API, there is an equivalent call to - * load images directly into an SDL_Texture for use by the GPU without using a - * software surface: call IMG_LoadTexture() instead. - * - * When done with the returned surface, the app should dispose of it with a - * call to - * [SDL_DestroySurface](https://wiki.libsdl.org/SDL3/SDL_DestroySurface) - * (). - * - * \param file a path on the filesystem to load an image from. - * \returns a new SDL surface, or NULL on error. - * - * \since This function is available since SDL_image 3.0.0. - * - * \sa IMG_LoadTyped_IO - * \sa IMG_Load_IO - * \sa SDL_DestroySurface - */ -extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_Load(const char *file); - -/** - * Load an image from an SDL data source into a software surface. - * - * An SDL_Surface is a buffer of pixels in memory accessible by the CPU. Use - * this if you plan to hand the data to something else or manipulate it - * further in code. - * - * There are no guarantees about what format the new SDL_Surface data will be; - * in many cases, SDL_image will attempt to supply a surface that exactly - * matches the provided image, but in others it might have to convert (either - * because the image is in a format that SDL doesn't directly support or - * because it's compressed data that could reasonably uncompress to various - * formats and SDL_image had to pick one). You can inspect an SDL_Surface for - * its specifics, and use SDL_ConvertSurface to then migrate to any supported - * format. - * - * If the image format supports a transparent pixel, SDL will set the colorkey - * for the surface. You can enable RLE acceleration on the surface afterwards - * by calling: SDL_SetSurfaceColorKey(image, SDL_RLEACCEL, - * image->format->colorkey); - * - * If `closeio` is true, `src` will be closed before returning, whether this - * function succeeds or not. SDL_image reads everything it needs from `src` - * during this call in any case. - * - * There is a separate function to read files from disk without having to deal - * with SDL_IOStream: `IMG_Load("filename.jpg")` will call this function and - * manage those details for you, determining the file type from the filename's - * extension. - * - * There is also IMG_LoadTyped_IO(), which is equivalent to this function - * except a file extension (like "BMP", "JPG", etc) can be specified, in case - * SDL_image cannot autodetect the file format. - * - * If you are using SDL's 2D rendering API, there is an equivalent call to - * load images directly into an SDL_Texture for use by the GPU without using a - * software surface: call IMG_LoadTexture_IO() instead. - * - * When done with the returned surface, the app should dispose of it with a - * call to SDL_DestroySurface(). - * - * \param src an SDL_IOStream that data will be read from. - * \param closeio true to close/free the SDL_IOStream before returning, false - * to leave it open. - * \returns a new SDL surface, or NULL on error. - * - * \since This function is available since SDL_image 3.0.0. - * - * \sa IMG_Load - * \sa IMG_LoadTyped_IO - * \sa SDL_DestroySurface - */ -extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_Load_IO(SDL_IOStream *src, bool closeio); - -/** - * Load an image from a filesystem path into a GPU texture. + * Load an image from a filesystem path into a texture. * * An SDL_Texture represents an image in GPU memory, usable by SDL's 2D Render * API. This can be significantly more efficient than using a CPU-bound @@ -255,7 +252,7 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_Load_IO(SDL_IOStream *src, bool cl * When done with the returned texture, the app should dispose of it with a * call to SDL_DestroyTexture(). * - * \param renderer the SDL_Renderer to use to create the GPU texture. + * \param renderer the SDL_Renderer to use to create the texture. * \param file a path on the filesystem to load an image from. * \returns a new texture, or NULL on error. * @@ -267,7 +264,7 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_Load_IO(SDL_IOStream *src, bool cl extern SDL_DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture(SDL_Renderer *renderer, const char *file); /** - * Load an image from an SDL data source into a GPU texture. + * Load an image from an SDL data source into a texture. * * An SDL_Texture represents an image in GPU memory, usable by SDL's 2D Render * API. This can be significantly more efficient than using a CPU-bound @@ -299,7 +296,7 @@ extern SDL_DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture(SDL_Renderer *renderer * When done with the returned texture, the app should dispose of it with a * call to SDL_DestroyTexture(). * - * \param renderer the SDL_Renderer to use to create the GPU texture. + * \param renderer the SDL_Renderer to use to create the texture. * \param src an SDL_IOStream that data will be read from. * \param closeio true to close/free the SDL_IOStream before returning, false * to leave it open. @@ -309,12 +306,11 @@ extern SDL_DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture(SDL_Renderer *renderer * * \sa IMG_LoadTexture * \sa IMG_LoadTextureTyped_IO - * \sa SDL_DestroyTexture */ extern SDL_DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture_IO(SDL_Renderer *renderer, SDL_IOStream *src, bool closeio); /** - * Load an image from an SDL data source into a GPU texture. + * Load an image from an SDL data source into a texture. * * An SDL_Texture represents an image in GPU memory, usable by SDL's 2D Render * API. This can be significantly more efficient than using a CPU-bound @@ -352,7 +348,7 @@ extern SDL_DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture_IO(SDL_Renderer *rende * When done with the returned texture, the app should dispose of it with a * call to SDL_DestroyTexture(). * - * \param renderer the SDL_Renderer to use to create the GPU texture. + * \param renderer the SDL_Renderer to use to create the texture. * \param src an SDL_IOStream that data will be read from. * \param closeio true to close/free the SDL_IOStream before returning, false * to leave it open. @@ -364,10 +360,194 @@ extern SDL_DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture_IO(SDL_Renderer *rende * * \sa IMG_LoadTexture * \sa IMG_LoadTexture_IO - * \sa SDL_DestroyTexture */ extern SDL_DECLSPEC SDL_Texture * SDLCALL IMG_LoadTextureTyped_IO(SDL_Renderer *renderer, SDL_IOStream *src, bool closeio, const char *type); +/** + * Load an image from a filesystem path into a GPU texture. + * + * An SDL_GPUTexture represents an image in GPU memory, usable by SDL's GPU + * API. Regardless of the source format of the image, this function will + * create a GPU texture with the format SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM + * with no mip levels. It can be bound as a sampled texture from a graphics or + * compute pipeline and as a a readonly storage texture in a compute pipeline. + * + * There is a separate function to read files from an SDL_IOStream, if you + * need an i/o abstraction to provide data from anywhere instead of a simple + * filesystem read; that function is IMG_LoadGPUTexture_IO(). + * + * When done with the returned texture, the app should dispose of it with a + * call to SDL_ReleaseGPUTexture(). + * + * \param device the SDL_GPUDevice to use to create the GPU texture. + * \param copy_pass the SDL_GPUCopyPass to use to upload the loaded image to + * the GPU texture. + * \param file a path on the filesystem to load an image from. + * \param width a pointer filled in with the width of the GPU texture. may be + * NULL. + * \param height a pointer filled in with the width of the GPU texture. may be + * NULL. + * \returns a new GPU texture, or NULL on error. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_LoadGPUTextureTyped_IO + * \sa IMG_LoadGPUTexture_IO + */ +extern SDL_DECLSPEC SDL_GPUTexture * SDLCALL IMG_LoadGPUTexture(SDL_GPUDevice *device, SDL_GPUCopyPass *copy_pass, const char *file, int *width, int *height); + +/** + * Load an image from an SDL data source into a GPU texture. + * + * An SDL_GPUTexture represents an image in GPU memory, usable by SDL's GPU + * API. Regardless of the source format of the image, this function will + * create a GPU texture with the format SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM + * with no mip levels. It can be bound as a sampled texture from a graphics or + * compute pipeline and as a a readonly storage texture in a compute pipeline. + * + * If `closeio` is true, `src` will be closed before returning, whether this + * function succeeds or not. SDL_image reads everything it needs from `src` + * during this call in any case. + * + * There is a separate function to read files from disk without having to deal + * with SDL_IOStream: `IMG_LoadGPUTexture(device, copy_pass, "filename.jpg", + * width, height) will call this function and manage those details for you, + * determining the file type from the filename's extension. + * + * There is also IMG_LoadGPUTextureTyped_IO(), which is equivalent to this + * function except a file extension (like "BMP", "JPG", etc) can be specified, + * in case SDL_image cannot autodetect the file format. + * + * When done with the returned texture, the app should dispose of it with a + * call to SDL_ReleaseGPUTexture(). + * + * \param device the SDL_GPUDevice to use to create the GPU texture. + * \param copy_pass the SDL_GPUCopyPass to use to upload the loaded image to + * the GPU texture. + * \param src an SDL_IOStream that data will be read from. + * \param closeio true to close/free the SDL_IOStream before returning, false + * to leave it open. + * \param width a pointer filled in with the width of the GPU texture. may be + * NULL. + * \param height a pointer filled in with the width of the GPU texture. may be + * NULL. + * \returns a new GPU texture, or NULL on error. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_LoadGPUTexture + * \sa IMG_LoadGPUTextureTyped_IO + */ +extern SDL_DECLSPEC SDL_GPUTexture * SDLCALL IMG_LoadGPUTexture_IO(SDL_GPUDevice *device, SDL_GPUCopyPass *copy_pass, SDL_IOStream *src, bool closeio, int *width, int *height); + +/** + * Load an image from an SDL data source into a GPU texture. + * + * An SDL_GPUTexture represents an image in GPU memory, usable by SDL's GPU + * API. Regardless of the source format of the image, this function will + * create a GPU texture with the format SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM + * with no mip levels. It can be bound as a sampled texture from a graphics or + * compute pipeline and as a a readonly storage texture in a compute pipeline. + * + * If `closeio` is true, `src` will be closed before returning, whether this + * function succeeds or not. SDL_image reads everything it needs from `src` + * during this call in any case. + * + * Even though this function accepts a file type, SDL_image may still try + * other decoders that are capable of detecting file type from the contents of + * the image data, but may rely on the caller-provided type string for formats + * that it cannot autodetect. If `type` is NULL, SDL_image will rely solely on + * its ability to guess the format. + * + * There is a separate function to read files from disk without having to deal + * with SDL_IOStream: `IMG_LoadGPUTexture(device, copy_pass, "filename.jpg", + * width, height) will call this function and manage those details for you, + * determining the file type from the filename's extension. + * + * There is also IMG_LoadGPUTexture_IO(), which is equivalent to this function + * except that it will rely on SDL_image to determine what type of data it is + * loading, much like passing a NULL for type. + * + * When done with the returned texture, the app should dispose of it with a + * call to SDL_ReleaseGPUTexture(). + * + * \param device the SDL_GPUDevice to use to create the GPU texture. + * \param copy_pass the SDL_GPUCopyPass to use to upload the loaded image to + * the GPU texture. + * \param src an SDL_IOStream that data will be read from. + * \param closeio true to close/free the SDL_IOStream before returning, false + * to leave it open. + * \param type a filename extension that represent this data ("BMP", "GIF", + * "PNG", etc). + * \param width a pointer filled in with the width of the GPU texture. may be + * NULL. + * \param height a pointer filled in with the width of the GPU texture. may be + * NULL. + * \returns a new GPU texture, or NULL on error. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_LoadGPUTexture + * \sa IMG_LoadGPUTexture_IO + */ +extern SDL_DECLSPEC SDL_GPUTexture * SDLCALL IMG_LoadGPUTextureTyped_IO(SDL_GPUDevice *device, SDL_GPUCopyPass *copy_pass, SDL_IOStream *src, bool closeio, const char *type, int *width, int *height); + +/** + * Get the image currently in the clipboard. + * + * When done with the returned surface, the app should dispose of it with a + * call to SDL_DestroySurface(). + * + * \returns a new SDL surface, or NULL if no supported image is available. + * + * \since This function is available since SDL_image 3.4.0. + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_GetClipboardImage(void); + +/** + * Detect ANI animated cursor data on a readable/seekable SDL_IOStream. + * + * This function attempts to determine if a file is a given filetype, reading + * the least amount possible from the SDL_IOStream (usually a few bytes). + * + * There is no distinction made between "not the filetype in question" and + * basic i/o errors. + * + * This function will always attempt to seek `src` back to where it started + * when this function was called, but it will not report any errors in doing + * so, but assuming seeking works, this means you can immediately use this + * with a different IMG_isTYPE function, or load the image without further + * seeking. + * + * You do not need to call this function to load data; SDL_image can work to + * determine file type in many cases in its standard load functions. + * + * \param src a seekable/readable SDL_IOStream to provide image data. + * \returns true if this is ANI animated cursor data, false otherwise. + * + * \since This function is available since SDL_image 3.0.0. + * + * \sa IMG_isAVIF + * \sa IMG_isBMP + * \sa IMG_isCUR + * \sa IMG_isGIF + * \sa IMG_isICO + * \sa IMG_isJPG + * \sa IMG_isJXL + * \sa IMG_isLBM + * \sa IMG_isPCX + * \sa IMG_isPNG + * \sa IMG_isPNM + * \sa IMG_isQOI + * \sa IMG_isSVG + * \sa IMG_isTIF + * \sa IMG_isWEBP + * \sa IMG_isXCF + * \sa IMG_isXPM + * \sa IMG_isXV + */ +extern SDL_DECLSPEC bool SDLCALL IMG_isANI(SDL_IOStream *src); + /** * Detect AVIF image data on a readable/seekable SDL_IOStream. * @@ -387,74 +567,31 @@ extern SDL_DECLSPEC SDL_Texture * SDLCALL IMG_LoadTextureTyped_IO(SDL_Renderer * * determine file type in many cases in its standard load functions. * * \param src a seekable/readable SDL_IOStream to provide image data. - * \returns non-zero if this is AVIF data, zero otherwise. + * \returns true if this is AVIF data, false otherwise. * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_isAVIF - * \sa IMG_isICO - * \sa IMG_isCUR + * \sa IMG_isANI * \sa IMG_isBMP + * \sa IMG_isCUR * \sa IMG_isGIF + * \sa IMG_isICO * \sa IMG_isJPG * \sa IMG_isJXL * \sa IMG_isLBM * \sa IMG_isPCX * \sa IMG_isPNG * \sa IMG_isPNM - * \sa IMG_isSVG * \sa IMG_isQOI + * \sa IMG_isSVG * \sa IMG_isTIF + * \sa IMG_isWEBP * \sa IMG_isXCF * \sa IMG_isXPM * \sa IMG_isXV - * \sa IMG_isWEBP */ extern SDL_DECLSPEC bool SDLCALL IMG_isAVIF(SDL_IOStream *src); -/** - * Detect ICO image data on a readable/seekable SDL_IOStream. - * - * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_IOStream (usually a few bytes). - * - * There is no distinction made between "not the filetype in question" and - * basic i/o errors. - * - * This function will always attempt to seek `src` back to where it started - * when this function was called, but it will not report any errors in doing - * so, but assuming seeking works, this means you can immediately use this - * with a different IMG_isTYPE function, or load the image without further - * seeking. - * - * You do not need to call this function to load data; SDL_image can work to - * determine file type in many cases in its standard load functions. - * - * \param src a seekable/readable SDL_IOStream to provide image data. - * \returns non-zero if this is ICO data, zero otherwise. - * - * \since This function is available since SDL_image 3.0.0. - * - * \sa IMG_isAVIF - * \sa IMG_isCUR - * \sa IMG_isBMP - * \sa IMG_isGIF - * \sa IMG_isJPG - * \sa IMG_isJXL - * \sa IMG_isLBM - * \sa IMG_isPCX - * \sa IMG_isPNG - * \sa IMG_isPNM - * \sa IMG_isSVG - * \sa IMG_isQOI - * \sa IMG_isTIF - * \sa IMG_isXCF - * \sa IMG_isXPM - * \sa IMG_isXV - * \sa IMG_isWEBP - */ -extern SDL_DECLSPEC bool SDLCALL IMG_isICO(SDL_IOStream *src); - /** * Detect CUR image data on a readable/seekable SDL_IOStream. * @@ -474,27 +611,28 @@ extern SDL_DECLSPEC bool SDLCALL IMG_isICO(SDL_IOStream *src); * determine file type in many cases in its standard load functions. * * \param src a seekable/readable SDL_IOStream to provide image data. - * \returns non-zero if this is CUR data, zero otherwise. + * \returns true if this is CUR data, false otherwise. * * \since This function is available since SDL_image 3.0.0. * + * \sa IMG_isANI * \sa IMG_isAVIF - * \sa IMG_isICO * \sa IMG_isBMP * \sa IMG_isGIF + * \sa IMG_isICO * \sa IMG_isJPG * \sa IMG_isJXL * \sa IMG_isLBM * \sa IMG_isPCX * \sa IMG_isPNG * \sa IMG_isPNM - * \sa IMG_isSVG * \sa IMG_isQOI + * \sa IMG_isSVG * \sa IMG_isTIF + * \sa IMG_isWEBP * \sa IMG_isXCF * \sa IMG_isXPM * \sa IMG_isXV - * \sa IMG_isWEBP */ extern SDL_DECLSPEC bool SDLCALL IMG_isCUR(SDL_IOStream *src); @@ -517,27 +655,28 @@ extern SDL_DECLSPEC bool SDLCALL IMG_isCUR(SDL_IOStream *src); * determine file type in many cases in its standard load functions. * * \param src a seekable/readable SDL_IOStream to provide image data. - * \returns non-zero if this is BMP data, zero otherwise. + * \returns true if this is BMP data, false otherwise. * * \since This function is available since SDL_image 3.0.0. * + * \sa IMG_isANI * \sa IMG_isAVIF - * \sa IMG_isICO * \sa IMG_isCUR * \sa IMG_isGIF + * \sa IMG_isICO * \sa IMG_isJPG * \sa IMG_isJXL * \sa IMG_isLBM * \sa IMG_isPCX * \sa IMG_isPNG * \sa IMG_isPNM - * \sa IMG_isSVG * \sa IMG_isQOI + * \sa IMG_isSVG * \sa IMG_isTIF + * \sa IMG_isWEBP * \sa IMG_isXCF * \sa IMG_isXPM * \sa IMG_isXV - * \sa IMG_isWEBP */ extern SDL_DECLSPEC bool SDLCALL IMG_isBMP(SDL_IOStream *src); @@ -560,30 +699,75 @@ extern SDL_DECLSPEC bool SDLCALL IMG_isBMP(SDL_IOStream *src); * determine file type in many cases in its standard load functions. * * \param src a seekable/readable SDL_IOStream to provide image data. - * \returns non-zero if this is GIF data, zero otherwise. + * \returns true if this is GIF data, false otherwise. * * \since This function is available since SDL_image 3.0.0. * + * \sa IMG_isANI * \sa IMG_isAVIF - * \sa IMG_isICO - * \sa IMG_isCUR * \sa IMG_isBMP + * \sa IMG_isCUR + * \sa IMG_isICO * \sa IMG_isJPG * \sa IMG_isJXL * \sa IMG_isLBM * \sa IMG_isPCX * \sa IMG_isPNG * \sa IMG_isPNM - * \sa IMG_isSVG * \sa IMG_isQOI + * \sa IMG_isSVG * \sa IMG_isTIF + * \sa IMG_isWEBP * \sa IMG_isXCF * \sa IMG_isXPM * \sa IMG_isXV - * \sa IMG_isWEBP */ extern SDL_DECLSPEC bool SDLCALL IMG_isGIF(SDL_IOStream *src); +/** + * Detect ICO image data on a readable/seekable SDL_IOStream. + * + * This function attempts to determine if a file is a given filetype, reading + * the least amount possible from the SDL_IOStream (usually a few bytes). + * + * There is no distinction made between "not the filetype in question" and + * basic i/o errors. + * + * This function will always attempt to seek `src` back to where it started + * when this function was called, but it will not report any errors in doing + * so, but assuming seeking works, this means you can immediately use this + * with a different IMG_isTYPE function, or load the image without further + * seeking. + * + * You do not need to call this function to load data; SDL_image can work to + * determine file type in many cases in its standard load functions. + * + * \param src a seekable/readable SDL_IOStream to provide image data. + * \returns true if this is ICO data, false otherwise. + * + * \since This function is available since SDL_image 3.0.0. + * + * \sa IMG_isANI + * \sa IMG_isAVIF + * \sa IMG_isBMP + * \sa IMG_isCUR + * \sa IMG_isGIF + * \sa IMG_isJPG + * \sa IMG_isJXL + * \sa IMG_isLBM + * \sa IMG_isPCX + * \sa IMG_isPNG + * \sa IMG_isPNM + * \sa IMG_isQOI + * \sa IMG_isSVG + * \sa IMG_isTIF + * \sa IMG_isWEBP + * \sa IMG_isXCF + * \sa IMG_isXPM + * \sa IMG_isXV + */ +extern SDL_DECLSPEC bool SDLCALL IMG_isICO(SDL_IOStream *src); + /** * Detect JPG image data on a readable/seekable SDL_IOStream. * @@ -603,27 +787,28 @@ extern SDL_DECLSPEC bool SDLCALL IMG_isGIF(SDL_IOStream *src); * determine file type in many cases in its standard load functions. * * \param src a seekable/readable SDL_IOStream to provide image data. - * \returns non-zero if this is JPG data, zero otherwise. + * \returns true if this is JPG data, false otherwise. * * \since This function is available since SDL_image 3.0.0. * + * \sa IMG_isANI * \sa IMG_isAVIF - * \sa IMG_isICO - * \sa IMG_isCUR * \sa IMG_isBMP + * \sa IMG_isCUR * \sa IMG_isGIF + * \sa IMG_isICO * \sa IMG_isJXL * \sa IMG_isLBM * \sa IMG_isPCX * \sa IMG_isPNG * \sa IMG_isPNM - * \sa IMG_isSVG * \sa IMG_isQOI + * \sa IMG_isSVG * \sa IMG_isTIF + * \sa IMG_isWEBP * \sa IMG_isXCF * \sa IMG_isXPM * \sa IMG_isXV - * \sa IMG_isWEBP */ extern SDL_DECLSPEC bool SDLCALL IMG_isJPG(SDL_IOStream *src); @@ -646,27 +831,28 @@ extern SDL_DECLSPEC bool SDLCALL IMG_isJPG(SDL_IOStream *src); * determine file type in many cases in its standard load functions. * * \param src a seekable/readable SDL_IOStream to provide image data. - * \returns non-zero if this is JXL data, zero otherwise. + * \returns true if this is JXL data, false otherwise. * * \since This function is available since SDL_image 3.0.0. * + * \sa IMG_isANI * \sa IMG_isAVIF - * \sa IMG_isICO - * \sa IMG_isCUR * \sa IMG_isBMP + * \sa IMG_isCUR * \sa IMG_isGIF + * \sa IMG_isICO * \sa IMG_isJPG * \sa IMG_isLBM * \sa IMG_isPCX * \sa IMG_isPNG * \sa IMG_isPNM - * \sa IMG_isSVG * \sa IMG_isQOI + * \sa IMG_isSVG * \sa IMG_isTIF + * \sa IMG_isWEBP * \sa IMG_isXCF * \sa IMG_isXPM * \sa IMG_isXV - * \sa IMG_isWEBP */ extern SDL_DECLSPEC bool SDLCALL IMG_isJXL(SDL_IOStream *src); @@ -689,27 +875,28 @@ extern SDL_DECLSPEC bool SDLCALL IMG_isJXL(SDL_IOStream *src); * determine file type in many cases in its standard load functions. * * \param src a seekable/readable SDL_IOStream to provide image data. - * \returns non-zero if this is LBM data, zero otherwise. + * \returns true if this is LBM data, false otherwise. * * \since This function is available since SDL_image 3.0.0. * + * \sa IMG_isANI * \sa IMG_isAVIF - * \sa IMG_isICO - * \sa IMG_isCUR * \sa IMG_isBMP + * \sa IMG_isCUR * \sa IMG_isGIF + * \sa IMG_isICO * \sa IMG_isJPG * \sa IMG_isJXL * \sa IMG_isPCX * \sa IMG_isPNG * \sa IMG_isPNM - * \sa IMG_isSVG * \sa IMG_isQOI + * \sa IMG_isSVG * \sa IMG_isTIF + * \sa IMG_isWEBP * \sa IMG_isXCF * \sa IMG_isXPM * \sa IMG_isXV - * \sa IMG_isWEBP */ extern SDL_DECLSPEC bool SDLCALL IMG_isLBM(SDL_IOStream *src); @@ -732,27 +919,28 @@ extern SDL_DECLSPEC bool SDLCALL IMG_isLBM(SDL_IOStream *src); * determine file type in many cases in its standard load functions. * * \param src a seekable/readable SDL_IOStream to provide image data. - * \returns non-zero if this is PCX data, zero otherwise. + * \returns true if this is PCX data, false otherwise. * * \since This function is available since SDL_image 3.0.0. * + * \sa IMG_isANI * \sa IMG_isAVIF - * \sa IMG_isICO - * \sa IMG_isCUR * \sa IMG_isBMP + * \sa IMG_isCUR * \sa IMG_isGIF + * \sa IMG_isICO * \sa IMG_isJPG * \sa IMG_isJXL * \sa IMG_isLBM * \sa IMG_isPNG * \sa IMG_isPNM - * \sa IMG_isSVG * \sa IMG_isQOI + * \sa IMG_isSVG * \sa IMG_isTIF + * \sa IMG_isWEBP * \sa IMG_isXCF * \sa IMG_isXPM * \sa IMG_isXV - * \sa IMG_isWEBP */ extern SDL_DECLSPEC bool SDLCALL IMG_isPCX(SDL_IOStream *src); @@ -775,27 +963,28 @@ extern SDL_DECLSPEC bool SDLCALL IMG_isPCX(SDL_IOStream *src); * determine file type in many cases in its standard load functions. * * \param src a seekable/readable SDL_IOStream to provide image data. - * \returns non-zero if this is PNG data, zero otherwise. + * \returns true if this is PNG data, false otherwise. * * \since This function is available since SDL_image 3.0.0. * + * \sa IMG_isANI * \sa IMG_isAVIF - * \sa IMG_isICO - * \sa IMG_isCUR * \sa IMG_isBMP + * \sa IMG_isCUR * \sa IMG_isGIF + * \sa IMG_isICO * \sa IMG_isJPG * \sa IMG_isJXL * \sa IMG_isLBM * \sa IMG_isPCX * \sa IMG_isPNM - * \sa IMG_isSVG * \sa IMG_isQOI + * \sa IMG_isSVG * \sa IMG_isTIF + * \sa IMG_isWEBP * \sa IMG_isXCF * \sa IMG_isXPM * \sa IMG_isXV - * \sa IMG_isWEBP */ extern SDL_DECLSPEC bool SDLCALL IMG_isPNG(SDL_IOStream *src); @@ -818,73 +1007,31 @@ extern SDL_DECLSPEC bool SDLCALL IMG_isPNG(SDL_IOStream *src); * determine file type in many cases in its standard load functions. * * \param src a seekable/readable SDL_IOStream to provide image data. - * \returns non-zero if this is PNM data, zero otherwise. + * \returns true if this is PNM data, false otherwise. * * \since This function is available since SDL_image 3.0.0. * + * \sa IMG_isANI * \sa IMG_isAVIF - * \sa IMG_isICO - * \sa IMG_isCUR * \sa IMG_isBMP + * \sa IMG_isCUR * \sa IMG_isGIF + * \sa IMG_isICO * \sa IMG_isJPG * \sa IMG_isJXL * \sa IMG_isLBM * \sa IMG_isPCX * \sa IMG_isPNG - * \sa IMG_isSVG * \sa IMG_isQOI + * \sa IMG_isSVG * \sa IMG_isTIF + * \sa IMG_isWEBP * \sa IMG_isXCF * \sa IMG_isXPM * \sa IMG_isXV - * \sa IMG_isWEBP */ extern SDL_DECLSPEC bool SDLCALL IMG_isPNM(SDL_IOStream *src); -/** - * Detect SVG image data on a readable/seekable SDL_IOStream. - * - * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_IOStream (usually a few bytes). - * - * There is no distinction made between "not the filetype in question" and - * basic i/o errors. - * - * This function will always attempt to seek `src` back to where it started - * when this function was called, but it will not report any errors in doing - * so, but assuming seeking works, this means you can immediately use this - * with a different IMG_isTYPE function, or load the image without further - * seeking. - * - * You do not need to call this function to load data; SDL_image can work to - * determine file type in many cases in its standard load functions. - * - * \param src a seekable/readable SDL_IOStream to provide image data. - * \returns non-zero if this is SVG data, zero otherwise. - * - * \since This function is available since SDL_image 3.0.0. - * - * \sa IMG_isAVIF - * \sa IMG_isICO - * \sa IMG_isCUR - * \sa IMG_isBMP - * \sa IMG_isGIF - * \sa IMG_isJPG - * \sa IMG_isJXL - * \sa IMG_isLBM - * \sa IMG_isPCX - * \sa IMG_isPNG - * \sa IMG_isPNM - * \sa IMG_isQOI - * \sa IMG_isTIF - * \sa IMG_isXCF - * \sa IMG_isXPM - * \sa IMG_isXV - * \sa IMG_isWEBP - */ -extern SDL_DECLSPEC bool SDLCALL IMG_isSVG(SDL_IOStream *src); - /** * Detect QOI image data on a readable/seekable SDL_IOStream. * @@ -904,15 +1051,16 @@ extern SDL_DECLSPEC bool SDLCALL IMG_isSVG(SDL_IOStream *src); * determine file type in many cases in its standard load functions. * * \param src a seekable/readable SDL_IOStream to provide image data. - * \returns non-zero if this is QOI data, zero otherwise. + * \returns true if this is QOI data, false otherwise. * * \since This function is available since SDL_image 3.0.0. * + * \sa IMG_isANI * \sa IMG_isAVIF - * \sa IMG_isICO - * \sa IMG_isCUR * \sa IMG_isBMP + * \sa IMG_isCUR * \sa IMG_isGIF + * \sa IMG_isICO * \sa IMG_isJPG * \sa IMG_isJXL * \sa IMG_isLBM @@ -921,13 +1069,57 @@ extern SDL_DECLSPEC bool SDLCALL IMG_isSVG(SDL_IOStream *src); * \sa IMG_isPNM * \sa IMG_isSVG * \sa IMG_isTIF + * \sa IMG_isWEBP * \sa IMG_isXCF * \sa IMG_isXPM * \sa IMG_isXV - * \sa IMG_isWEBP */ extern SDL_DECLSPEC bool SDLCALL IMG_isQOI(SDL_IOStream *src); +/** + * Detect SVG image data on a readable/seekable SDL_IOStream. + * + * This function attempts to determine if a file is a given filetype, reading + * the least amount possible from the SDL_IOStream (usually a few bytes). + * + * There is no distinction made between "not the filetype in question" and + * basic i/o errors. + * + * This function will always attempt to seek `src` back to where it started + * when this function was called, but it will not report any errors in doing + * so, but assuming seeking works, this means you can immediately use this + * with a different IMG_isTYPE function, or load the image without further + * seeking. + * + * You do not need to call this function to load data; SDL_image can work to + * determine file type in many cases in its standard load functions. + * + * \param src a seekable/readable SDL_IOStream to provide image data. + * \returns true if this is SVG data, false otherwise. + * + * \since This function is available since SDL_image 3.0.0. + * + * \sa IMG_isANI + * \sa IMG_isAVIF + * \sa IMG_isBMP + * \sa IMG_isCUR + * \sa IMG_isGIF + * \sa IMG_isICO + * \sa IMG_isJPG + * \sa IMG_isJXL + * \sa IMG_isLBM + * \sa IMG_isPCX + * \sa IMG_isPNG + * \sa IMG_isPNM + * \sa IMG_isQOI + * \sa IMG_isTIF + * \sa IMG_isWEBP + * \sa IMG_isXCF + * \sa IMG_isXPM + * \sa IMG_isXV + */ +extern SDL_DECLSPEC bool SDLCALL IMG_isSVG(SDL_IOStream *src); + /** * Detect TIFF image data on a readable/seekable SDL_IOStream. * @@ -947,30 +1139,75 @@ extern SDL_DECLSPEC bool SDLCALL IMG_isQOI(SDL_IOStream *src); * determine file type in many cases in its standard load functions. * * \param src a seekable/readable SDL_IOStream to provide image data. - * \returns non-zero if this is TIFF data, zero otherwise. + * \returns true if this is TIFF data, false otherwise. * * \since This function is available since SDL_image 3.0.0. * + * \sa IMG_isANI * \sa IMG_isAVIF - * \sa IMG_isICO - * \sa IMG_isCUR * \sa IMG_isBMP + * \sa IMG_isCUR * \sa IMG_isGIF + * \sa IMG_isICO * \sa IMG_isJPG * \sa IMG_isJXL * \sa IMG_isLBM * \sa IMG_isPCX * \sa IMG_isPNG * \sa IMG_isPNM - * \sa IMG_isSVG * \sa IMG_isQOI + * \sa IMG_isSVG + * \sa IMG_isWEBP * \sa IMG_isXCF * \sa IMG_isXPM * \sa IMG_isXV - * \sa IMG_isWEBP */ extern SDL_DECLSPEC bool SDLCALL IMG_isTIF(SDL_IOStream *src); +/** + * Detect WEBP image data on a readable/seekable SDL_IOStream. + * + * This function attempts to determine if a file is a given filetype, reading + * the least amount possible from the SDL_IOStream (usually a few bytes). + * + * There is no distinction made between "not the filetype in question" and + * basic i/o errors. + * + * This function will always attempt to seek `src` back to where it started + * when this function was called, but it will not report any errors in doing + * so, but assuming seeking works, this means you can immediately use this + * with a different IMG_isTYPE function, or load the image without further + * seeking. + * + * You do not need to call this function to load data; SDL_image can work to + * determine file type in many cases in its standard load functions. + * + * \param src a seekable/readable SDL_IOStream to provide image data. + * \returns true if this is WEBP data, false otherwise. + * + * \since This function is available since SDL_image 3.0.0. + * + * \sa IMG_isANI + * \sa IMG_isAVIF + * \sa IMG_isBMP + * \sa IMG_isCUR + * \sa IMG_isGIF + * \sa IMG_isICO + * \sa IMG_isJPG + * \sa IMG_isJXL + * \sa IMG_isLBM + * \sa IMG_isPCX + * \sa IMG_isPNG + * \sa IMG_isPNM + * \sa IMG_isQOI + * \sa IMG_isSVG + * \sa IMG_isTIF + * \sa IMG_isXCF + * \sa IMG_isXPM + * \sa IMG_isXV + */ +extern SDL_DECLSPEC bool SDLCALL IMG_isWEBP(SDL_IOStream *src); + /** * Detect XCF image data on a readable/seekable SDL_IOStream. * @@ -990,27 +1227,28 @@ extern SDL_DECLSPEC bool SDLCALL IMG_isTIF(SDL_IOStream *src); * determine file type in many cases in its standard load functions. * * \param src a seekable/readable SDL_IOStream to provide image data. - * \returns non-zero if this is XCF data, zero otherwise. + * \returns true if this is XCF data, false otherwise. * * \since This function is available since SDL_image 3.0.0. * + * \sa IMG_isANI * \sa IMG_isAVIF - * \sa IMG_isICO - * \sa IMG_isCUR * \sa IMG_isBMP + * \sa IMG_isCUR * \sa IMG_isGIF + * \sa IMG_isICO * \sa IMG_isJPG * \sa IMG_isJXL * \sa IMG_isLBM * \sa IMG_isPCX * \sa IMG_isPNG * \sa IMG_isPNM - * \sa IMG_isSVG * \sa IMG_isQOI + * \sa IMG_isSVG * \sa IMG_isTIF + * \sa IMG_isWEBP * \sa IMG_isXPM * \sa IMG_isXV - * \sa IMG_isWEBP */ extern SDL_DECLSPEC bool SDLCALL IMG_isXCF(SDL_IOStream *src); @@ -1033,27 +1271,28 @@ extern SDL_DECLSPEC bool SDLCALL IMG_isXCF(SDL_IOStream *src); * determine file type in many cases in its standard load functions. * * \param src a seekable/readable SDL_IOStream to provide image data. - * \returns non-zero if this is XPM data, zero otherwise. + * \returns true if this is XPM data, false otherwise. * * \since This function is available since SDL_image 3.0.0. * + * \sa IMG_isANI * \sa IMG_isAVIF - * \sa IMG_isICO - * \sa IMG_isCUR * \sa IMG_isBMP + * \sa IMG_isCUR * \sa IMG_isGIF + * \sa IMG_isICO * \sa IMG_isJPG * \sa IMG_isJXL * \sa IMG_isLBM * \sa IMG_isPCX * \sa IMG_isPNG * \sa IMG_isPNM - * \sa IMG_isSVG * \sa IMG_isQOI + * \sa IMG_isSVG * \sa IMG_isTIF + * \sa IMG_isWEBP * \sa IMG_isXCF * \sa IMG_isXV - * \sa IMG_isWEBP */ extern SDL_DECLSPEC bool SDLCALL IMG_isXPM(SDL_IOStream *src); @@ -1076,73 +1315,31 @@ extern SDL_DECLSPEC bool SDLCALL IMG_isXPM(SDL_IOStream *src); * determine file type in many cases in its standard load functions. * * \param src a seekable/readable SDL_IOStream to provide image data. - * \returns non-zero if this is XV data, zero otherwise. + * \returns true if this is XV data, false otherwise. * * \since This function is available since SDL_image 3.0.0. * + * \sa IMG_isANI * \sa IMG_isAVIF - * \sa IMG_isICO - * \sa IMG_isCUR * \sa IMG_isBMP + * \sa IMG_isCUR * \sa IMG_isGIF + * \sa IMG_isICO * \sa IMG_isJPG * \sa IMG_isJXL * \sa IMG_isLBM * \sa IMG_isPCX * \sa IMG_isPNG * \sa IMG_isPNM - * \sa IMG_isSVG * \sa IMG_isQOI + * \sa IMG_isSVG * \sa IMG_isTIF + * \sa IMG_isWEBP * \sa IMG_isXCF * \sa IMG_isXPM - * \sa IMG_isWEBP */ extern SDL_DECLSPEC bool SDLCALL IMG_isXV(SDL_IOStream *src); -/** - * Detect WEBP image data on a readable/seekable SDL_IOStream. - * - * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_IOStream (usually a few bytes). - * - * There is no distinction made between "not the filetype in question" and - * basic i/o errors. - * - * This function will always attempt to seek `src` back to where it started - * when this function was called, but it will not report any errors in doing - * so, but assuming seeking works, this means you can immediately use this - * with a different IMG_isTYPE function, or load the image without further - * seeking. - * - * You do not need to call this function to load data; SDL_image can work to - * determine file type in many cases in its standard load functions. - * - * \param src a seekable/readable SDL_IOStream to provide image data. - * \returns non-zero if this is WEBP data, zero otherwise. - * - * \since This function is available since SDL_image 3.0.0. - * - * \sa IMG_isAVIF - * \sa IMG_isICO - * \sa IMG_isCUR - * \sa IMG_isBMP - * \sa IMG_isGIF - * \sa IMG_isJPG - * \sa IMG_isJXL - * \sa IMG_isLBM - * \sa IMG_isPCX - * \sa IMG_isPNG - * \sa IMG_isPNM - * \sa IMG_isSVG - * \sa IMG_isQOI - * \sa IMG_isTIF - * \sa IMG_isXCF - * \sa IMG_isXPM - * \sa IMG_isXV - */ -extern SDL_DECLSPEC bool SDLCALL IMG_isWEBP(SDL_IOStream *src); - /** * Load a AVIF image directly. * @@ -1156,95 +1353,27 @@ extern SDL_DECLSPEC bool SDLCALL IMG_isWEBP(SDL_IOStream *src); * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadICO_IO - * \sa IMG_LoadCUR_IO * \sa IMG_LoadBMP_IO + * \sa IMG_LoadCUR_IO * \sa IMG_LoadGIF_IO + * \sa IMG_LoadICO_IO * \sa IMG_LoadJPG_IO * \sa IMG_LoadJXL_IO * \sa IMG_LoadLBM_IO * \sa IMG_LoadPCX_IO * \sa IMG_LoadPNG_IO * \sa IMG_LoadPNM_IO - * \sa IMG_LoadSVG_IO * \sa IMG_LoadQOI_IO + * \sa IMG_LoadSVG_IO * \sa IMG_LoadTGA_IO * \sa IMG_LoadTIF_IO + * \sa IMG_LoadWEBP_IO * \sa IMG_LoadXCF_IO * \sa IMG_LoadXPM_IO * \sa IMG_LoadXV_IO - * \sa IMG_LoadWEBP_IO */ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadAVIF_IO(SDL_IOStream *src); -/** - * Load a ICO image directly. - * - * If you know you definitely have a ICO image, you can call this function, - * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_IOStream - * interface available here. - * - * \param src an SDL_IOStream to load image data from. - * \returns SDL surface, or NULL on error. - * - * \since This function is available since SDL_image 3.0.0. - * - * \sa IMG_LoadAVIF_IO - * \sa IMG_LoadCUR_IO - * \sa IMG_LoadBMP_IO - * \sa IMG_LoadGIF_IO - * \sa IMG_LoadJPG_IO - * \sa IMG_LoadJXL_IO - * \sa IMG_LoadLBM_IO - * \sa IMG_LoadPCX_IO - * \sa IMG_LoadPNG_IO - * \sa IMG_LoadPNM_IO - * \sa IMG_LoadSVG_IO - * \sa IMG_LoadQOI_IO - * \sa IMG_LoadTGA_IO - * \sa IMG_LoadTIF_IO - * \sa IMG_LoadXCF_IO - * \sa IMG_LoadXPM_IO - * \sa IMG_LoadXV_IO - * \sa IMG_LoadWEBP_IO - */ -extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadICO_IO(SDL_IOStream *src); - -/** - * Load a CUR image directly. - * - * If you know you definitely have a CUR image, you can call this function, - * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_IOStream - * interface available here. - * - * \param src an SDL_IOStream to load image data from. - * \returns SDL surface, or NULL on error. - * - * \since This function is available since SDL_image 3.0.0. - * - * \sa IMG_LoadAVIF_IO - * \sa IMG_LoadICO_IO - * \sa IMG_LoadBMP_IO - * \sa IMG_LoadGIF_IO - * \sa IMG_LoadJPG_IO - * \sa IMG_LoadJXL_IO - * \sa IMG_LoadLBM_IO - * \sa IMG_LoadPCX_IO - * \sa IMG_LoadPNG_IO - * \sa IMG_LoadPNM_IO - * \sa IMG_LoadSVG_IO - * \sa IMG_LoadQOI_IO - * \sa IMG_LoadTGA_IO - * \sa IMG_LoadTIF_IO - * \sa IMG_LoadXCF_IO - * \sa IMG_LoadXPM_IO - * \sa IMG_LoadXV_IO - * \sa IMG_LoadWEBP_IO - */ -extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadCUR_IO(SDL_IOStream *src); - /** * Load a BMP image directly. * @@ -1259,26 +1388,60 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadCUR_IO(SDL_IOStream *src); * \since This function is available since SDL_image 3.0.0. * * \sa IMG_LoadAVIF_IO - * \sa IMG_LoadICO_IO * \sa IMG_LoadCUR_IO * \sa IMG_LoadGIF_IO + * \sa IMG_LoadICO_IO * \sa IMG_LoadJPG_IO * \sa IMG_LoadJXL_IO * \sa IMG_LoadLBM_IO * \sa IMG_LoadPCX_IO * \sa IMG_LoadPNG_IO * \sa IMG_LoadPNM_IO - * \sa IMG_LoadSVG_IO * \sa IMG_LoadQOI_IO + * \sa IMG_LoadSVG_IO * \sa IMG_LoadTGA_IO * \sa IMG_LoadTIF_IO + * \sa IMG_LoadWEBP_IO * \sa IMG_LoadXCF_IO * \sa IMG_LoadXPM_IO * \sa IMG_LoadXV_IO - * \sa IMG_LoadWEBP_IO */ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadBMP_IO(SDL_IOStream *src); +/** + * Load a CUR image directly. + * + * If you know you definitely have a CUR image, you can call this function, + * which will skip SDL_image's file format detection routines. Generally it's + * better to use the abstract interfaces; also, there is only an SDL_IOStream + * interface available here. + * + * \param src an SDL_IOStream to load image data from. + * \returns SDL surface, or NULL on error. + * + * \since This function is available since SDL_image 3.0.0. + * + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadWEBP_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadCUR_IO(SDL_IOStream *src); + /** * Load a GIF image directly. * @@ -1293,26 +1456,60 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadBMP_IO(SDL_IOStream *src); * \since This function is available since SDL_image 3.0.0. * * \sa IMG_LoadAVIF_IO - * \sa IMG_LoadICO_IO - * \sa IMG_LoadCUR_IO * \sa IMG_LoadBMP_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadICO_IO * \sa IMG_LoadJPG_IO * \sa IMG_LoadJXL_IO * \sa IMG_LoadLBM_IO * \sa IMG_LoadPCX_IO * \sa IMG_LoadPNG_IO * \sa IMG_LoadPNM_IO - * \sa IMG_LoadSVG_IO * \sa IMG_LoadQOI_IO + * \sa IMG_LoadSVG_IO * \sa IMG_LoadTGA_IO * \sa IMG_LoadTIF_IO + * \sa IMG_LoadWEBP_IO * \sa IMG_LoadXCF_IO * \sa IMG_LoadXPM_IO * \sa IMG_LoadXV_IO - * \sa IMG_LoadWEBP_IO */ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadGIF_IO(SDL_IOStream *src); +/** + * Load a ICO image directly. + * + * If you know you definitely have a ICO image, you can call this function, + * which will skip SDL_image's file format detection routines. Generally it's + * better to use the abstract interfaces; also, there is only an SDL_IOStream + * interface available here. + * + * \param src an SDL_IOStream to load image data from. + * \returns SDL surface, or NULL on error. + * + * \since This function is available since SDL_image 3.0.0. + * + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadWEBP_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadICO_IO(SDL_IOStream *src); + /** * Load a JPG image directly. * @@ -1327,23 +1524,23 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadGIF_IO(SDL_IOStream *src); * \since This function is available since SDL_image 3.0.0. * * \sa IMG_LoadAVIF_IO - * \sa IMG_LoadICO_IO - * \sa IMG_LoadCUR_IO * \sa IMG_LoadBMP_IO + * \sa IMG_LoadCUR_IO * \sa IMG_LoadGIF_IO + * \sa IMG_LoadICO_IO * \sa IMG_LoadJXL_IO * \sa IMG_LoadLBM_IO * \sa IMG_LoadPCX_IO * \sa IMG_LoadPNG_IO * \sa IMG_LoadPNM_IO - * \sa IMG_LoadSVG_IO * \sa IMG_LoadQOI_IO + * \sa IMG_LoadSVG_IO * \sa IMG_LoadTGA_IO * \sa IMG_LoadTIF_IO + * \sa IMG_LoadWEBP_IO * \sa IMG_LoadXCF_IO * \sa IMG_LoadXPM_IO * \sa IMG_LoadXV_IO - * \sa IMG_LoadWEBP_IO */ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadJPG_IO(SDL_IOStream *src); @@ -1361,23 +1558,23 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadJPG_IO(SDL_IOStream *src); * \since This function is available since SDL_image 3.0.0. * * \sa IMG_LoadAVIF_IO - * \sa IMG_LoadICO_IO - * \sa IMG_LoadCUR_IO * \sa IMG_LoadBMP_IO + * \sa IMG_LoadCUR_IO * \sa IMG_LoadGIF_IO + * \sa IMG_LoadICO_IO * \sa IMG_LoadJPG_IO * \sa IMG_LoadLBM_IO * \sa IMG_LoadPCX_IO * \sa IMG_LoadPNG_IO * \sa IMG_LoadPNM_IO - * \sa IMG_LoadSVG_IO * \sa IMG_LoadQOI_IO + * \sa IMG_LoadSVG_IO * \sa IMG_LoadTGA_IO * \sa IMG_LoadTIF_IO + * \sa IMG_LoadWEBP_IO * \sa IMG_LoadXCF_IO * \sa IMG_LoadXPM_IO * \sa IMG_LoadXV_IO - * \sa IMG_LoadWEBP_IO */ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadJXL_IO(SDL_IOStream *src); @@ -1395,23 +1592,23 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadJXL_IO(SDL_IOStream *src); * \since This function is available since SDL_image 3.0.0. * * \sa IMG_LoadAVIF_IO - * \sa IMG_LoadICO_IO - * \sa IMG_LoadCUR_IO * \sa IMG_LoadBMP_IO + * \sa IMG_LoadCUR_IO * \sa IMG_LoadGIF_IO + * \sa IMG_LoadICO_IO * \sa IMG_LoadJPG_IO * \sa IMG_LoadJXL_IO * \sa IMG_LoadPCX_IO * \sa IMG_LoadPNG_IO * \sa IMG_LoadPNM_IO - * \sa IMG_LoadSVG_IO * \sa IMG_LoadQOI_IO + * \sa IMG_LoadSVG_IO * \sa IMG_LoadTGA_IO * \sa IMG_LoadTIF_IO + * \sa IMG_LoadWEBP_IO * \sa IMG_LoadXCF_IO * \sa IMG_LoadXPM_IO * \sa IMG_LoadXV_IO - * \sa IMG_LoadWEBP_IO */ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadLBM_IO(SDL_IOStream *src); @@ -1429,23 +1626,23 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadLBM_IO(SDL_IOStream *src); * \since This function is available since SDL_image 3.0.0. * * \sa IMG_LoadAVIF_IO - * \sa IMG_LoadICO_IO - * \sa IMG_LoadCUR_IO * \sa IMG_LoadBMP_IO + * \sa IMG_LoadCUR_IO * \sa IMG_LoadGIF_IO + * \sa IMG_LoadICO_IO * \sa IMG_LoadJPG_IO * \sa IMG_LoadJXL_IO * \sa IMG_LoadLBM_IO * \sa IMG_LoadPNG_IO * \sa IMG_LoadPNM_IO - * \sa IMG_LoadSVG_IO * \sa IMG_LoadQOI_IO + * \sa IMG_LoadSVG_IO * \sa IMG_LoadTGA_IO * \sa IMG_LoadTIF_IO + * \sa IMG_LoadWEBP_IO * \sa IMG_LoadXCF_IO * \sa IMG_LoadXPM_IO * \sa IMG_LoadXV_IO - * \sa IMG_LoadWEBP_IO */ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadPCX_IO(SDL_IOStream *src); @@ -1463,23 +1660,23 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadPCX_IO(SDL_IOStream *src); * \since This function is available since SDL_image 3.0.0. * * \sa IMG_LoadAVIF_IO - * \sa IMG_LoadICO_IO - * \sa IMG_LoadCUR_IO * \sa IMG_LoadBMP_IO + * \sa IMG_LoadCUR_IO * \sa IMG_LoadGIF_IO + * \sa IMG_LoadICO_IO * \sa IMG_LoadJPG_IO * \sa IMG_LoadJXL_IO * \sa IMG_LoadLBM_IO * \sa IMG_LoadPCX_IO * \sa IMG_LoadPNM_IO - * \sa IMG_LoadSVG_IO * \sa IMG_LoadQOI_IO + * \sa IMG_LoadSVG_IO * \sa IMG_LoadTGA_IO * \sa IMG_LoadTIF_IO + * \sa IMG_LoadWEBP_IO * \sa IMG_LoadXCF_IO * \sa IMG_LoadXPM_IO * \sa IMG_LoadXV_IO - * \sa IMG_LoadWEBP_IO */ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNG_IO(SDL_IOStream *src); @@ -1497,23 +1694,23 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNG_IO(SDL_IOStream *src); * \since This function is available since SDL_image 3.0.0. * * \sa IMG_LoadAVIF_IO - * \sa IMG_LoadICO_IO - * \sa IMG_LoadCUR_IO * \sa IMG_LoadBMP_IO + * \sa IMG_LoadCUR_IO * \sa IMG_LoadGIF_IO + * \sa IMG_LoadICO_IO * \sa IMG_LoadJPG_IO * \sa IMG_LoadJXL_IO * \sa IMG_LoadLBM_IO * \sa IMG_LoadPCX_IO * \sa IMG_LoadPNG_IO - * \sa IMG_LoadSVG_IO * \sa IMG_LoadQOI_IO + * \sa IMG_LoadSVG_IO * \sa IMG_LoadTGA_IO * \sa IMG_LoadTIF_IO + * \sa IMG_LoadWEBP_IO * \sa IMG_LoadXCF_IO * \sa IMG_LoadXPM_IO * \sa IMG_LoadXV_IO - * \sa IMG_LoadWEBP_IO */ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNM_IO(SDL_IOStream *src); @@ -1531,10 +1728,10 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNM_IO(SDL_IOStream *src); * \since This function is available since SDL_image 3.0.0. * * \sa IMG_LoadAVIF_IO - * \sa IMG_LoadICO_IO - * \sa IMG_LoadCUR_IO * \sa IMG_LoadBMP_IO + * \sa IMG_LoadCUR_IO * \sa IMG_LoadGIF_IO + * \sa IMG_LoadICO_IO * \sa IMG_LoadJPG_IO * \sa IMG_LoadJXL_IO * \sa IMG_LoadLBM_IO @@ -1542,253 +1739,16 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNM_IO(SDL_IOStream *src); * \sa IMG_LoadPNG_IO * \sa IMG_LoadPNM_IO * \sa IMG_LoadQOI_IO + * \sa IMG_LoadSizedSVG_IO * \sa IMG_LoadTGA_IO * \sa IMG_LoadTIF_IO + * \sa IMG_LoadWEBP_IO * \sa IMG_LoadXCF_IO * \sa IMG_LoadXPM_IO * \sa IMG_LoadXV_IO - * \sa IMG_LoadWEBP_IO */ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadSVG_IO(SDL_IOStream *src); -/** - * Load a QOI image directly. - * - * If you know you definitely have a QOI image, you can call this function, - * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_IOStream - * interface available here. - * - * \param src an SDL_IOStream to load image data from. - * \returns SDL surface, or NULL on error. - * - * \since This function is available since SDL_image 3.0.0. - * - * \sa IMG_LoadAVIF_IO - * \sa IMG_LoadICO_IO - * \sa IMG_LoadCUR_IO - * \sa IMG_LoadBMP_IO - * \sa IMG_LoadGIF_IO - * \sa IMG_LoadJPG_IO - * \sa IMG_LoadJXL_IO - * \sa IMG_LoadLBM_IO - * \sa IMG_LoadPCX_IO - * \sa IMG_LoadPNG_IO - * \sa IMG_LoadPNM_IO - * \sa IMG_LoadSVG_IO - * \sa IMG_LoadTGA_IO - * \sa IMG_LoadTIF_IO - * \sa IMG_LoadXCF_IO - * \sa IMG_LoadXPM_IO - * \sa IMG_LoadXV_IO - * \sa IMG_LoadWEBP_IO - */ -extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadQOI_IO(SDL_IOStream *src); - -/** - * Load a TGA image directly. - * - * If you know you definitely have a TGA image, you can call this function, - * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_IOStream - * interface available here. - * - * \param src an SDL_IOStream to load image data from. - * \returns SDL surface, or NULL on error. - * - * \since This function is available since SDL_image 3.0.0. - * - * \sa IMG_LoadAVIF_IO - * \sa IMG_LoadICO_IO - * \sa IMG_LoadCUR_IO - * \sa IMG_LoadBMP_IO - * \sa IMG_LoadGIF_IO - * \sa IMG_LoadJPG_IO - * \sa IMG_LoadJXL_IO - * \sa IMG_LoadLBM_IO - * \sa IMG_LoadPCX_IO - * \sa IMG_LoadPNG_IO - * \sa IMG_LoadPNM_IO - * \sa IMG_LoadSVG_IO - * \sa IMG_LoadQOI_IO - * \sa IMG_LoadTIF_IO - * \sa IMG_LoadXCF_IO - * \sa IMG_LoadXPM_IO - * \sa IMG_LoadXV_IO - * \sa IMG_LoadWEBP_IO - */ -extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadTGA_IO(SDL_IOStream *src); - -/** - * Load a TIFF image directly. - * - * If you know you definitely have a TIFF image, you can call this function, - * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_IOStream - * interface available here. - * - * \param src an SDL_IOStream to load image data from. - * \returns SDL surface, or NULL on error. - * - * \since This function is available since SDL_image 3.0.0. - * - * \sa IMG_LoadAVIF_IO - * \sa IMG_LoadICO_IO - * \sa IMG_LoadCUR_IO - * \sa IMG_LoadBMP_IO - * \sa IMG_LoadGIF_IO - * \sa IMG_LoadJPG_IO - * \sa IMG_LoadJXL_IO - * \sa IMG_LoadLBM_IO - * \sa IMG_LoadPCX_IO - * \sa IMG_LoadPNG_IO - * \sa IMG_LoadPNM_IO - * \sa IMG_LoadSVG_IO - * \sa IMG_LoadQOI_IO - * \sa IMG_LoadTGA_IO - * \sa IMG_LoadXCF_IO - * \sa IMG_LoadXPM_IO - * \sa IMG_LoadXV_IO - * \sa IMG_LoadWEBP_IO - */ -extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadTIF_IO(SDL_IOStream *src); - -/** - * Load a XCF image directly. - * - * If you know you definitely have a XCF image, you can call this function, - * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_IOStream - * interface available here. - * - * \param src an SDL_IOStream to load image data from. - * \returns SDL surface, or NULL on error. - * - * \since This function is available since SDL_image 3.0.0. - * - * \sa IMG_LoadAVIF_IO - * \sa IMG_LoadICO_IO - * \sa IMG_LoadCUR_IO - * \sa IMG_LoadBMP_IO - * \sa IMG_LoadGIF_IO - * \sa IMG_LoadJPG_IO - * \sa IMG_LoadJXL_IO - * \sa IMG_LoadLBM_IO - * \sa IMG_LoadPCX_IO - * \sa IMG_LoadPNG_IO - * \sa IMG_LoadPNM_IO - * \sa IMG_LoadSVG_IO - * \sa IMG_LoadQOI_IO - * \sa IMG_LoadTGA_IO - * \sa IMG_LoadTIF_IO - * \sa IMG_LoadXPM_IO - * \sa IMG_LoadXV_IO - * \sa IMG_LoadWEBP_IO - */ -extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadXCF_IO(SDL_IOStream *src); - -/** - * Load a XPM image directly. - * - * If you know you definitely have a XPM image, you can call this function, - * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_IOStream - * interface available here. - * - * \param src an SDL_IOStream to load image data from. - * \returns SDL surface, or NULL on error. - * - * \since This function is available since SDL_image 3.0.0. - * - * \sa IMG_LoadAVIF_IO - * \sa IMG_LoadICO_IO - * \sa IMG_LoadCUR_IO - * \sa IMG_LoadBMP_IO - * \sa IMG_LoadGIF_IO - * \sa IMG_LoadJPG_IO - * \sa IMG_LoadJXL_IO - * \sa IMG_LoadLBM_IO - * \sa IMG_LoadPCX_IO - * \sa IMG_LoadPNG_IO - * \sa IMG_LoadPNM_IO - * \sa IMG_LoadSVG_IO - * \sa IMG_LoadQOI_IO - * \sa IMG_LoadTGA_IO - * \sa IMG_LoadTIF_IO - * \sa IMG_LoadXCF_IO - * \sa IMG_LoadXV_IO - * \sa IMG_LoadWEBP_IO - */ -extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadXPM_IO(SDL_IOStream *src); - -/** - * Load a XV image directly. - * - * If you know you definitely have a XV image, you can call this function, - * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_IOStream - * interface available here. - * - * \param src an SDL_IOStream to load image data from. - * \returns SDL surface, or NULL on error. - * - * \since This function is available since SDL_image 3.0.0. - * - * \sa IMG_LoadAVIF_IO - * \sa IMG_LoadICO_IO - * \sa IMG_LoadCUR_IO - * \sa IMG_LoadBMP_IO - * \sa IMG_LoadGIF_IO - * \sa IMG_LoadJPG_IO - * \sa IMG_LoadJXL_IO - * \sa IMG_LoadLBM_IO - * \sa IMG_LoadPCX_IO - * \sa IMG_LoadPNG_IO - * \sa IMG_LoadPNM_IO - * \sa IMG_LoadSVG_IO - * \sa IMG_LoadQOI_IO - * \sa IMG_LoadTGA_IO - * \sa IMG_LoadTIF_IO - * \sa IMG_LoadXCF_IO - * \sa IMG_LoadXPM_IO - * \sa IMG_LoadWEBP_IO - */ -extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadXV_IO(SDL_IOStream *src); - -/** - * Load a WEBP image directly. - * - * If you know you definitely have a WEBP image, you can call this function, - * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_IOStream - * interface available here. - * - * \param src an SDL_IOStream to load image data from. - * \returns SDL surface, or NULL on error. - * - * \since This function is available since SDL_image 3.0.0. - * - * \sa IMG_LoadAVIF_IO - * \sa IMG_LoadICO_IO - * \sa IMG_LoadCUR_IO - * \sa IMG_LoadBMP_IO - * \sa IMG_LoadGIF_IO - * \sa IMG_LoadJPG_IO - * \sa IMG_LoadJXL_IO - * \sa IMG_LoadLBM_IO - * \sa IMG_LoadPCX_IO - * \sa IMG_LoadPNG_IO - * \sa IMG_LoadPNM_IO - * \sa IMG_LoadSVG_IO - * \sa IMG_LoadQOI_IO - * \sa IMG_LoadTGA_IO - * \sa IMG_LoadTIF_IO - * \sa IMG_LoadXCF_IO - * \sa IMG_LoadXPM_IO - * \sa IMG_LoadXV_IO - */ -extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadWEBP_IO(SDL_IOStream *src); - /** * Load an SVG image, scaled to a specific size. * @@ -1807,9 +1767,249 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadWEBP_IO(SDL_IOStream *src); * \returns a new SDL surface, or NULL on error. * * \since This function is available since SDL_image 3.0.0. + * + * \sa IMG_LoadSVG_IO */ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadSizedSVG_IO(SDL_IOStream *src, int width, int height); +/** + * Load a QOI image directly. + * + * If you know you definitely have a QOI image, you can call this function, + * which will skip SDL_image's file format detection routines. Generally it's + * better to use the abstract interfaces; also, there is only an SDL_IOStream + * interface available here. + * + * \param src an SDL_IOStream to load image data from. + * \returns SDL surface, or NULL on error. + * + * \since This function is available since SDL_image 3.0.0. + * + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadWEBP_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadQOI_IO(SDL_IOStream *src); + +/** + * Load a TGA image directly. + * + * If you know you definitely have a TGA image, you can call this function, + * which will skip SDL_image's file format detection routines. Generally it's + * better to use the abstract interfaces; also, there is only an SDL_IOStream + * interface available here. + * + * \param src an SDL_IOStream to load image data from. + * \returns SDL surface, or NULL on error. + * + * \since This function is available since SDL_image 3.0.0. + * + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadWEBP_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadTGA_IO(SDL_IOStream *src); + +/** + * Load a TIFF image directly. + * + * If you know you definitely have a TIFF image, you can call this function, + * which will skip SDL_image's file format detection routines. Generally it's + * better to use the abstract interfaces; also, there is only an SDL_IOStream + * interface available here. + * + * \param src an SDL_IOStream to load image data from. + * \returns SDL surface, or NULL on error. + * + * \since This function is available since SDL_image 3.0.0. + * + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadWEBP_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadTIF_IO(SDL_IOStream *src); + +/** + * Load a WEBP image directly. + * + * If you know you definitely have a WEBP image, you can call this function, + * which will skip SDL_image's file format detection routines. Generally it's + * better to use the abstract interfaces; also, there is only an SDL_IOStream + * interface available here. + * + * \param src an SDL_IOStream to load image data from. + * \returns SDL surface, or NULL on error. + * + * \since This function is available since SDL_image 3.0.0. + * + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadWEBP_IO(SDL_IOStream *src); + +/** + * Load a XCF image directly. + * + * If you know you definitely have a XCF image, you can call this function, + * which will skip SDL_image's file format detection routines. Generally it's + * better to use the abstract interfaces; also, there is only an SDL_IOStream + * interface available here. + * + * \param src an SDL_IOStream to load image data from. + * \returns SDL surface, or NULL on error. + * + * \since This function is available since SDL_image 3.0.0. + * + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadWEBP_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadXCF_IO(SDL_IOStream *src); + +/** + * Load a XPM image directly. + * + * If you know you definitely have a XPM image, you can call this function, + * which will skip SDL_image's file format detection routines. Generally it's + * better to use the abstract interfaces; also, there is only an SDL_IOStream + * interface available here. + * + * \param src an SDL_IOStream to load image data from. + * \returns SDL surface, or NULL on error. + * + * \since This function is available since SDL_image 3.0.0. + * + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadWEBP_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXV_IO + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadXPM_IO(SDL_IOStream *src); + +/** + * Load a XV image directly. + * + * If you know you definitely have a XV image, you can call this function, + * which will skip SDL_image's file format detection routines. Generally it's + * better to use the abstract interfaces; also, there is only an SDL_IOStream + * interface available here. + * + * \param src an SDL_IOStream to load image data from. + * \returns SDL surface, or NULL on error. + * + * \since This function is available since SDL_image 3.0.0. + * + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadWEBP_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_LoadXV_IO(SDL_IOStream *src); + /** * Load an XPM image from a memory array. * @@ -1848,6 +2048,67 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_ReadXPMFromArray(char **xpm); */ extern SDL_DECLSPEC SDL_Surface * SDLCALL IMG_ReadXPMFromArrayToRGB888(char **xpm); +/** + * Save an SDL_Surface into an image file. + * + * If the file already exists, it will be overwritten. + * + * For formats that accept a quality, a default quality of 90 will be used. + * + * \param surface the SDL surface to save. + * \param file path on the filesystem to write new file to. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_SaveTyped_IO + * \sa IMG_SaveAVIF + * \sa IMG_SaveBMP + * \sa IMG_SaveCUR + * \sa IMG_SaveGIF + * \sa IMG_SaveICO + * \sa IMG_SaveJPG + * \sa IMG_SavePNG + * \sa IMG_SaveTGA + * \sa IMG_SaveWEBP + */ +extern SDL_DECLSPEC bool SDLCALL IMG_Save(SDL_Surface *surface, const char *file); + +/** + * Save an SDL_Surface into formatted image data, via an SDL_IOStream. + * + * If you just want to save to a filename, you can use IMG_Save() instead. + * + * If `closeio` is true, `dst` will be closed before returning, whether this + * function succeeds or not. + * + * For formats that accept a quality, a default quality of 90 will be used. + * + * \param surface the SDL surface to save. + * \param dst the SDL_IOStream to save the image data to. + * \param closeio true to close/free the SDL_IOStream before returning, false + * to leave it open. + * \param type a filename extension that represent this data ("BMP", "GIF", + * "PNG", etc). + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_Save + * \sa IMG_SaveAVIF_IO + * \sa IMG_SaveBMP_IO + * \sa IMG_SaveCUR_IO + * \sa IMG_SaveGIF_IO + * \sa IMG_SaveICO_IO + * \sa IMG_SaveJPG_IO + * \sa IMG_SavePNG_IO + * \sa IMG_SaveTGA_IO + * \sa IMG_SaveWEBP_IO + */ +extern SDL_DECLSPEC bool SDLCALL IMG_SaveTyped_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio, const char *type); + /** * Save an SDL_Surface into a AVIF image file. * @@ -1890,7 +2151,7 @@ extern SDL_DECLSPEC bool SDLCALL IMG_SaveAVIF(SDL_Surface *surface, const char * extern SDL_DECLSPEC bool SDLCALL IMG_SaveAVIF_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio, int quality); /** - * Save an SDL_Surface into a PNG image file. + * Save an SDL_Surface into a BMP image file. * * If the file already exists, it will be overwritten. * @@ -1899,16 +2160,16 @@ extern SDL_DECLSPEC bool SDLCALL IMG_SaveAVIF_IO(SDL_Surface *surface, SDL_IOStr * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \since This function is available since SDL_image 3.0.0. + * \since This function is available since SDL_image 3.4.0. * - * \sa IMG_SavePNG_IO + * \sa IMG_SaveBMP_IO */ -extern SDL_DECLSPEC bool SDLCALL IMG_SavePNG(SDL_Surface *surface, const char *file); +extern SDL_DECLSPEC bool SDLCALL IMG_SaveBMP(SDL_Surface *surface, const char *file); /** - * Save an SDL_Surface into PNG image data, via an SDL_IOStream. + * Save an SDL_Surface into BMP image data, via an SDL_IOStream. * - * If you just want to save to a filename, you can use IMG_SavePNG() instead. + * If you just want to save to a filename, you can use IMG_SaveBMP() instead. * * If `closeio` is true, `dst` will be closed before returning, whether this * function succeeds or not. @@ -1920,11 +2181,122 @@ extern SDL_DECLSPEC bool SDLCALL IMG_SavePNG(SDL_Surface *surface, const char *f * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \since This function is available since SDL_image 3.0.0. + * \since This function is available since SDL_image 3.4.0. * - * \sa IMG_SavePNG + * \sa IMG_SaveBMP */ -extern SDL_DECLSPEC bool SDLCALL IMG_SavePNG_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio); +extern SDL_DECLSPEC bool SDLCALL IMG_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio); + +/** + * Save an SDL_Surface into a CUR image file. + * + * If the file already exists, it will be overwritten. + * + * \param surface the SDL surface to save. + * \param file path on the filesystem to write new file to. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_SaveCUR_IO + */ +extern SDL_DECLSPEC bool SDLCALL IMG_SaveCUR(SDL_Surface *surface, const char *file); + +/** + * Save an SDL_Surface into CUR image data, via an SDL_IOStream. + * + * If you just want to save to a filename, you can use IMG_SaveCUR() instead. + * + * If `closeio` is true, `dst` will be closed before returning, whether this + * function succeeds or not. + * + * \param surface the SDL surface to save. + * \param dst the SDL_IOStream to save the image data to. + * \param closeio true to close/free the SDL_IOStream before returning, false + * to leave it open. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_SaveCUR + */ +extern SDL_DECLSPEC bool SDLCALL IMG_SaveCUR_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio); + +/** + * Save an SDL_Surface into a GIF image file. + * + * If the file already exists, it will be overwritten. + * + * \param surface the SDL surface to save. + * \param file path on the filesystem to write new file to. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_SaveGIF_IO + */ +extern SDL_DECLSPEC bool SDLCALL IMG_SaveGIF(SDL_Surface *surface, const char *file); + +/** + * Save an SDL_Surface into GIF image data, via an SDL_IOStream. + * + * If you just want to save to a filename, you can use IMG_SaveGIF() instead. + * + * If `closeio` is true, `dst` will be closed before returning, whether this + * function succeeds or not. + * + * \param surface the SDL surface to save. + * \param dst the SDL_IOStream to save the image data to. + * \param closeio true to close/free the SDL_IOStream before returning, false + * to leave it open. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_SaveGIF + */ +extern SDL_DECLSPEC bool SDLCALL IMG_SaveGIF_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio); + +/** + * Save an SDL_Surface into a ICO image file. + * + * If the file already exists, it will be overwritten. + * + * \param surface the SDL surface to save. + * \param file path on the filesystem to write new file to. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_SaveICO_IO + */ +extern SDL_DECLSPEC bool SDLCALL IMG_SaveICO(SDL_Surface *surface, const char *file); + +/** + * Save an SDL_Surface into ICO image data, via an SDL_IOStream. + * + * If you just want to save to a filename, you can use IMG_SaveICO() instead. + * + * If `closeio` is true, `dst` will be closed before returning, whether this + * function succeeds or not. + * + * \param surface the SDL surface to save. + * \param dst the SDL_IOStream to save the image data to. + * \param closeio true to close/free the SDL_IOStream before returning, false + * to leave it open. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_SaveICO + */ +extern SDL_DECLSPEC bool SDLCALL IMG_SaveICO_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio); /** * Save an SDL_Surface into a JPEG image file. @@ -1968,16 +2340,134 @@ extern SDL_DECLSPEC bool SDLCALL IMG_SaveJPG(SDL_Surface *surface, const char *f extern SDL_DECLSPEC bool SDLCALL IMG_SaveJPG_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio, int quality); /** - * Animated image support + * Save an SDL_Surface into a PNG image file. * - * Currently only animated GIFs and WEBP images are supported. + * If the file already exists, it will be overwritten. + * + * \param surface the SDL surface to save. + * \param file path on the filesystem to write new file to. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.0.0. + * + * \sa IMG_SavePNG_IO + */ +extern SDL_DECLSPEC bool SDLCALL IMG_SavePNG(SDL_Surface *surface, const char *file); + +/** + * Save an SDL_Surface into PNG image data, via an SDL_IOStream. + * + * If you just want to save to a filename, you can use IMG_SavePNG() instead. + * + * If `closeio` is true, `dst` will be closed before returning, whether this + * function succeeds or not. + * + * \param surface the SDL surface to save. + * \param dst the SDL_IOStream to save the image data to. + * \param closeio true to close/free the SDL_IOStream before returning, false + * to leave it open. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.0.0. + * + * \sa IMG_SavePNG + */ +extern SDL_DECLSPEC bool SDLCALL IMG_SavePNG_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio); + +/** + * Save an SDL_Surface into a TGA image file. + * + * If the file already exists, it will be overwritten. + * + * \param surface the SDL surface to save. + * \param file path on the filesystem to write new file to. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_SaveTGA_IO + */ +extern SDL_DECLSPEC bool SDLCALL IMG_SaveTGA(SDL_Surface *surface, const char *file); + +/** + * Save an SDL_Surface into TGA image data, via an SDL_IOStream. + * + * If you just want to save to a filename, you can use IMG_SaveTGA() instead. + * + * If `closeio` is true, `dst` will be closed before returning, whether this + * function succeeds or not. + * + * \param surface the SDL surface to save. + * \param dst the SDL_IOStream to save the image data to. + * \param closeio true to close/free the SDL_IOStream before returning, false + * to leave it open. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_SaveTGA + */ +extern SDL_DECLSPEC bool SDLCALL IMG_SaveTGA_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio); + +/** + * Save an SDL_Surface into a WEBP image file. + * + * If the file already exists, it will be overwritten. + * + * \param surface the SDL surface to save. + * \param file path on the filesystem to write the new file to. + * \param quality between 0 and 100. For lossy, 0 gives the smallest size and + * 100 the largest. For lossless, this parameter is the amount + * of effort put into the compression: 0 is the fastest but + * gives larger files compared to the slowest, but best, 100. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_SaveWEBP_IO + */ +extern SDL_DECLSPEC bool SDLCALL IMG_SaveWEBP(SDL_Surface *surface, const char *file, float quality); + +/** + * Save an SDL_Surface into WEBP image data, via an SDL_IOStream. + * + * If you just want to save to a filename, you can use IMG_SaveWEBP() instead. + * + * If `closeio` is true, `dst` will be closed before returning, whether this + * function succeeds or not. + * + * \param surface the SDL surface to save. + * \param dst the SDL_IOStream to save the image data to. + * \param closeio true to close/free the SDL_IOStream before returning, false + * to leave it open. + * \param quality between 0 and 100. For lossy, 0 gives the smallest size and + * 100 the largest. For lossless, this parameter is the amount + * of effort put into the compression: 0 is the fastest but + * gives larger files compared to the slowest, but best, 100. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_SaveWEBP + */ +extern SDL_DECLSPEC bool SDLCALL IMG_SaveWEBP_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio, float quality); + +/** + * Animated image support */ typedef struct IMG_Animation { - int w, h; - int count; - SDL_Surface **frames; - int *delays; + int w; /**< The width of the frames */ + int h; /**< The height of the frames */ + int count; /**< The number of frames */ + SDL_Surface **frames; /**< An array of frames */ + int *delays; /**< An array of frame delays, in milliseconds */ } IMG_Animation; /** @@ -1991,6 +2481,14 @@ typedef struct IMG_Animation * * \since This function is available since SDL_image 3.0.0. * + * \sa IMG_CreateAnimatedCursor + * \sa IMG_LoadAnimation_IO + * \sa IMG_LoadAnimationTyped_IO + * \sa IMG_LoadANIAnimation_IO + * \sa IMG_LoadAPNGAnimation_IO + * \sa IMG_LoadAVIFAnimation_IO + * \sa IMG_LoadGIFAnimation_IO + * \sa IMG_LoadWEBPAnimation_IO * \sa IMG_FreeAnimation */ extern SDL_DECLSPEC IMG_Animation * SDLCALL IMG_LoadAnimation(const char *file); @@ -2012,12 +2510,20 @@ extern SDL_DECLSPEC IMG_Animation * SDLCALL IMG_LoadAnimation(const char *file); * * \since This function is available since SDL_image 3.0.0. * + * \sa IMG_CreateAnimatedCursor + * \sa IMG_LoadAnimation + * \sa IMG_LoadAnimationTyped_IO + * \sa IMG_LoadANIAnimation_IO + * \sa IMG_LoadAPNGAnimation_IO + * \sa IMG_LoadAVIFAnimation_IO + * \sa IMG_LoadGIFAnimation_IO + * \sa IMG_LoadWEBPAnimation_IO * \sa IMG_FreeAnimation */ extern SDL_DECLSPEC IMG_Animation * SDLCALL IMG_LoadAnimation_IO(SDL_IOStream *src, bool closeio); /** - * Load an animation from an SDL datasource + * Load an animation from an SDL_IOStream. * * Even though this function accepts a file type, SDL_image may still try * other decoders that are capable of detecting file type from the contents of @@ -2040,26 +2546,101 @@ extern SDL_DECLSPEC IMG_Animation * SDLCALL IMG_LoadAnimation_IO(SDL_IOStream *s * * \since This function is available since SDL_image 3.0.0. * + * \sa IMG_CreateAnimatedCursor * \sa IMG_LoadAnimation * \sa IMG_LoadAnimation_IO + * \sa IMG_LoadANIAnimation_IO + * \sa IMG_LoadAPNGAnimation_IO + * \sa IMG_LoadAVIFAnimation_IO + * \sa IMG_LoadGIFAnimation_IO + * \sa IMG_LoadWEBPAnimation_IO * \sa IMG_FreeAnimation */ extern SDL_DECLSPEC IMG_Animation * SDLCALL IMG_LoadAnimationTyped_IO(SDL_IOStream *src, bool closeio, const char *type); /** - * Dispose of an IMG_Animation and free its resources. + * Load an ANI animation directly from an SDL_IOStream. * - * The provided `anim` pointer is not valid once this call returns. + * If you know you definitely have an ANI image, you can call this function, + * which will skip SDL_image's file format detection routines. Generally, it's + * better to use the abstract interfaces; also, there is only an SDL_IOStream + * interface available here. * - * \param anim IMG_Animation to dispose of. + * When done with the returned animation, the app should dispose of it with a + * call to IMG_FreeAnimation(). * - * \since This function is available since SDL_image 3.0.0. + * \param src an SDL_IOStream from which data will be read. + * \returns a new IMG_Animation, or NULL on error. * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_isANI * \sa IMG_LoadAnimation * \sa IMG_LoadAnimation_IO * \sa IMG_LoadAnimationTyped_IO + * \sa IMG_LoadAPNGAnimation_IO + * \sa IMG_LoadAVIFAnimation_IO + * \sa IMG_LoadGIFAnimation_IO + * \sa IMG_LoadWEBPAnimation_IO + * \sa IMG_FreeAnimation */ -extern SDL_DECLSPEC void SDLCALL IMG_FreeAnimation(IMG_Animation *anim); +extern SDL_DECLSPEC IMG_Animation *SDLCALL IMG_LoadANIAnimation_IO(SDL_IOStream *src); + +/** + * Load an APNG animation directly from an SDL_IOStream. + * + * If you know you definitely have an APNG image, you can call this function, + * which will skip SDL_image's file format detection routines. Generally, it's + * better to use the abstract interfaces; also, there is only an SDL_IOStream + * interface available here. + * + * When done with the returned animation, the app should dispose of it with a + * call to IMG_FreeAnimation(). + * + * \param src an SDL_IOStream from which data will be read. + * \returns a new IMG_Animation, or NULL on error. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_isPNG + * \sa IMG_LoadAnimation + * \sa IMG_LoadAnimation_IO + * \sa IMG_LoadAnimationTyped_IO + * \sa IMG_LoadANIAnimation_IO + * \sa IMG_LoadAVIFAnimation_IO + * \sa IMG_LoadGIFAnimation_IO + * \sa IMG_LoadWEBPAnimation_IO + * \sa IMG_FreeAnimation + */ +extern SDL_DECLSPEC IMG_Animation *SDLCALL IMG_LoadAPNGAnimation_IO(SDL_IOStream *src); + +/** + * Load an AVIF animation directly from an SDL_IOStream. + * + * If you know you definitely have an AVIF animation, you can call this + * function, which will skip SDL_image's file format detection routines. + * Generally it's better to use the abstract interfaces; also, there is only + * an SDL_IOStream interface available here. + * + * When done with the returned animation, the app should dispose of it with a + * call to IMG_FreeAnimation(). + * + * \param src an SDL_IOStream that data will be read from. + * \returns a new IMG_Animation, or NULL on error. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_isAVIF + * \sa IMG_LoadAnimation + * \sa IMG_LoadAnimation_IO + * \sa IMG_LoadAnimationTyped_IO + * \sa IMG_LoadANIAnimation_IO + * \sa IMG_LoadAPNGAnimation_IO + * \sa IMG_LoadGIFAnimation_IO + * \sa IMG_LoadWEBPAnimation_IO + * \sa IMG_FreeAnimation + */ +extern SDL_DECLSPEC IMG_Animation *SDLCALL IMG_LoadAVIFAnimation_IO(SDL_IOStream *src); /** * Load a GIF animation directly. @@ -2074,9 +2655,14 @@ extern SDL_DECLSPEC void SDLCALL IMG_FreeAnimation(IMG_Animation *anim); * * \since This function is available since SDL_image 3.0.0. * + * \sa IMG_isGIF * \sa IMG_LoadAnimation * \sa IMG_LoadAnimation_IO * \sa IMG_LoadAnimationTyped_IO + * \sa IMG_LoadANIAnimation_IO + * \sa IMG_LoadAPNGAnimation_IO + * \sa IMG_LoadAVIFAnimation_IO + * \sa IMG_LoadWEBPAnimation_IO * \sa IMG_FreeAnimation */ extern SDL_DECLSPEC IMG_Animation * SDLCALL IMG_LoadGIFAnimation_IO(SDL_IOStream *src); @@ -2094,13 +2680,643 @@ extern SDL_DECLSPEC IMG_Animation * SDLCALL IMG_LoadGIFAnimation_IO(SDL_IOStream * * \since This function is available since SDL_image 3.0.0. * + * \sa IMG_isWEBP * \sa IMG_LoadAnimation * \sa IMG_LoadAnimation_IO * \sa IMG_LoadAnimationTyped_IO + * \sa IMG_LoadANIAnimation_IO + * \sa IMG_LoadAPNGAnimation_IO + * \sa IMG_LoadAVIFAnimation_IO + * \sa IMG_LoadGIFAnimation_IO * \sa IMG_FreeAnimation */ extern SDL_DECLSPEC IMG_Animation * SDLCALL IMG_LoadWEBPAnimation_IO(SDL_IOStream *src); +/** + * Save an animation to a file. + * + * For formats that accept a quality, a default quality of 90 will be used. + * + * \param anim the animation to save. + * \param file path on the filesystem containing an animated image. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_SaveAnimationTyped_IO + * \sa IMG_SaveANIAnimation_IO + * \sa IMG_SaveAPNGAnimation_IO + * \sa IMG_SaveAVIFAnimation_IO + * \sa IMG_SaveGIFAnimation_IO + * \sa IMG_SaveWEBPAnimation_IO + */ +extern SDL_DECLSPEC bool SDLCALL IMG_SaveAnimation(IMG_Animation *anim, const char *file); + +/** + * Save an animation to an SDL_IOStream. + * + * If you just want to save to a filename, you can use IMG_SaveAnimation() + * instead. + * + * If `closeio` is true, `dst` will be closed before returning, whether this + * function succeeds or not. + * + * For formats that accept a quality, a default quality of 90 will be used. + * + * \param anim the animation to save. + * \param dst an SDL_IOStream that data will be written to. + * \param closeio true to close/free the SDL_IOStream before returning, false + * to leave it open. + * \param type a filename extension that represent this data ("GIF", etc). + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_SaveAnimation + * \sa IMG_SaveANIAnimation_IO + * \sa IMG_SaveAPNGAnimation_IO + * \sa IMG_SaveAVIFAnimation_IO + * \sa IMG_SaveGIFAnimation_IO + * \sa IMG_SaveWEBPAnimation_IO + */ +extern SDL_DECLSPEC bool SDLCALL IMG_SaveAnimationTyped_IO(IMG_Animation *anim, SDL_IOStream *dst, bool closeio, const char *type); + +/** + * Save an animation in ANI format to an SDL_IOStream. + * + * If `closeio` is true, `dst` will be closed before returning, whether this + * function succeeds or not. + * + * \param anim the animation to save. + * \param dst an SDL_IOStream from which data will be written to. + * \param closeio true to close/free the SDL_IOStream before returning, false + * to leave it open. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_SaveAnimation + * \sa IMG_SaveAnimationTyped_IO + * \sa IMG_SaveAPNGAnimation_IO + * \sa IMG_SaveAVIFAnimation_IO + * \sa IMG_SaveGIFAnimation_IO + * \sa IMG_SaveWEBPAnimation_IO + */ +extern SDL_DECLSPEC bool SDLCALL IMG_SaveANIAnimation_IO(IMG_Animation *anim, SDL_IOStream *dst, bool closeio); + +/** + * Save an animation in APNG format to an SDL_IOStream. + * + * If `closeio` is true, `dst` will be closed before returning, whether this + * function succeeds or not. + * + * \param anim the animation to save. + * \param dst an SDL_IOStream from which data will be written to. + * \param closeio true to close/free the SDL_IOStream before returning, false + * to leave it open. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_SaveAnimation + * \sa IMG_SaveAnimationTyped_IO + * \sa IMG_SaveANIAnimation_IO + * \sa IMG_SaveAVIFAnimation_IO + * \sa IMG_SaveGIFAnimation_IO + * \sa IMG_SaveWEBPAnimation_IO + */ +extern SDL_DECLSPEC bool SDLCALL IMG_SaveAPNGAnimation_IO(IMG_Animation *anim, SDL_IOStream *dst, bool closeio); + +/** + * Save an animation in AVIF format to an SDL_IOStream. + * + * If `closeio` is true, `dst` will be closed before returning, whether this + * function succeeds or not. + * + * \param anim the animation to save. + * \param dst an SDL_IOStream from which data will be written to. + * \param closeio true to close/free the SDL_IOStream before returning, false + * to leave it open. + * \param quality the desired quality, ranging between 0 (lowest) and 100 + * (highest). + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_SaveAnimation + * \sa IMG_SaveAnimationTyped_IO + * \sa IMG_SaveANIAnimation_IO + * \sa IMG_SaveAPNGAnimation_IO + * \sa IMG_SaveGIFAnimation_IO + * \sa IMG_SaveWEBPAnimation_IO + */ +extern SDL_DECLSPEC bool SDLCALL IMG_SaveAVIFAnimation_IO(IMG_Animation *anim, SDL_IOStream *dst, bool closeio, int quality); + +/** + * Save an animation in GIF format to an SDL_IOStream. + * + * If `closeio` is true, `dst` will be closed before returning, whether this + * function succeeds or not. + * + * \param anim the animation to save. + * \param dst an SDL_IOStream from which data will be written to. + * \param closeio true to close/free the SDL_IOStream before returning, false + * to leave it open. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_SaveAnimation + * \sa IMG_SaveAnimationTyped_IO + * \sa IMG_SaveANIAnimation_IO + * \sa IMG_SaveAPNGAnimation_IO + * \sa IMG_SaveAVIFAnimation_IO + * \sa IMG_SaveWEBPAnimation_IO + */ +extern SDL_DECLSPEC bool SDLCALL IMG_SaveGIFAnimation_IO(IMG_Animation *anim, SDL_IOStream *dst, bool closeio); + +/** + * Save an animation in WEBP format to an SDL_IOStream. + * + * If `closeio` is true, `dst` will be closed before returning, whether this + * function succeeds or not. + * + * \param anim the animation to save. + * \param dst an SDL_IOStream from which data will be written to. + * \param closeio true to close/free the SDL_IOStream before returning, false + * to leave it open. + * \param quality between 0 and 100. For lossy, 0 gives the smallest size and + * 100 the largest. For lossless, this parameter is the amount + * of effort put into the compression: 0 is the fastest but + * gives larger files compared to the slowest, but best, 100. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_SaveAnimation + * \sa IMG_SaveAnimationTyped_IO + * \sa IMG_SaveANIAnimation_IO + * \sa IMG_SaveAPNGAnimation_IO + * \sa IMG_SaveAVIFAnimation_IO + * \sa IMG_SaveGIFAnimation_IO + */ +extern SDL_DECLSPEC bool SDLCALL IMG_SaveWEBPAnimation_IO(IMG_Animation *anim, SDL_IOStream *dst, bool closeio, int quality); + +/** + * Create an animated cursor from an animation. + * + * \param anim an animation to use to create an animated cursor. + * \param hot_x the x position of the cursor hot spot. + * \param hot_y the y position of the cursor hot spot. + * \returns the new cursor on success or NULL on failure; call SDL_GetError() + * for more information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_LoadAnimation + * \sa IMG_LoadAnimation_IO + * \sa IMG_LoadAnimationTyped_IO + */ +extern SDL_DECLSPEC SDL_Cursor * SDLCALL IMG_CreateAnimatedCursor(IMG_Animation *anim, int hot_x, int hot_y); + +/** + * Dispose of an IMG_Animation and free its resources. + * + * The provided `anim` pointer is not valid once this call returns. + * + * \param anim IMG_Animation to dispose of. + * + * \since This function is available since SDL_image 3.0.0. + * + * \sa IMG_LoadAnimation + * \sa IMG_LoadAnimation_IO + * \sa IMG_LoadAnimationTyped_IO + * \sa IMG_LoadANIAnimation_IO + * \sa IMG_LoadAPNGAnimation_IO + * \sa IMG_LoadAVIFAnimation_IO + * \sa IMG_LoadGIFAnimation_IO + * \sa IMG_LoadWEBPAnimation_IO + */ +extern SDL_DECLSPEC void SDLCALL IMG_FreeAnimation(IMG_Animation *anim); + +/** + * An object representing the encoder context. + */ +typedef struct IMG_AnimationEncoder IMG_AnimationEncoder; + +/** + * Create an encoder to save a series of images to a file. + * + * These animation types are currently supported: + * + * - ANI + * - APNG + * - AVIFS + * - GIF + * - WEBP + * + * The file type is determined from the file extension, e.g. "file.webp" will + * be encoded using WEBP. + * + * \param file the file where the animation will be saved. + * \returns a new IMG_AnimationEncoder, or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_CreateAnimationEncoder_IO + * \sa IMG_CreateAnimationEncoderWithProperties + * \sa IMG_AddAnimationEncoderFrame + * \sa IMG_CloseAnimationEncoder + */ +extern SDL_DECLSPEC IMG_AnimationEncoder * SDLCALL IMG_CreateAnimationEncoder(const char *file); + +/** + * Create an encoder to save a series of images to an IOStream. + * + * These animation types are currently supported: + * + * - ANI + * - APNG + * - AVIFS + * - GIF + * - WEBP + * + * If `closeio` is true, `dst` will be closed before returning if this + * function fails, or when the animation encoder is closed if this function + * succeeds. + * + * \param dst an SDL_IOStream that will be used to save the stream. + * \param closeio true to close the SDL_IOStream when done, false to leave it + * open. + * \param type a filename extension that represent this data ("WEBP", etc). + * \returns a new IMG_AnimationEncoder, or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_CreateAnimationEncoder + * \sa IMG_CreateAnimationEncoderWithProperties + * \sa IMG_AddAnimationEncoderFrame + * \sa IMG_CloseAnimationEncoder + */ +extern SDL_DECLSPEC IMG_AnimationEncoder * SDLCALL IMG_CreateAnimationEncoder_IO(SDL_IOStream *dst, bool closeio, const char *type); + +/** + * Create an animation encoder with the specified properties. + * + * These animation types are currently supported: + * + * - ANI + * - APNG + * - AVIFS + * - GIF + * - WEBP + * + * These are the supported properties: + * + * - `IMG_PROP_ANIMATION_ENCODER_CREATE_FILENAME_STRING`: the file to save, if + * an SDL_IOStream isn't being used. This is required if + * `IMG_PROP_ANIMATION_ENCODER_CREATE_IOSTREAM_POINTER` isn't set. + * - `IMG_PROP_ANIMATION_ENCODER_CREATE_IOSTREAM_POINTER`: an SDL_IOStream + * that will be used to save the stream. This should not be closed until the + * animation encoder is closed. This is required if + * `IMG_PROP_ANIMATION_ENCODER_CREATE_FILENAME_STRING` isn't set. + * - `IMG_PROP_ANIMATION_ENCODER_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN`: true if + * closing the animation encoder should also close the associated + * SDL_IOStream. + * - `IMG_PROP_ANIMATION_ENCODER_CREATE_TYPE_STRING`: the output file type, + * e.g. "webp", defaults to the file extension if + * `IMG_PROP_ANIMATION_ENCODER_CREATE_FILENAME_STRING` is set. + * - `IMG_PROP_ANIMATION_ENCODER_CREATE_QUALITY_NUMBER`: the compression + * quality, in the range of 0 to 100. The higher the number, the higher the + * quality and file size. This defaults to a balanced value for compression + * and quality. + * - `IMG_PROP_ANIMATION_ENCODER_CREATE_TIMEBASE_NUMERATOR_NUMBER`: the + * numerator of the fraction used to multiply the pts to convert it to + * seconds. This defaults to 1. + * - `IMG_PROP_ANIMATION_ENCODER_CREATE_TIMEBASE_DENOMINATOR_NUMBER`: the + * denominator of the fraction used to multiply the pts to convert it to + * seconds. This defaults to 1000. + * + * \param props the properties of the animation encoder. + * \returns a new IMG_AnimationEncoder, or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_CreateAnimationEncoder + * \sa IMG_CreateAnimationEncoder_IO + * \sa IMG_AddAnimationEncoderFrame + * \sa IMG_CloseAnimationEncoder + */ +extern SDL_DECLSPEC IMG_AnimationEncoder * SDLCALL IMG_CreateAnimationEncoderWithProperties(SDL_PropertiesID props); + +#define IMG_PROP_ANIMATION_ENCODER_CREATE_FILENAME_STRING "SDL_image.animation_encoder.create.filename" +#define IMG_PROP_ANIMATION_ENCODER_CREATE_IOSTREAM_POINTER "SDL_image.animation_encoder.create.iostream" +#define IMG_PROP_ANIMATION_ENCODER_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN "SDL_image.animation_encoder.create.iostream.autoclose" +#define IMG_PROP_ANIMATION_ENCODER_CREATE_TYPE_STRING "SDL_image.animation_encoder.create.type" +#define IMG_PROP_ANIMATION_ENCODER_CREATE_QUALITY_NUMBER "SDL_image.animation_encoder.create.quality" +#define IMG_PROP_ANIMATION_ENCODER_CREATE_TIMEBASE_NUMERATOR_NUMBER "SDL_image.animation_encoder.create.timebase.numerator" +#define IMG_PROP_ANIMATION_ENCODER_CREATE_TIMEBASE_DENOMINATOR_NUMBER "SDL_image.animation_encoder.create.timebase.denominator" + +#define IMG_PROP_ANIMATION_ENCODER_CREATE_AVIF_MAX_THREADS_NUMBER "SDL_image.animation_encoder.create.avif.max_threads" +#define IMG_PROP_ANIMATION_ENCODER_CREATE_AVIF_KEYFRAME_INTERVAL_NUMBER "SDL_image.animation_encoder.create.avif.keyframe_interval" +#define IMG_PROP_ANIMATION_ENCODER_CREATE_GIF_USE_LUT_BOOLEAN "SDL_image.animation_encoder.create.gif.use_lut" + +/** + * Add a frame to an animation encoder. + * + * \param encoder the receiving images. + * \param surface the surface to add as the next frame in the animation. + * \param duration the duration of the frame, usually in milliseconds but can + * be other units if the + * `IMG_PROP_ANIMATION_ENCODER_CREATE_TIMEBASE_DENOMINATOR_NUMBER` + * property is set when creating the encoder. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_CreateAnimationEncoder + * \sa IMG_CreateAnimationEncoder_IO + * \sa IMG_CreateAnimationEncoderWithProperties + * \sa IMG_CloseAnimationEncoder + */ +extern SDL_DECLSPEC bool SDLCALL IMG_AddAnimationEncoderFrame(IMG_AnimationEncoder *encoder, SDL_Surface *surface, Uint64 duration); + +/** + * Close an animation encoder, finishing any encoding. + * + * Calling this function frees the animation encoder, and returns the final + * status of the encoding process. + * + * \param encoder the encoder to close. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_CreateAnimationEncoder + * \sa IMG_CreateAnimationEncoder_IO + * \sa IMG_CreateAnimationEncoderWithProperties + */ +extern SDL_DECLSPEC bool SDLCALL IMG_CloseAnimationEncoder(IMG_AnimationEncoder *encoder); + +/** + * An enum representing the status of an animation decoder. + * + * \since This enum is available since SDL_image 3.4.0. + */ +typedef enum IMG_AnimationDecoderStatus +{ + IMG_DECODER_STATUS_INVALID = -1, /**< The decoder is invalid */ + IMG_DECODER_STATUS_OK, /**< The decoder is ready to decode the next frame */ + IMG_DECODER_STATUS_FAILED, /**< The decoder failed to decode a frame, call SDL_GetError() for more information. */ + IMG_DECODER_STATUS_COMPLETE /**< No more frames available */ +} IMG_AnimationDecoderStatus; + +/** + * An object representing animation decoder. + */ +typedef struct IMG_AnimationDecoder IMG_AnimationDecoder; + +/** + * Create a decoder to read a series of images from a file. + * + * These animation types are currently supported: + * + * - ANI + * - APNG + * - AVIFS + * - GIF + * - WEBP + * + * The file type is determined from the file extension, e.g. "file.webp" will + * be decoded using WEBP. + * + * \param file the file containing a series of images. + * \returns a new IMG_AnimationDecoder, or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_CreateAnimationDecoder_IO + * \sa IMG_CreateAnimationDecoderWithProperties + * \sa IMG_GetAnimationDecoderFrame + * \sa IMG_ResetAnimationDecoder + * \sa IMG_CloseAnimationDecoder + */ +extern SDL_DECLSPEC IMG_AnimationDecoder * SDLCALL IMG_CreateAnimationDecoder(const char *file); + +/** + * Create a decoder to read a series of images from an IOStream. + * + * These animation types are currently supported: + * + * - ANI + * - APNG + * - AVIFS + * - GIF + * - WEBP + * + * If `closeio` is true, `src` will be closed before returning if this + * function fails, or when the animation decoder is closed if this function + * succeeds. + * + * \param src an SDL_IOStream containing a series of images. + * \param closeio true to close the SDL_IOStream when done, false to leave it + * open. + * \param type a filename extension that represent this data ("WEBP", etc). + * \returns a new IMG_AnimationDecoder, or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_CreateAnimationDecoder + * \sa IMG_CreateAnimationDecoderWithProperties + * \sa IMG_GetAnimationDecoderFrame + * \sa IMG_ResetAnimationDecoder + * \sa IMG_CloseAnimationDecoder + */ +extern SDL_DECLSPEC IMG_AnimationDecoder * SDLCALL IMG_CreateAnimationDecoder_IO(SDL_IOStream *src, bool closeio, const char *type); + +/** + * Create an animation decoder with the specified properties. + * + * These animation types are currently supported: + * + * - ANI + * - APNG + * - AVIFS + * - GIF + * - WEBP + * + * These are the supported properties: + * + * - `IMG_PROP_ANIMATION_DECODER_CREATE_FILENAME_STRING`: the file to load, if + * an SDL_IOStream isn't being used. This is required if + * `IMG_PROP_ANIMATION_DECODER_CREATE_IOSTREAM_POINTER` isn't set. + * - `IMG_PROP_ANIMATION_DECODER_CREATE_IOSTREAM_POINTER`: an SDL_IOStream + * containing a series of images. This should not be closed until the + * animation decoder is closed. This is required if + * `IMG_PROP_ANIMATION_DECODER_CREATE_FILENAME_STRING` isn't set. + * - `IMG_PROP_ANIMATION_DECODER_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN`: true if + * closing the animation decoder should also close the associated + * SDL_IOStream. + * - `IMG_PROP_ANIMATION_DECODER_CREATE_TYPE_STRING`: the input file type, + * e.g. "webp", defaults to the file extension if + * `IMG_PROP_ANIMATION_DECODER_CREATE_FILENAME_STRING` is set. + * + * \param props the properties of the animation decoder. + * \returns a new IMG_AnimationDecoder, or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_CreateAnimationDecoder + * \sa IMG_CreateAnimationDecoder_IO + * \sa IMG_GetAnimationDecoderFrame + * \sa IMG_ResetAnimationDecoder + * \sa IMG_CloseAnimationDecoder + */ +extern SDL_DECLSPEC IMG_AnimationDecoder * SDLCALL IMG_CreateAnimationDecoderWithProperties(SDL_PropertiesID props); + +#define IMG_PROP_ANIMATION_DECODER_CREATE_FILENAME_STRING "SDL_image.animation_decoder.create.filename" +#define IMG_PROP_ANIMATION_DECODER_CREATE_IOSTREAM_POINTER "SDL_image.animation_decoder.create.iostream" +#define IMG_PROP_ANIMATION_DECODER_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN "SDL_image.animation_decoder.create.iostream.autoclose" +#define IMG_PROP_ANIMATION_DECODER_CREATE_TYPE_STRING "SDL_image.animation_decoder.create.type" +#define IMG_PROP_ANIMATION_DECODER_CREATE_TIMEBASE_NUMERATOR_NUMBER "SDL_image.animation_decoder.create.timebase.numerator" +#define IMG_PROP_ANIMATION_DECODER_CREATE_TIMEBASE_DENOMINATOR_NUMBER "SDL_image.animation_decoder.create.timebase.denominator" + +#define IMG_PROP_ANIMATION_DECODER_CREATE_AVIF_MAX_THREADS_NUMBER "SDL_image.animation_decoder.create.avif.max_threads" +#define IMG_PROP_ANIMATION_DECODER_CREATE_AVIF_ALLOW_INCREMENTAL_BOOLEAN "SDL_image.animation_decoder.create.avif.allow_incremental" +#define IMG_PROP_ANIMATION_DECODER_CREATE_AVIF_ALLOW_PROGRESSIVE_BOOLEAN "SDL_image.animation_decoder.create.avif.allow_progressive" +#define IMG_PROP_ANIMATION_DECODER_CREATE_GIF_TRANSPARENT_COLOR_INDEX_NUMBER "SDL_image.animation_encoder.create.gif.transparent_color_index" +#define IMG_PROP_ANIMATION_DECODER_CREATE_GIF_NUM_COLORS_NUMBER "SDL_image.animation_encoder.create.gif.num_colors" + +/** + * Get the properties of an animation decoder. + * + * This function returns the properties of the animation decoder, which holds + * information about the underlying image such as description, copyright text + * and loop count. + * + * \param decoder the animation decoder. + * \returns the properties ID of the animation decoder, or 0 if there are no + * properties; call SDL_GetError() for more information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_CreateAnimationDecoder + * \sa IMG_CreateAnimationDecoder_IO + * \sa IMG_CreateAnimationDecoderWithProperties + */ +extern SDL_DECLSPEC SDL_PropertiesID SDLCALL IMG_GetAnimationDecoderProperties(IMG_AnimationDecoder* decoder); + +#define IMG_PROP_METADATA_IGNORE_PROPS_BOOLEAN "SDL_image.metadata.ignore_props" +#define IMG_PROP_METADATA_DESCRIPTION_STRING "SDL_image.metadata.description" +#define IMG_PROP_METADATA_COPYRIGHT_STRING "SDL_image.metadata.copyright" +#define IMG_PROP_METADATA_TITLE_STRING "SDL_image.metadata.title" +#define IMG_PROP_METADATA_AUTHOR_STRING "SDL_image.metadata.author" +#define IMG_PROP_METADATA_CREATION_TIME_STRING "SDL_image.metadata.creation_time" +#define IMG_PROP_METADATA_FRAME_COUNT_NUMBER "SDL_image.metadata.frame_count" +#define IMG_PROP_METADATA_LOOP_COUNT_NUMBER "SDL_image.metadata.loop_count" + +/** + * Get the next frame in an animation decoder. + * + * This function decodes the next frame in the animation decoder, returning it + * as an SDL_Surface. The returned surface should be freed with + * SDL_FreeSurface() when no longer needed. + * + * If the animation decoder has no more frames or an error occurred while + * decoding the frame, this function returns false. In that case, please call + * SDL_GetError() for more information. If SDL_GetError() returns an empty + * string, that means there are no more available frames. If SDL_GetError() + * returns a valid string, that means the decoding failed. + * + * \param decoder the animation decoder. + * \param frame a pointer filled in with the SDL_Surface for the next frame in + * the animation. + * \param duration the duration of the frame, usually in milliseconds but can + * be other units if the + * `IMG_PROP_ANIMATION_DECODER_CREATE_TIMEBASE_DENOMINATOR_NUMBER` + * property is set when creating the decoder. + * \returns true on success or false on failure and when no more frames are + * available; call IMG_GetAnimationDecoderStatus() or SDL_GetError() + * for more information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_CreateAnimationDecoder + * \sa IMG_CreateAnimationDecoder_IO + * \sa IMG_CreateAnimationDecoderWithProperties + * \sa IMG_GetAnimationDecoderStatus + * \sa IMG_ResetAnimationDecoder + * \sa IMG_CloseAnimationDecoder + */ +extern SDL_DECLSPEC bool SDLCALL IMG_GetAnimationDecoderFrame(IMG_AnimationDecoder *decoder, SDL_Surface **frame, Uint64 *duration); + +/** + * Get the decoder status indicating the current state of the decoder. + * + * \param decoder the decoder to get the status of. + * \returns the status of the underlying decoder, or + * IMG_DECODER_STATUS_INVALID if the given decoder is invalid. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_GetAnimationDecoderFrame + */ +extern SDL_DECLSPEC IMG_AnimationDecoderStatus SDLCALL IMG_GetAnimationDecoderStatus(IMG_AnimationDecoder *decoder); + +/** + * Reset an animation decoder. + * + * Calling this function resets the animation decoder, allowing it to start + * from the beginning again. This is useful if you want to decode the frame + * sequence again without creating a new decoder. + * + * \param decoder the decoder to reset. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_CreateAnimationDecoder + * \sa IMG_CreateAnimationDecoder_IO + * \sa IMG_CreateAnimationDecoderWithProperties + * \sa IMG_GetAnimationDecoderFrame + * \sa IMG_CloseAnimationDecoder + */ +extern SDL_DECLSPEC bool SDLCALL IMG_ResetAnimationDecoder(IMG_AnimationDecoder *decoder); + +/** + * Close an animation decoder, finishing any decoding. + * + * Calling this function frees the animation decoder, and returns the final + * status of the decoding process. + * + * \param decoder the decoder to close. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL_image 3.4.0. + * + * \sa IMG_CreateAnimationDecoder + * \sa IMG_CreateAnimationDecoder_IO + * \sa IMG_CreateAnimationDecoderWithProperties + */ +extern SDL_DECLSPEC bool SDLCALL IMG_CloseAnimationDecoder(IMG_AnimationDecoder *decoder); + /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/vendor/sdl3/image/libavif-16.dll b/vendor/sdl3/image/libavif-16.dll index 7fef6232a..eb235450f 100644 Binary files a/vendor/sdl3/image/libavif-16.dll and b/vendor/sdl3/image/libavif-16.dll differ diff --git a/vendor/sdl3/image/libpng16-16.dll b/vendor/sdl3/image/libpng16-16.dll new file mode 100644 index 000000000..ea1e35e61 Binary files /dev/null and b/vendor/sdl3/image/libpng16-16.dll differ diff --git a/vendor/sdl3/image/libtiff-6.dll b/vendor/sdl3/image/libtiff-6.dll index 645e446b8..0dcf40a01 100644 Binary files a/vendor/sdl3/image/libtiff-6.dll and b/vendor/sdl3/image/libtiff-6.dll differ diff --git a/vendor/sdl3/image/libwebpmux-3.dll b/vendor/sdl3/image/libwebpmux-3.dll new file mode 100644 index 000000000..4294a2394 Binary files /dev/null and b/vendor/sdl3/image/libwebpmux-3.dll differ diff --git a/vendor/sdl3/image/sdl_image.odin b/vendor/sdl3/image/sdl_image.odin index 098d21de7..820a7c4da 100644 --- a/vendor/sdl3/image/sdl_image.odin +++ b/vendor/sdl3/image/sdl_image.odin @@ -11,8 +11,8 @@ when ODIN_OS == .Windows { } MAJOR_VERSION :: 3 -MINOR_VERSION :: 2 -PATCHLEVEL :: 4 +MINOR_VERSION :: 4 +PATCHLEVEL :: 0 Animation :: struct { w, h: c.int, @@ -21,6 +21,51 @@ Animation :: struct { delays: [^]c.int, } +AnimationEncoder :: struct {} + +PROP_ANIMATION_ENCODER_CREATE_FILENAME_STRING :: "SDL_image.animation_encoder.create.filename" +PROP_ANIMATION_ENCODER_CREATE_IOSTREAM_POINTER :: "SDL_image.animation_encoder.create.iostream" +PROP_ANIMATION_ENCODER_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN :: "SDL_image.animation_encoder.create.iostream.autoclose" +PROP_ANIMATION_ENCODER_CREATE_TYPE_STRING :: "SDL_image.animation_encoder.create.type" +PROP_ANIMATION_ENCODER_CREATE_QUALITY_NUMBER :: "SDL_image.animation_encoder.create.quality" +PROP_ANIMATION_ENCODER_CREATE_TIMEBASE_NUMERATOR_NUMBER :: "SDL_image.animation_encoder.create.timebase.numerator" +PROP_ANIMATION_ENCODER_CREATE_TIMEBASE_DENOMINATOR_NUMBER :: "SDL_image.animation_encoder.create.timebase.denominator" + +PROP_ANIMATION_ENCODER_CREATE_AVIF_MAX_THREADS_NUMBER :: "SDL_image.animation_encoder.create.avif.max_threads" +PROP_ANIMATION_ENCODER_CREATE_AVIF_KEYFRAME_INTERVAL_NUMBER :: "SDL_image.animation_encoder.create.avif.keyframe_interval" +PROP_ANIMATION_ENCODER_CREATE_GIF_USE_LUT_BOOLEAN :: "SDL_image.animation_encoder.create.gif.use_lut" + +AnimationDecoderStatus :: enum c.int { + INVALID = -1, + OK, + FAILED, + COMPLETE, +} + +AnimationDecoder :: struct {} + +PROP_ANIMATION_DECODER_CREATE_FILENAME_STRING :: "SDL_image.animation_decoder.create.filename" +PROP_ANIMATION_DECODER_CREATE_IOSTREAM_POINTER :: "SDL_image.animation_decoder.create.iostream" +PROP_ANIMATION_DECODER_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN :: "SDL_image.animation_decoder.create.iostream.autoclose" +PROP_ANIMATION_DECODER_CREATE_TYPE_STRING :: "SDL_image.animation_decoder.create.type" +PROP_ANIMATION_DECODER_CREATE_TIMEBASE_NUMERATOR_NUMBER :: "SDL_image.animation_decoder.create.timebase.numerator" +PROP_ANIMATION_DECODER_CREATE_TIMEBASE_DENOMINATOR_NUMBER :: "SDL_image.animation_decoder.create.timebase.denominator" + +PROP_ANIMATION_DECODER_CREATE_AVIF_MAX_THREADS_NUMBER :: "SDL_image.animation_decoder.create.avif.max_threads" +PROP_ANIMATION_DECODER_CREATE_AVIF_ALLOW_INCREMENTAL_BOOLEAN :: "SDL_image.animation_decoder.create.avif.allow_incremental" +PROP_ANIMATION_DECODER_CREATE_AVIF_ALLOW_PROGRESSIVE_BOOLEAN :: "SDL_image.animation_decoder.create.avif.allow_progressive" +PROP_ANIMATION_DECODER_CREATE_GIF_TRANSPARENT_COLOR_INDEX_NUMBER :: "SDL_image.animation_encoder.create.gif.transparent_color_index" +PROP_ANIMATION_DECODER_CREATE_GIF_NUM_COLORS_NUMBER :: "SDL_image.animation_encoder.create.gif.num_colors" + +PROP_METADATA_IGNORE_PROPS_BOOLEAN :: "SDL_image.metadata.ignore_props" +PROP_METADATA_DESCRIPTION_STRING :: "SDL_image.metadata.description" +PROP_METADATA_COPYRIGHT_STRING :: "SDL_image.metadata.copyright" +PROP_METADATA_TITLE_STRING :: "SDL_image.metadata.title" +PROP_METADATA_AUTHOR_STRING :: "SDL_image.metadata.author" +PROP_METADATA_CREATION_TIME_STRING :: "SDL_image.metadata.creation_time" +PROP_METADATA_FRAME_COUNT_NUMBER :: "SDL_image.metadata.frame_count" +PROP_METADATA_LOOP_COUNT_NUMBER :: "SDL_image.metadata.loop_count" + @(default_calling_convention="c", link_prefix="IMG_") foreign lib { Version :: proc() -> c.int --- @@ -43,7 +88,16 @@ foreign lib { LoadTexture_IO :: proc(renderer: ^SDL.Renderer, src: ^SDL.IOStream, closeio: bool) -> ^SDL.Texture --- LoadTextureTyped_IO :: proc(renderer: ^SDL.Renderer, src: ^SDL.IOStream, closeio: bool, type: cstring) -> ^SDL.Texture --- + /* Load an image directly into a GPU texture. */ + LoadGPUTexture :: proc(device: ^SDL.GPUDevice, copy_pass: ^SDL.GPUCopyPass, file: cstring, width: ^c.int, height: ^c.int) -> ^SDL.GPUTexture --- + LoadGPUTexture_IO :: proc(device: ^SDL.GPUDevice, copy_pass: ^SDL.GPUCopyPass, src: ^SDL.IOStream, closeio: bool, width: ^c.int, height: ^c.int) -> ^SDL.GPUTexture --- + LoadGPUTextureTyped_IO :: proc(device: ^SDL.GPUDevice, copy_pass: ^SDL.GPUCopyPass, src: ^SDL.IOStream, closeio: bool, type: cstring, width: ^c.int, height: ^c.int) -> ^SDL.GPUTexture --- + + /* Get the image currently in the clipboard. */ + GetClipboardImage :: proc() -> ^SDL.Surface --- + /* Functions to detect a file type, given a seekable source */ + isANI :: proc(src: ^SDL.IOStream) -> bool --- isAVIF :: proc(src: ^SDL.IOStream) -> bool --- isICO :: proc(src: ^SDL.IOStream) -> bool --- isCUR :: proc(src: ^SDL.IOStream) -> bool --- @@ -90,19 +144,63 @@ foreign lib { ReadXPMFromArrayToRGB888 :: proc(xpm: [^]cstring) -> ^SDL.Surface --- /* Individual saving functions */ - SaveAVIF :: proc(surface: ^SDL.Surface, file: cstring, quality: c.int) -> c.bool --- - SaveAVIF_IO :: proc(surface: ^SDL.Surface, dst: ^SDL.IOStream, closeio: bool, quality: c.int) -> c.bool --- - SavePNG :: proc(surface: ^SDL.Surface, file: cstring) -> c.bool --- - SavePNG_IO :: proc(surface: ^SDL.Surface, dst: ^SDL.IOStream, closeio: bool) -> c.bool --- - SaveJPG :: proc(surface: ^SDL.Surface, file: cstring, quality: c.int) -> c.bool --- - SaveJPG_IO :: proc(surface: ^SDL.Surface, dst: ^SDL.IOStream, closeio: bool, quality: c.int) -> c.bool --- + Save :: proc(surface: ^SDL.Surface, file: cstring) -> c.bool --- + SaveTyped_IO :: proc(surface: ^SDL.Surface, dst: ^SDL.IOStream, closeio: bool, type: cstring) -> c.bool --- + SaveAVIF :: proc(surface: ^SDL.Surface, file: cstring, quality: c.int) -> c.bool --- + SaveAVIF_IO :: proc(surface: ^SDL.Surface, dst: ^SDL.IOStream, closeio: bool, quality: c.int) -> c.bool --- + SaveBMP :: proc(surface: ^SDL.Surface, file: cstring) -> c.bool --- + SaveBMP_IO :: proc(surface: ^SDL.Surface, dst: ^SDL.IOStream, closeio: bool) -> c.bool --- + SaveCUR :: proc(surface: ^SDL.Surface, file: cstring) -> c.bool --- + SaveCUR_IO :: proc(surface: ^SDL.Surface, dst: ^SDL.IOStream, closeio: bool) -> c.bool --- + SaveGIF :: proc(surface: ^SDL.Surface, file: cstring) -> c.bool --- + SaveGIF_IO :: proc(surface: ^SDL.Surface, dst: ^SDL.IOStream, closeio: bool) -> c.bool --- + SaveICO :: proc(surface: ^SDL.Surface, file: cstring) -> c.bool --- + SaveICO_IO :: proc(surface: ^SDL.Surface, dst: ^SDL.IOStream, closeio: bool) -> c.bool --- + SaveJPG :: proc(surface: ^SDL.Surface, file: cstring, quality: c.int) -> c.bool --- + SaveJPG_IO :: proc(surface: ^SDL.Surface, dst: ^SDL.IOStream, closeio: bool, quality: c.int) -> c.bool --- + SavePNG :: proc(surface: ^SDL.Surface, file: cstring) -> c.bool --- + SavePNG_IO :: proc(surface: ^SDL.Surface, dst: ^SDL.IOStream, closeio: bool) -> c.bool --- + SaveTGA :: proc(surface: ^SDL.Surface, file: cstring) -> c.bool --- + SaveTGA_IO :: proc(surface: ^SDL.Surface, dst: ^SDL.IOStream, closeio: bool) -> c.bool --- + SaveWEBP :: proc(surface: ^SDL.Surface, file: cstring, quality: f32) -> c.bool --- + SaveWEBP_IO :: proc(surface: ^SDL.Surface, dst: ^SDL.IOStream, closeio: bool, quality: f32) -> c.bool --- LoadAnimation :: proc(file: cstring) -> ^Animation --- LoadAnimation_IO :: proc(src: ^SDL.IOStream, closeio: bool) -> ^Animation --- LoadAnimationTyped_IO :: proc(src: ^SDL.IOStream, closeio: bool, type: cstring) -> ^Animation --- + SaveAnimation :: proc(anim: ^Animation, file: cstring) -> c.bool --- + SaveAnimationTyped_IO :: proc(anim: ^Animation, dst: ^SDL.IOStream, closeio: bool, type: cstring) -> c.bool --- + CreateAnimatedCursor :: proc(anim: ^Animation, hot_x: c.int, hot_y: c.int) -> ^SDL.Cursor --- FreeAnimation :: proc(anim: ^Animation) --- + /* Animation encoder functions */ + CreateAnimationEncoder :: proc(file: cstring) -> ^AnimationEncoder --- + CreateAnimationEncoder_IO :: proc(dst: ^SDL.IOStream, closeio: bool, type: cstring) -> ^AnimationEncoder --- + CreateAnimationEncoderWithProperties :: proc(props: SDL.PropertiesID) -> ^AnimationEncoder --- + AddAnimationEncoderFrame :: proc(encoder: ^AnimationEncoder, surface: ^SDL.Surface, duration: u64) -> c.bool --- + CloseAnimationEncoder :: proc(encoder: ^AnimationEncoder) -> c.bool --- + + /* Animation decoder functions */ + CreateAnimationDecoder :: proc(file: cstring) -> ^AnimationDecoder --- + CreateAnimationDecoder_IO :: proc(src: ^SDL.IOStream, closeio: bool, type: cstring) -> ^AnimationDecoder --- + CreateAnimationDecoderWithProperties :: proc(props: SDL.PropertiesID) -> ^AnimationDecoder --- + GetAnimationDecoderProperties :: proc(decoder: ^AnimationDecoder) -> SDL.PropertiesID --- + GetAnimationDecoderFrame :: proc(decoder: ^AnimationDecoder, frame: ^^SDL.Surface, duration: ^u64) -> c.bool --- + GetAnimationDecoderStatus :: proc(decoder: ^AnimationDecoder) -> AnimationDecoderStatus --- + ResetAnimationDecoder :: proc(decoder: ^AnimationDecoder) -> c.bool --- + CloseAnimationDecoder :: proc(decoder: ^AnimationDecoder) -> c.bool --- + /* Individual loading functions */ + LoadANIAnimation_IO :: proc(src: ^SDL.IOStream) -> ^Animation --- + LoadAPNGAnimation_IO :: proc(src: ^SDL.IOStream) -> ^Animation --- + LoadAVIFAnimation_IO :: proc(src: ^SDL.IOStream) -> ^Animation --- LoadGIFAnimation_IO :: proc(src: ^SDL.IOStream) -> ^Animation --- LoadWEBPAnimation_IO :: proc(src: ^SDL.IOStream) -> ^Animation --- + + /* Individual saving functions */ + SaveANIAnimation_IO :: proc(anim: ^Animation, dst: ^SDL.IOStream, closeio: bool) -> c.bool --- + SaveAPNGAnimation_IO :: proc(anim: ^Animation, dst: ^SDL.IOStream, closeio: bool) -> c.bool --- + SaveAVIFAnimation_IO :: proc(anim: ^Animation, dst: ^SDL.IOStream, closeio: bool, quality: c.int) -> c.bool --- + SaveGIFAnimation_IO :: proc(anim: ^Animation, dst: ^SDL.IOStream, closeio: bool) -> c.bool --- + SaveWEBPAnimation_IO :: proc(anim: ^Animation, dst: ^SDL.IOStream, closeio: bool, quality: c.int) -> c.bool --- } diff --git a/vendor/sdl3/include/SDL.h b/vendor/sdl3/include/SDL.h index ed1b32483..04a05d257 100644 --- a/vendor/sdl3/include/SDL.h +++ b/vendor/sdl3/include/SDL.h @@ -20,7 +20,7 @@ */ /** - * Main include header for the SDL library, version 3.2.16 + * Main include header for the SDL library, version 3.4.0 * * It is almost always best to include just this one header instead of * picking out individual headers included here. There are exceptions to @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include diff --git a/vendor/sdl3/include/SDL_assert.h b/vendor/sdl3/include/SDL_assert.h index 6c90acc02..f0c4637b9 100644 --- a/vendor/sdl3/include/SDL_assert.h +++ b/vendor/sdl3/include/SDL_assert.h @@ -126,20 +126,17 @@ extern "C" { */ #define SDL_TriggerBreakpoint() TriggerABreakpointInAPlatformSpecificManner -#elif defined(_MSC_VER) && _MSC_VER >= 1310 +#elif defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER >= 1310) /* Don't include intrin.h here because it contains C++ code */ extern void __cdecl __debugbreak(void); #define SDL_TriggerBreakpoint() __debugbreak() #elif defined(_MSC_VER) && defined(_M_IX86) #define SDL_TriggerBreakpoint() { _asm { int 0x03 } } -#elif defined(ANDROID) - #include - #define SDL_TriggerBreakpoint() assert(0) #elif SDL_HAS_BUILTIN(__builtin_debugtrap) #define SDL_TriggerBreakpoint() __builtin_debugtrap() #elif SDL_HAS_BUILTIN(__builtin_trap) #define SDL_TriggerBreakpoint() __builtin_trap() -#elif (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) +#elif (defined(__GNUC__) || defined(__clang__) || defined(__TINYC__)) && (defined(__i386__) || defined(__x86_64__)) #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" ) #elif (defined(__GNUC__) || defined(__clang__)) && defined(__riscv) #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "ebreak\n\t" ) @@ -179,12 +176,48 @@ extern "C" { # define SDL_FUNCTION "???" #endif +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + /** * A macro that reports the current file being compiled. * + * This macro is only defined if it isn't already defined, so to override it + * (perhaps with something that doesn't provide path information at all, so + * build machine information doesn't leak into public binaries), apps can + * define this macro before including SDL.h or SDL_assert.h. + * * \since This macro is available since SDL 3.2.0. */ +#define SDL_FILE __FILE_NAME__ + +#elif !defined(SDL_FILE) +#ifdef __FILE_NAME__ +#define SDL_FILE __FILE_NAME__ +#else #define SDL_FILE __FILE__ +#endif +#endif + +#ifdef SDL_WIKI_DOCUMENTATION_SECTION + +/** + * A macro that reports the current file being compiled, for use in + * assertions. + * + * This macro is only defined if it isn't already defined, so to override it + * (perhaps with something that doesn't provide path information at all, so + * build machine information doesn't leak into public binaries), apps can + * define this macro before including SDL_assert.h. For example, defining this + * to `""` will make sure no source path information is included in asserts. + * + * \since This macro is available since SDL 3.4.0. + */ +#define SDL_ASSERT_FILE SDL_FILE + +#elif !defined(SDL_ASSERT_FILE) +#define SDL_ASSERT_FILE SDL_FILE +#endif + /** * A macro that reports the current line number of the file being compiled. @@ -362,8 +395,8 @@ extern SDL_DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData * #define SDL_enabled_assert(condition) \ do { \ while ( !(condition) ) { \ - static struct SDL_AssertData sdl_assert_data = { 0, 0, #condition, 0, 0, 0, 0 }; \ - const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \ + static struct SDL_AssertData sdl_assert_data = { false, 0, #condition, NULL, 0, NULL, NULL }; \ + const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_ASSERT_FILE, SDL_LINE); \ if (sdl_assert_state == SDL_ASSERTION_RETRY) { \ continue; /* go again. */ \ } else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \ diff --git a/vendor/sdl3/include/SDL_atomic.h b/vendor/sdl3/include/SDL_atomic.h index 78b5e0fa5..bfcf81ee0 100644 --- a/vendor/sdl3/include/SDL_atomic.h +++ b/vendor/sdl3/include/SDL_atomic.h @@ -596,6 +596,24 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_SetAtomicU32(SDL_AtomicU32 *a, Uint32 v); */ extern SDL_DECLSPEC Uint32 SDLCALL SDL_GetAtomicU32(SDL_AtomicU32 *a); +/** + * Add to an atomic variable. + * + * This function also acts as a full memory barrier. + * + * ***Note: If you don't know what this function is for, you shouldn't use + * it!*** + * + * \param a a pointer to an SDL_AtomicU32 variable to be modified. + * \param v the desired value to add or subtract. + * \returns the previous value of the atomic variable. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC Uint32 SDLCALL SDL_AddAtomicU32(SDL_AtomicU32 *a, int v); + /** * Set a pointer to a new value if it is currently an old value. * diff --git a/vendor/sdl3/include/SDL_audio.h b/vendor/sdl3/include/SDL_audio.h index c6acf885f..4c362e738 100644 --- a/vendor/sdl3/include/SDL_audio.h +++ b/vendor/sdl3/include/SDL_audio.h @@ -577,6 +577,15 @@ extern SDL_DECLSPEC SDL_AudioDeviceID * SDLCALL SDL_GetAudioRecordingDevices(int /** * Get the human-readable name of a specific audio device. * + * **WARNING**: this function will work with SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK + * and SDL_AUDIO_DEVICE_DEFAULT_RECORDING, returning the current default + * physical devices' names. However, as the default device may change at any + * time, it is likely better to show a generic name to the user, like "System + * default audio device" or perhaps "default [currently %s]". Do not store + * this name to disk to reidentify the device in a later run of the program, + * as the default might change in general, and the string will be the name of + * a specific device and not the abstract system default. + * * \param devid the instance ID of the device to query. * \returns the name of the audio device, or NULL on failure; call * SDL_GetError() for more information. @@ -942,7 +951,10 @@ extern SDL_DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID devid); * Binding a stream to a device will set its output format for playback * devices, and its input format for recording devices, so they match the * device's settings. The caller is welcome to change the other end of the - * stream's format at any time with SDL_SetAudioStreamFormat(). + * stream's format at any time with SDL_SetAudioStreamFormat(). If the other + * end of the stream's format has never been set (the audio stream was created + * with a NULL audio spec), this function will set it to match the device + * end's format. * * \param devid an audio device to bind a stream to. * \param streams an array of audio streams to bind. @@ -1021,7 +1033,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_UnbindAudioStream(SDL_AudioStream *stream); /** * Query an audio stream for its currently-bound device. * - * This reports the audio device that an audio stream is currently bound to. + * This reports the logical audio device that an audio stream is currently + * bound to. * * If not bound, or invalid, this returns zero, which is not a valid device * ID. @@ -1063,6 +1076,17 @@ extern SDL_DECLSPEC SDL_AudioStream * SDLCALL SDL_CreateAudioStream(const SDL_Au /** * Get the properties associated with an audio stream. * + * The application can hang any data it wants here, but the following + * properties are understood by SDL: + * + * - `SDL_PROP_AUDIOSTREAM_AUTO_CLEANUP_BOOLEAN`: if true (the default), the + * stream be automatically cleaned up when the audio subsystem quits. If set + * to false, the streams will persist beyond that. This property is ignored + * for streams created through SDL_OpenAudioDeviceStream(), and will always + * be cleaned up. Streams that are not cleaned up will still be unbound from + * devices when the audio subsystem quits. This property was added in SDL + * 3.4.0. + * * \param stream the SDL_AudioStream to query. * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. @@ -1073,6 +1097,9 @@ extern SDL_DECLSPEC SDL_AudioStream * SDLCALL SDL_CreateAudioStream(const SDL_Au */ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetAudioStreamProperties(SDL_AudioStream *stream); +#define SDL_PROP_AUDIOSTREAM_AUTO_CLEANUP_BOOLEAN "SDL.audiostream.auto_cleanup" + + /** * Query the current format of an audio stream. * @@ -1149,14 +1176,14 @@ extern SDL_DECLSPEC float SDLCALL SDL_GetAudioStreamFrequencyRatio(SDL_AudioStre * * The frequency ratio is used to adjust the rate at which input data is * consumed. Changing this effectively modifies the speed and pitch of the - * audio. A value greater than 1.0 will play the audio faster, and at a higher - * pitch. A value less than 1.0 will play the audio slower, and at a lower - * pitch. + * audio. A value greater than 1.0f will play the audio faster, and at a + * higher pitch. A value less than 1.0f will play the audio slower, and at a + * lower pitch. 1.0f means play at normal speed. * * This is applied during SDL_GetAudioStreamData, and can be continuously * changed to create various effects. * - * \param stream the stream the frequency ratio is being changed. + * \param stream the stream on which the frequency ratio is being changed. * \param ratio the frequency ratio. 1.0 is normal speed. Must be between 0.01 * and 100. * \returns true on success or false on failure; call SDL_GetError() for more @@ -1318,7 +1345,7 @@ extern SDL_DECLSPEC int * SDLCALL SDL_GetAudioStreamOutputChannelMap(SDL_AudioSt * \threadsafety It is safe to call this function from any thread, as it holds * a stream-specific mutex while running. Don't change the * stream's format to have a different number of channels from a - * a different thread at the same time, though! + * different thread at the same time, though! * * \since This function is available since SDL 3.2.0. * @@ -1332,7 +1359,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamInputChannelMap(SDL_AudioStre * Channel maps are optional; most things do not need them, instead passing * data in the [order that SDL expects](CategoryAudio#channel-layouts). * - * The output channel map reorders data that leaving a stream via + * The output channel map reorders data that is leaving a stream via * SDL_GetAudioStreamData. * * Each item in the array represents an input channel, and its value is the @@ -1414,6 +1441,136 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamOutputChannelMap(SDL_AudioStr */ extern SDL_DECLSPEC bool SDLCALL SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len); +/** + * A callback that fires for completed SDL_PutAudioStreamDataNoCopy() data. + * + * When using SDL_PutAudioStreamDataNoCopy() to provide data to an + * SDL_AudioStream, it's not safe to dispose of the data until the stream has + * completely consumed it. Often times it's difficult to know exactly when + * this has happened. + * + * This callback fires once when the stream no longer needs the buffer, + * allowing the app to easily free or reuse it. + * + * \param userdata an opaque pointer provided by the app for their personal + * use. + * \param buf the pointer provided to SDL_PutAudioStreamDataNoCopy(). + * \param buflen the size of buffer, in bytes, provided to + * SDL_PutAudioStreamDataNoCopy(). + * + * \threadsafety This callbacks may run from any thread, so if you need to + * protect shared data, you should use SDL_LockAudioStream to + * serialize access; this lock will be held before your callback + * is called, so your callback does not need to manage the lock + * explicitly. + * + * \since This datatype is available since SDL 3.4.0. + * + * \sa SDL_SetAudioStreamGetCallback + * \sa SDL_SetAudioStreamPutCallback + */ +typedef void (SDLCALL *SDL_AudioStreamDataCompleteCallback)(void *userdata, const void *buf, int buflen); + +/** + * Add external data to an audio stream without copying it. + * + * Unlike SDL_PutAudioStreamData(), this function does not make a copy of the + * provided data, instead storing the provided pointer. This means that the + * put operation does not need to allocate and copy the data, but the original + * data must remain available until the stream is done with it, either by + * being read from the stream in its entirety, or a call to + * SDL_ClearAudioStream() or SDL_DestroyAudioStream(). + * + * The data must match the format/channels/samplerate specified in the latest + * call to SDL_SetAudioStreamFormat, or the format specified when creating the + * stream if it hasn't been changed. + * + * An optional callback may be provided, which is called when the stream no + * longer needs the data. Once this callback fires, the stream will not access + * the data again. This callback will fire for any reason the data is no + * longer needed, including clearing or destroying the stream. + * + * Note that there is still an allocation to store tracking information, so + * this function is more efficient for larger blocks of data. If you're + * planning to put a few samples at a time, it will be more efficient to use + * SDL_PutAudioStreamData(), which allocates and buffers in blocks. + * + * \param stream the stream the audio data is being added to. + * \param buf a pointer to the audio data to add. + * \param len the number of bytes to add to the stream. + * \param callback the callback function to call when the data is no longer + * needed by the stream. May be NULL. + * \param userdata an opaque pointer provided to the callback for its own + * personal use. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread, but if the + * stream has a callback set, the caller might need to manage + * extra locking. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_ClearAudioStream + * \sa SDL_FlushAudioStream + * \sa SDL_GetAudioStreamData + * \sa SDL_GetAudioStreamQueued + */ +extern SDL_DECLSPEC bool SDLCALL SDL_PutAudioStreamDataNoCopy(SDL_AudioStream *stream, const void *buf, int len, SDL_AudioStreamDataCompleteCallback callback, void *userdata); + +/** + * Add data to the stream with each channel in a separate array. + * + * This data must match the format/channels/samplerate specified in the latest + * call to SDL_SetAudioStreamFormat, or the format specified when creating the + * stream if it hasn't been changed. + * + * The data will be interleaved and queued. Note that SDL_AudioStream only + * operates on interleaved data, so this is simply a convenience function for + * easily queueing data from sources that provide separate arrays. There is no + * equivalent function to retrieve planar data. + * + * The arrays in `channel_buffers` are ordered as they are to be interleaved; + * the first array will be the first sample in the interleaved data. Any + * individual array may be NULL; in this case, silence will be interleaved for + * that channel. + * + * `num_channels` specifies how many arrays are in `channel_buffers`. This can + * be used as a safety to prevent overflow, in case the stream format has + * changed elsewhere. If more channels are specified than the current input + * spec, they are ignored. If less channels are specified, the missing arrays + * are treated as if they are NULL (silence is written to those channels). If + * the count is -1, SDL will assume the array count matches the current input + * spec. + * + * Note that `num_samples` is the number of _samples per array_. This can also + * be thought of as the number of _sample frames_ to be queued. A value of 1 + * with stereo arrays will queue two samples to the stream. This is different + * than SDL_PutAudioStreamData, which wants the size of a single array in + * bytes. + * + * \param stream the stream the audio data is being added to. + * \param channel_buffers a pointer to an array of arrays, one array per + * channel. + * \param num_channels the number of arrays in `channel_buffers` or -1. + * \param num_samples the number of _samples_ per array to write to the + * stream. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety It is safe to call this function from any thread, but if the + * stream has a callback set, the caller might need to manage + * extra locking. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_ClearAudioStream + * \sa SDL_FlushAudioStream + * \sa SDL_GetAudioStreamData + * \sa SDL_GetAudioStreamQueued + */ +extern SDL_DECLSPEC bool SDLCALL SDL_PutAudioStreamPlanarData(SDL_AudioStream *stream, const void * const *channel_buffers, int num_channels, int num_samples); + /** * Get converted/resampled data from the stream. * @@ -1583,8 +1740,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_PauseAudioStreamDevice(SDL_AudioStream *str * previously been paused. Once unpaused, any bound audio streams will begin * to progress again, and audio can be generated. * - * Remember, SDL_OpenAudioDeviceStream opens device in a paused state, so this - * function call is required for audio playback to begin on such device. + * SDL_OpenAudioDeviceStream opens audio devices in a paused state, so this + * function call is required for audio playback to begin on such devices. * * \param stream the audio stream associated with the audio device to resume. * \returns true on success or false on failure; call SDL_GetError() for more @@ -1841,7 +1998,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_DestroyAudioStream(SDL_AudioStream *stream) * Also unlike other functions, the audio device begins paused. This is to map * more closely to SDL2-style behavior, since there is no extra step here to * bind a stream to begin audio flowing. The audio device should be resumed - * with `SDL_ResumeAudioStreamDevice(stream);` + * with SDL_ResumeAudioStreamDevice(). * * This function works with both playback and recording devices. * diff --git a/vendor/sdl3/include/SDL_begin_code.h b/vendor/sdl3/include/SDL_begin_code.h index a6b47cf4b..675cd7f09 100644 --- a/vendor/sdl3/include/SDL_begin_code.h +++ b/vendor/sdl3/include/SDL_begin_code.h @@ -261,9 +261,9 @@ * * On compilers without restrict support, this is defined to nothing. * - * \since This macro is available since SDL 3.2.0. + * \since This macro is available since SDL 3.4.0. */ -#define SDL_RESTRICT __restrict__ +#define SDL_RESTRICT __restrict /** * Check if the compiler supports a given builtin functionality. @@ -281,9 +281,61 @@ */ #define SDL_HAS_BUILTIN(x) __has_builtin(x) +/** + * A macro to specify data alignment. + * + * This informs the compiler that a given datatype or variable must be aligned + * to a specific byte count. + * + * For example: + * + * ```c + * // make sure this is struct is aligned to 16 bytes for SIMD access. + * typedef struct { + * float x, y, z, w; + * } SDL_ALIGNED(16) MySIMDAlignedData; + * + * // make sure this one field in a struct is aligned to 16 bytes for SIMD access. + * typedef struct { + * SomeStuff stuff; + * float SDL_ALIGNED(16) position[4]; + * SomeOtherStuff other_stuff; + * } MyStruct; + * + * // make sure this variable is aligned to 32 bytes. + * int SDL_ALIGNED(32) myval = 0; + * ``` + * + * Alignment is only guaranteed for things the compiler places: local + * variables on the stack and global/static variables. To dynamically allocate + * something that respects this alignment, use SDL_aligned_alloc() or some + * other mechanism. + * + * On compilers without alignment support, this macro is defined to an invalid + * symbol, to make it clear that the current compiler is likely to generate + * incorrect code when it sees this macro. + * + * \param x the byte count to align to, so the data's address will be a + * multiple of this value. + * + * \since This macro is available since SDL 3.4.0. + */ +#define SDL_ALIGNED(x) __attribute__((aligned(x))) + /* end of wiki documentation section. */ #endif +/* `restrict` is from C99, but __restrict works with both Visual Studio and GCC. */ +#ifndef SDL_RESTRICT +# if defined(restrict) || ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))) +# define SDL_RESTRICT restrict +# elif defined(_MSC_VER) || defined(__GNUC__) || defined(__clang__) +# define SDL_RESTRICT __restrict +# else +# define SDL_RESTRICT +# endif +#endif + #ifndef SDL_HAS_BUILTIN #ifdef __has_builtin #define SDL_HAS_BUILTIN(x) __has_builtin(x) @@ -379,7 +431,7 @@ #endif /* SDL_INLINE not defined */ #ifndef SDL_FORCE_INLINE -#ifdef _MSC_VER +#if defined(_MSC_VER) && (_MSC_VER >= 1200) #define SDL_FORCE_INLINE __forceinline #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) #define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ @@ -389,7 +441,7 @@ #endif /* SDL_FORCE_INLINE not defined */ #ifndef SDL_NORETURN -#ifdef __GNUC__ +#if defined(__GNUC__) #define SDL_NORETURN __attribute__((noreturn)) #elif defined(_MSC_VER) #define SDL_NORETURN __declspec(noreturn) @@ -484,3 +536,18 @@ #define SDL_ALLOC_SIZE2(p1, p2) #endif #endif /* SDL_ALLOC_SIZE2 not defined */ + +#ifndef SDL_ALIGNED +#if defined(__clang__) || defined(__GNUC__) +#define SDL_ALIGNED(x) __attribute__((aligned(x))) +#elif defined(_MSC_VER) +#define SDL_ALIGNED(x) __declspec(align(x)) +#elif defined(__cplusplus) && (__cplusplus >= 201103L) +#define SDL_ALIGNED(x) alignas(x) +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) +#define SDL_ALIGNED(x) _Alignas(x) +#else +#define SDL_ALIGNED(x) PLEASE_DEFINE_SDL_ALIGNED +#endif +#endif /* SDL_ALIGNED not defined */ + diff --git a/vendor/sdl3/include/SDL_camera.h b/vendor/sdl3/include/SDL_camera.h index 5f3911fdf..59ce73fe8 100644 --- a/vendor/sdl3/include/SDL_camera.h +++ b/vendor/sdl3/include/SDL_camera.h @@ -119,7 +119,7 @@ typedef struct SDL_CameraSpec int width; /**< Frame width */ int height; /**< Frame height */ int framerate_numerator; /**< Frame rate numerator ((num / denom) == FPS, (denom / num) == duration in seconds) */ - int framerate_denominator; /**< Frame rate demoninator ((num / denom) == FPS, (denom / num) == duration in seconds) */ + int framerate_denominator; /**< Frame rate denominator ((num / denom) == FPS, (denom / num) == duration in seconds) */ } SDL_CameraSpec; /** @@ -136,6 +136,20 @@ typedef enum SDL_CameraPosition SDL_CAMERA_POSITION_BACK_FACING } SDL_CameraPosition; +/** + * The current state of a request for camera access. + * + * \since This enum is available since SDL 3.4.0. + * + * \sa SDL_GetCameraPermissionState + */ +typedef enum SDL_CameraPermissionState +{ + SDL_CAMERA_PERMISSION_STATE_DENIED = -1, + SDL_CAMERA_PERMISSION_STATE_PENDING, + SDL_CAMERA_PERMISSION_STATE_APPROVED, +} SDL_CameraPermissionState; + /** * Use this function to get the number of built-in camera drivers. @@ -346,8 +360,9 @@ extern SDL_DECLSPEC SDL_Camera * SDLCALL SDL_OpenCamera(SDL_CameraID instance_id * on others the approval might be implicit and not alert the user at all. * * This function can be used to check the status of that approval. It will - * return 0 if still waiting for user response, 1 if the camera is approved - * for use, and -1 if the user denied access. + * return SDL_CAMERA_PERMISSION_STATE_PENDING if waiting for user response, + * SDL_CAMERA_PERMISSION_STATE_APPROVED if the camera is approved for use, and + * SDL_CAMERA_PERMISSION_STATE_DENIED if the user denied access. * * Instead of polling with this function, you can wait for a * SDL_EVENT_CAMERA_DEVICE_APPROVED (or SDL_EVENT_CAMERA_DEVICE_DENIED) event @@ -358,8 +373,9 @@ extern SDL_DECLSPEC SDL_Camera * SDLCALL SDL_OpenCamera(SDL_CameraID instance_id * SDL_CloseCamera() to dispose of it. * * \param camera the opened camera device to query. - * \returns -1 if user denied access to the camera, 1 if user approved access, - * 0 if no decision has been made yet. + * \returns an SDL_CameraPermissionState value indicating if access is + * granted, or `SDL_CAMERA_PERMISSION_STATE_PENDING` if the decision + * is still pending. * * \threadsafety It is safe to call this function from any thread. * @@ -368,7 +384,7 @@ extern SDL_DECLSPEC SDL_Camera * SDLCALL SDL_OpenCamera(SDL_CameraID instance_id * \sa SDL_OpenCamera * \sa SDL_CloseCamera */ -extern SDL_DECLSPEC int SDLCALL SDL_GetCameraPermissionState(SDL_Camera *camera); +extern SDL_DECLSPEC SDL_CameraPermissionState SDLCALL SDL_GetCameraPermissionState(SDL_Camera *camera); /** * Get the instance ID of an opened camera. diff --git a/vendor/sdl3/include/SDL_clipboard.h b/vendor/sdl3/include/SDL_clipboard.h index 0d3cbb499..7480eb284 100644 --- a/vendor/sdl3/include/SDL_clipboard.h +++ b/vendor/sdl3/include/SDL_clipboard.h @@ -106,7 +106,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetClipboardText(const char *text); /** * Get UTF-8 text from the clipboard. * - * This functions returns an empty string if there was not enough memory left + * This function returns an empty string if there is not enough memory left * for a copy of the clipboard's content. * * \returns the clipboard text on success or an empty string on failure; call @@ -155,7 +155,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetPrimarySelectionText(const char *text); /** * Get UTF-8 text from the primary selection. * - * This functions returns an empty string if there was not enough memory left + * This function returns an empty string if there is not enough memory left * for a copy of the primary selection's content. * * \returns the primary selection text on success or an empty string on @@ -194,15 +194,14 @@ extern SDL_DECLSPEC bool SDLCALL SDL_HasPrimarySelectionText(void); * clipboard is cleared or new data is set. The clipboard is automatically * cleared in SDL_Quit(). * - * \param userdata a pointer to provided user data. + * \param userdata a pointer to the provided user data. * \param mime_type the requested mime-type. * \param size a pointer filled in with the length of the returned data. * \returns a pointer to the data for the provided mime-type. Returning NULL - * or setting length to 0 will cause no data to be sent to the - * "receiver". It is up to the receiver to handle this. Essentially - * returning no data is more or less undefined behavior and may cause - * breakage in receiving applications. The returned data will not be - * freed so it needs to be retained and dealt with internally. + * or setting the length to 0 will cause zero length data to be sent + * to the "receiver", which should be able to handle this. The + * returned data will not be freed, so it needs to be retained and + * dealt with internally. * * \since This function is available since SDL 3.2.0. * @@ -211,10 +210,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_HasPrimarySelectionText(void); typedef const void *(SDLCALL *SDL_ClipboardDataCallback)(void *userdata, const char *mime_type, size_t *size); /** - * Callback function that will be called when the clipboard is cleared, or new - * data is set. + * Callback function that will be called when the clipboard is cleared, or + * when new data is set. * - * \param userdata a pointer to provided user data. + * \param userdata a pointer to the provided user data. * * \since This function is available since SDL 3.2.0. * @@ -231,7 +230,7 @@ typedef void (SDLCALL *SDL_ClipboardCleanupCallback)(void *userdata); * respond with the data for the requested mime-type. * * The size of text data does not include any terminator, and the text does - * not need to be null terminated (e.g. you can directly copy a portion of a + * not need to be null-terminated (e.g., you can directly copy a portion of a * document). * * \param callback a function pointer to the function that provides the @@ -239,7 +238,8 @@ typedef void (SDLCALL *SDL_ClipboardCleanupCallback)(void *userdata); * \param cleanup a function pointer to the function that cleans up the * clipboard data. * \param userdata an opaque pointer that will be forwarded to the callbacks. - * \param mime_types a list of mime-types that are being offered. + * \param mime_types a list of mime-types that are being offered. SDL copies + * the given list. * \param num_mime_types the number of mime-types in the mime_types list. * \returns true on success or false on failure; call SDL_GetError() for more * information. @@ -269,10 +269,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetClipboardData(SDL_ClipboardDataCallback extern SDL_DECLSPEC bool SDLCALL SDL_ClearClipboardData(void); /** - * Get the data from clipboard for a given mime type. + * Get the data from the clipboard for a given mime type. * * The size of text data does not include the terminator, but the text is - * guaranteed to be null terminated. + * guaranteed to be null-terminated. * * \param mime_type the mime type to read from the clipboard. * \param size a pointer filled in with the length of the returned data. @@ -292,8 +292,8 @@ extern SDL_DECLSPEC void * SDLCALL SDL_GetClipboardData(const char *mime_type, s /** * Query whether there is data in the clipboard for the provided mime type. * - * \param mime_type the mime type to check for data for. - * \returns true if there exists data in clipboard for the provided mime type, + * \param mime_type the mime type to check for data. + * \returns true if data exists in the clipboard for the provided mime type, * false if it does not. * * \threadsafety This function should only be called on the main thread. @@ -310,7 +310,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_HasClipboardData(const char *mime_type); * * \param num_mime_types a pointer filled with the number of mime types, may * be NULL. - * \returns a null terminated array of strings with mime types, or NULL on + * \returns a null-terminated array of strings with mime types, or NULL on * failure; call SDL_GetError() for more information. This should be * freed with SDL_free() when it is no longer needed. * diff --git a/vendor/sdl3/include/SDL_cpuinfo.h b/vendor/sdl3/include/SDL_cpuinfo.h index 1745bd934..b1e125b55 100644 --- a/vendor/sdl3/include/SDL_cpuinfo.h +++ b/vendor/sdl3/include/SDL_cpuinfo.h @@ -344,6 +344,27 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetSystemRAM(void); */ extern SDL_DECLSPEC size_t SDLCALL SDL_GetSIMDAlignment(void); +/** + * Report the size of a page of memory. + * + * Different platforms might have different memory page sizes. In current + * times, 4 kilobytes is not unusual, but newer systems are moving to larger + * page sizes, and esoteric platforms might have any unexpected size. + * + * Note that this function can return 0, which means SDL can't determine the + * page size on this platform. It will _not_ set an error string to be + * retrieved with SDL_GetError() in this case! In this case, defaulting to + * 4096 is often a reasonable option. + * + * \returns the size of a single page of memory, in bytes, or 0 if SDL can't + * determine this information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetSystemPageSize(void); + /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/vendor/sdl3/include/SDL_dialog.h b/vendor/sdl3/include/SDL_dialog.h index ddb9e24d5..395b7e8c9 100644 --- a/vendor/sdl3/include/SDL_dialog.h +++ b/vendor/sdl3/include/SDL_dialog.h @@ -139,10 +139,12 @@ typedef void (SDLCALL *SDL_DialogFileCallback)(void *userdata, const char * cons * it will be invoked. * \param window the window that the dialog should be modal for, may be NULL. * Not all platforms support this option. - * \param filters a list of filters, may be NULL. Not all platforms support - * this option, and platforms that do support it may allow the - * user to ignore the filters. If non-NULL, it must remain - * valid at least until the callback is invoked. + * \param filters a list of filters, may be NULL. See the + * [`SDL_DialogFileFilter`](SDL_DialogFileFilter#code-examples) + * documentation for examples]. Not all platforms support this + * option, and platforms that do support it may allow the user + * to ignore the filters. If non-NULL, it must remain valid at + * least until the callback is invoked. * \param nfilters the number of filters. Ignored if filters is NULL. * \param default_location the default folder or file to start the dialog at, * may be NULL. Not all platforms support this option. diff --git a/vendor/sdl3/include/SDL_dlopennote.h b/vendor/sdl3/include/SDL_dlopennote.h new file mode 100644 index 000000000..e866d2a20 --- /dev/null +++ b/vendor/sdl3/include/SDL_dlopennote.h @@ -0,0 +1,234 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* WIKI CATEGORY: DlopenNotes */ + +/** + * # CategoryDlopenNotes + * + * This header allows you to annotate your code so external tools know about + * dynamic shared library dependencies. + * + * If you determine that your toolchain doesn't support dlopen notes, you can + * disable this feature by defining `SDL_DISABLE_DLOPEN_NOTES`. You can use + * this CMake snippet to check for support: + * + * ```cmake + * include(CheckCSourceCompiles) + * find_package(SDL3 REQUIRED CONFIG COMPONENTS Headers) + * list(APPEND CMAKE_REQUIRED_LIBRARIES SDL3::Headers) + * check_c_source_compiles([==[ + * #include + * SDL_ELF_NOTE_DLOPEN("sdl-video", + * "Support for video through SDL", + * SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED, + * "libSDL-1.2.so.0", "libSDL-2.0.so.0", "libSDL3.so.0" + * ) + * int main(int argc, char *argv[]) { + * return argc + argv[0][1]; + * } + * ]==] COMPILER_SUPPORTS_SDL_ELF_NOTE_DLOPEN) + * if(NOT COMPILER_SUPPORTS_SDL_ELF_NOTE_DLOPEN) + * add_compile_definitions(-DSDL_DISABLE_DLOPEN_NOTE) + * endif() + * ``` + */ + +#ifndef SDL_dlopennote_h +#define SDL_dlopennote_h + +/** + * Use this macro with SDL_ELF_NOTE_DLOPEN() to note that a dynamic shared + * library dependency is optional. + * + * Optional functionality uses the dependency, the binary will work and the + * dependency is only needed for full-featured installations. + * + * \since This macro is available since SDL 3.4.0. + * + * \sa SDL_ELF_NOTE_DLOPEN + * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED + * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED + */ +#define SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED "suggested" + +/** + * Use this macro with SDL_ELF_NOTE_DLOPEN() to note that a dynamic shared + * library dependency is recommended. + * + * Important functionality needs the dependency, the binary will work but in + * most cases the dependency should be provided. + * + * \since This macro is available since SDL 3.4.0. + * + * \sa SDL_ELF_NOTE_DLOPEN + * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED + * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED + */ +#define SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED "recommended" + +/** + * Use this macro with SDL_ELF_NOTE_DLOPEN() to note that a dynamic shared + * library dependency is required. + * + * Core functionality needs the dependency, the binary will not work if it + * cannot be found. + * + * \since This macro is available since SDL 3.4.0. + * + * \sa SDL_ELF_NOTE_DLOPEN + * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED + * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED + */ +#define SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED "required" + + +#if !defined(SDL_PLATFORM_UNIX) || defined(SDL_PLATFORM_ANDROID) +/* The dlopen note functionality isn't used on this platform */ +#ifndef SDL_DISABLE_DLOPEN_NOTES +#define SDL_DISABLE_DLOPEN_NOTES +#endif +#elif defined(__GNUC__) && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1)) +/* gcc < 3.1 too old */ +#ifndef SDL_DISABLE_DLOPEN_NOTES +#define SDL_DISABLE_DLOPEN_NOTES +#endif +#endif /* SDL_PLATFORM_UNIX || SDL_PLATFORM_ANDROID */ + +#if defined(__ELF__) && !defined(SDL_DISABLE_DLOPEN_NOTES) + +#include + +#define SDL_ELF_NOTE_DLOPEN_VENDOR "FDO" +#define SDL_ELF_NOTE_DLOPEN_TYPE 0x407c0c0aU + +#define SDL_ELF_NOTE_INTERNAL2(json, variable_name) \ + __attribute__((aligned(4), used, section(".note.dlopen"))) \ + static const struct { \ + struct { \ + Uint32 n_namesz; \ + Uint32 n_descsz; \ + Uint32 n_type; \ + } nhdr; \ + char name[4]; \ + __attribute__((aligned(4))) char dlopen_json[sizeof(json)]; \ + } variable_name = { \ + { \ + sizeof(SDL_ELF_NOTE_DLOPEN_VENDOR), \ + sizeof(json), \ + SDL_ELF_NOTE_DLOPEN_TYPE \ + }, \ + SDL_ELF_NOTE_DLOPEN_VENDOR, \ + json \ + } + +#define SDL_ELF_NOTE_INTERNAL(json, variable_name) \ + SDL_ELF_NOTE_INTERNAL2(json, variable_name) + +#define SDL_DLNOTE_JSON_ARRAY1(N1) "[\"" N1 "\"]" +#define SDL_DLNOTE_JSON_ARRAY2(N1,N2) "[\"" N1 "\",\"" N2 "\"]" +#define SDL_DLNOTE_JSON_ARRAY3(N1,N2,N3) "[\"" N1 "\",\"" N2 "\",\"" N3 "\"]" +#define SDL_DLNOTE_JSON_ARRAY4(N1,N2,N3,N4) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\"]" +#define SDL_DLNOTE_JSON_ARRAY5(N1,N2,N3,N4,N5) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\"]" +#define SDL_DLNOTE_JSON_ARRAY6(N1,N2,N3,N4,N5,N6) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\",\"" N6 "\"]" +#define SDL_DLNOTE_JSON_ARRAY7(N1,N2,N3,N4,N5,N6,N7) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\",\"" N6 "\",\"" N7 "\"]" +#define SDL_DLNOTE_JSON_ARRAY8(N1,N2,N3,N4,N5,N6,N7,N8) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\",\"" N6 "\",\"" N7 "\",\"" N8 "\"]" +#define SDL_DLNOTE_JSON_ARRAY_GET(N1,N2,N3,N4,N5,N6,N7,N8,NAME,...) NAME +#define SDL_DLNOTE_JSON_ARRAY(...) \ + SDL_DLNOTE_JSON_ARRAY_GET( \ + __VA_ARGS__, \ + SDL_DLNOTE_JSON_ARRAY8, \ + SDL_DLNOTE_JSON_ARRAY7, \ + SDL_DLNOTE_JSON_ARRAY6, \ + SDL_DLNOTE_JSON_ARRAY5, \ + SDL_DLNOTE_JSON_ARRAY4, \ + SDL_DLNOTE_JSON_ARRAY3, \ + SDL_DLNOTE_JSON_ARRAY2, \ + SDL_DLNOTE_JSON_ARRAY1 \ + )(__VA_ARGS__) + +/* Create "unique" variable name using __LINE__, + * so creating multiple elf notes on the same line is not supported + */ +#define SDL_DLNOTE_JOIN2(A,B) A##B +#define SDL_DLNOTE_JOIN(A,B) SDL_DLNOTE_JOIN2(A,B) +#define SDL_DLNOTE_UNIQUE_NAME SDL_DLNOTE_JOIN(s_SDL_dlopen_note_, __LINE__) + +/** + * Add a note that your application has dynamic shared library dependencies. + * + * You can do this by adding the following to the global scope: + * + * ```c + * SDL_ELF_NOTE_DLOPEN( + * "png", + * "Support for loading PNG images using libpng (required for APNG)", + * SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED, + * "libpng12.so.0" + * ) + * ``` + * + * A trailing semicolon is not needed. + * + * Or if you support multiple versions of a library, you can list them: + * + * ```c + * // Our app supports SDL1, SDL2, and SDL3 by dynamically loading them + * SDL_ELF_NOTE_DLOPEN( + * "SDL", + * "Create windows through SDL video backend", + * SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED + * "libSDL-1.2.so.0", "libSDL2-2.0.so.0", "libSDL3.so.0" + * ) + * ``` + * + * This macro is not available for compilers that do not support variadic + * macro's. + * + * \since This macro is available since SDL 3.4.0. + * + * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED + * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED + * \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED + */ +#define SDL_ELF_NOTE_DLOPEN(feature, description, priority, ...) \ + SDL_ELF_NOTE_INTERNAL( \ + "[{\"feature\":\"" feature \ + "\",\"description\":\"" description \ + "\",\"priority\":\"" priority \ + "\",\"soname\":" SDL_DLNOTE_JSON_ARRAY(__VA_ARGS__) "}]", \ + SDL_DLNOTE_UNIQUE_NAME); + +#elif defined(__GNUC__) && __GNUC__ < 3 + +#define SDL_ELF_NOTE_DLOPEN(args...) + +#elif defined(_MSC_VER) && _MSC_VER < 1400 + +/* Variadic macros are not supported */ + +#else + +#define SDL_ELF_NOTE_DLOPEN(...) + +#endif + +#endif /* SDL_dlopennote_h */ diff --git a/vendor/sdl3/include/SDL_endian.h b/vendor/sdl3/include/SDL_endian.h index a34e9d4b0..6b1b4cbcf 100644 --- a/vendor/sdl3/include/SDL_endian.h +++ b/vendor/sdl3/include/SDL_endian.h @@ -46,7 +46,7 @@ #if defined(_MSC_VER) && (_MSC_VER >= 1400) /* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version, so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */ -#ifdef __clang__ +#if defined(__clang__) && !SDL_HAS_BUILTIN(_m_prefetch) #ifndef __PRFCHWINTRIN_H #define __PRFCHWINTRIN_H static __inline__ void __attribute__((__always_inline__, __nodebug__)) @@ -128,7 +128,7 @@ _m_prefetch(void *__P) * \sa SDL_BIG_ENDIAN */ #define SDL_BYTEORDER SDL_LIL_ENDIAN___or_maybe___SDL_BIG_ENDIAN -#elif defined(SDL_PLATFORM_LINUX) +#elif defined(SDL_PLATFORM_LINUX) || defined(__GLIBC__) #include #define SDL_BYTEORDER __BYTE_ORDER #elif defined(SDL_PLATFORM_SOLARIS) @@ -252,7 +252,7 @@ SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) #elif defined(__x86_64__) SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) { - __asm__("xchgb %b0,%h0": "=Q"(x):"0"(x)); + __asm__("xchgb %b0,%h0": "=abcd"(x):"0"(x)); return x; } #elif (defined(__powerpc__) || defined(__ppc__)) @@ -486,7 +486,7 @@ SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) { return x_but_byteswapped; } * * \since This function is available since SDL 3.2.0. */ -SDL_FORCE_INLINE Uint32 SDL_Swap64(Uint64 x) { return x_but_byteswapped; } +SDL_FORCE_INLINE Uint64 SDL_Swap64(Uint64 x) { return x_but_byteswapped; } /** * Swap a 16-bit value from littleendian to native byte order. diff --git a/vendor/sdl3/include/SDL_events.h b/vendor/sdl3/include/SDL_events.h index d267f051f..4c06e45b1 100644 --- a/vendor/sdl3/include/SDL_events.h +++ b/vendor/sdl3/include/SDL_events.h @@ -30,7 +30,7 @@ * coming and going, the system changing in some way, etc. * * An app generally takes a moment, perhaps at the start of a new frame, to - * examine any events that have occured since the last time and process or + * examine any events that have occurred since the last time and process or * ignore them. This is generally done by calling SDL_PollEvent() in a loop * until it returns false (or, if using the main callbacks, events are * provided one at a time in calls to SDL_AppEvent() before the next call to @@ -127,15 +127,17 @@ typedef enum SDL_EventType SDL_EVENT_DISPLAY_DESKTOP_MODE_CHANGED, /**< Display has changed desktop mode */ SDL_EVENT_DISPLAY_CURRENT_MODE_CHANGED, /**< Display has changed current mode */ SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED, /**< Display has changed content scale */ + SDL_EVENT_DISPLAY_USABLE_BOUNDS_CHANGED, /**< Display has changed usable bounds */ SDL_EVENT_DISPLAY_FIRST = SDL_EVENT_DISPLAY_ORIENTATION, - SDL_EVENT_DISPLAY_LAST = SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED, + SDL_EVENT_DISPLAY_LAST = SDL_EVENT_DISPLAY_USABLE_BOUNDS_CHANGED, /* Window events */ /* 0x200 was SDL_WINDOWEVENT, reserve the number for sdl2-compat */ /* 0x201 was SDL_SYSWMEVENT, reserve the number for sdl2-compat */ SDL_EVENT_WINDOW_SHOWN = 0x202, /**< Window has been shown */ SDL_EVENT_WINDOW_HIDDEN, /**< Window has been hidden */ - SDL_EVENT_WINDOW_EXPOSED, /**< Window has been exposed and should be redrawn, and can be redrawn directly from event watchers for this event */ + SDL_EVENT_WINDOW_EXPOSED, /**< Window has been exposed and should be redrawn, and can be redrawn directly from event watchers for this event. + data1 is 1 for live-resize expose events, 0 otherwise. */ SDL_EVENT_WINDOW_MOVED, /**< Window has been moved to data1, data2 */ SDL_EVENT_WINDOW_RESIZED, /**< Window has been resized to data1xdata2 */ SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED,/**< The pixel size of the window has changed to data1xdata2 */ @@ -174,6 +176,8 @@ typedef enum SDL_EventType SDL_EVENT_KEYBOARD_ADDED, /**< A new keyboard has been inserted into the system */ SDL_EVENT_KEYBOARD_REMOVED, /**< A keyboard has been removed */ SDL_EVENT_TEXT_EDITING_CANDIDATES, /**< Keyboard text editing candidates */ + SDL_EVENT_SCREEN_KEYBOARD_SHOWN, /**< The on-screen keyboard has been shown */ + SDL_EVENT_SCREEN_KEYBOARD_HIDDEN, /**< The on-screen keyboard has been hidden */ /* Mouse events */ SDL_EVENT_MOUSE_MOTION = 0x400, /**< Mouse moved */ @@ -214,10 +218,15 @@ typedef enum SDL_EventType SDL_EVENT_FINGER_MOTION, SDL_EVENT_FINGER_CANCELED, + /* Pinch events */ + SDL_EVENT_PINCH_BEGIN = 0x710, /**< Pinch gesture started */ + SDL_EVENT_PINCH_UPDATE, /**< Pinch gesture updated */ + SDL_EVENT_PINCH_END, /**< Pinch gesture ended */ + /* 0x800, 0x801, and 0x802 were the Gesture events from SDL2. Do not reuse these values! sdl2-compat needs them! */ /* Clipboard events */ - SDL_EVENT_CLIPBOARD_UPDATE = 0x900, /**< The clipboard or primary selection changed */ + SDL_EVENT_CLIPBOARD_UPDATE = 0x900, /**< The clipboard changed */ /* Drag and drop events */ SDL_EVENT_DROP_FILE = 0x1000, /**< The system requests a file open */ @@ -298,7 +307,7 @@ typedef struct SDL_CommonEvent */ typedef struct SDL_DisplayEvent { - SDL_EventType type; /**< SDL_DISPLAYEVENT_* */ + SDL_EventType type; /**< SDL_EVENT_DISPLAY_* */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_DisplayID displayID;/**< The associated display */ @@ -704,6 +713,10 @@ typedef struct SDL_GamepadSensorEvent /** * Audio device event structure (event.adevice.*) * + * Note that SDL will send a SDL_EVENT_AUDIO_DEVICE_ADDED event for every + * device it discovers during initialization. After that, this event will only + * arrive when a device is hotplugged during the program's run. + * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_AudioDeviceEvent @@ -781,7 +794,19 @@ typedef struct SDL_TouchFingerEvent } SDL_TouchFingerEvent; /** - * Pressure-sensitive pen proximity event structure (event.pmotion.*) + * Pinch event structure (event.pinch.*) + */ +typedef struct SDL_PinchFingerEvent +{ + SDL_EventType type; /**< ::SDL_EVENT_PINCH_BEGIN or ::SDL_EVENT_PINCH_UPDATE or ::SDL_EVENT_PINCH_END */ + Uint32 reserved; + Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ + float scale; /**< The scale change since the last SDL_EVENT_PINCH_UPDATE. Scale < 1 is "zoom out". Scale > 1 is "zoom in". */ + SDL_WindowID windowID; /**< The window underneath the finger, if any */ +} SDL_PinchFingerEvent; + +/** + * Pressure-sensitive pen proximity event structure (event.pproximity.*) * * When a pen becomes visible to the system (it is close enough to a tablet, * etc), SDL will send an SDL_EVENT_PEN_PROXIMITY_IN event with the new pen's @@ -793,6 +818,9 @@ typedef struct SDL_TouchFingerEvent * is there." The pen touching and lifting off from the tablet while not * leaving the area are handled by SDL_EVENT_PEN_DOWN and SDL_EVENT_PEN_UP. * + * Not all platforms have a window associated with the pen during proximity + * events. Some wait until motion/button/etc events to offer this info. + * * \since This struct is available since SDL 3.2.0. */ typedef struct SDL_PenProximityEvent @@ -967,7 +995,7 @@ typedef struct SDL_QuitEvent */ typedef struct SDL_UserEvent { - Uint32 type; /**< SDL_EVENT_USER through SDL_EVENT_LAST-1, Uint32 because these are not in the SDL_EventType enumeration */ + Uint32 type; /**< SDL_EVENT_USER through SDL_EVENT_LAST, Uint32 because these are not in the SDL_EventType enumeration */ Uint32 reserved; Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */ SDL_WindowID windowID; /**< The associated window if any */ @@ -1017,6 +1045,7 @@ typedef union SDL_Event SDL_QuitEvent quit; /**< Quit request event data */ SDL_UserEvent user; /**< Custom event data */ SDL_TouchFingerEvent tfinger; /**< Touch finger event data */ + SDL_PinchFingerEvent pinch; /**< Pinch event data */ SDL_PenProximityEvent pproximity; /**< Pen proximity event data */ SDL_PenTouchEvent ptouch; /**< Pen tip touching event data */ SDL_PenMotionEvent pmotion; /**< Pen motion event data */ @@ -1043,7 +1072,7 @@ typedef union SDL_Event } SDL_Event; /* Make sure we haven't broken binary compatibility */ -SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == sizeof(((SDL_Event *)NULL)->padding)); +SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == sizeof((SDL_static_cast(SDL_Event *, NULL))->padding)); /* Function prototypes */ @@ -1255,6 +1284,13 @@ extern SDL_DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType) * } * ``` * + * Note that Windows (and possibly other platforms) has a quirk about how it + * handles events while dragging/resizing a window, which can cause this + * function to block for significant amounts of time. Technical explanations + * and solutions are discussed on the wiki: + * + * https://wiki.libsdl.org/SDL3/AppFreezeDuringDrag + * * \param event the SDL_Event structure to be filled with the next event from * the queue, or NULL. * \returns true if this got an event or false if there are none available. @@ -1391,7 +1427,10 @@ typedef bool (SDLCALL *SDL_EventFilter)(void *userdata, SDL_Event *event); * allows selective filtering of dynamically arriving events. * * **WARNING**: Be very careful of what you do in the event filter function, - * as it may run in a different thread! + * as it may run in a different thread! The exception is handling of + * SDL_EVENT_WINDOW_EXPOSED, which is guaranteed to be sent from the OS on the + * main thread and you are expected to redraw your window in response to this + * event. * * On platforms that support it, if the quit event is generated by an * interrupt signal (e.g. pressing Ctrl-C), it will be delivered to the @@ -1404,7 +1443,7 @@ typedef bool (SDLCALL *SDL_EventFilter)(void *userdata, SDL_Event *event); * the event filter, but events pushed onto the queue with SDL_PeepEvents() do * not. * - * \param filter an SDL_EventFilter function to call when an event happens. + * \param filter a function to call when an event happens. * \param userdata a pointer that is passed to `filter`. * * \threadsafety It is safe to call this function from any thread. @@ -1567,6 +1606,38 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents); */ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromEvent(const SDL_Event *event); +/** + * Generate an English description of an event. + * + * This will fill `buf` with a null-terminated string that might look + * something like this: + * + * ``` + * SDL_EVENT_MOUSE_MOTION (timestamp=1140256324 windowid=2 which=0 state=0 x=492.99 y=139.09 xrel=52 yrel=6) + * ``` + * + * The exact format of the string is not guaranteed; it is intended for + * logging purposes, to be read by a human, and not parsed by a computer. + * + * The returned value follows the same rules as SDL_snprintf(): `buf` will + * always be NULL-terminated (unless `buflen` is zero), and will be truncated + * if `buflen` is too small. The return code is the number of bytes needed for + * the complete string, not counting the NULL-terminator, whether the string + * was truncated or not. Unlike SDL_snprintf(), though, this function never + * returns -1. + * + * \param event an event to describe. May be NULL. + * \param buf the buffer to fill with the description string. May be NULL. + * \param buflen the maximum bytes that can be written to `buf`. + * \returns number of bytes needed for the full string, not counting the + * null-terminator byte. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC int SDLCALL SDL_GetEventDescription(const SDL_Event *event, char *buf, int buflen); + /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/vendor/sdl3/include/SDL_filesystem.h b/vendor/sdl3/include/SDL_filesystem.h index af3ca27e0..67f6d7ac8 100644 --- a/vendor/sdl3/include/SDL_filesystem.h +++ b/vendor/sdl3/include/SDL_filesystem.h @@ -77,6 +77,9 @@ extern "C" { * - `parent`: the containing directory of the bundle. For example: * `/Applications/SDLApp/` * + * **Android Specific Functionality**: This function returns "./", which + * allows filesystem operations to use internal storage and the asset system. + * * **Nintendo 3DS Specific Functionality**: This function returns "romfs" * directory of the application as it is uncommon to store resources outside * the executable. As such it is not a writable directory. @@ -89,6 +92,8 @@ extern "C" { * doesn't implement this functionality, call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetPrefPath @@ -134,6 +139,12 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetBasePath(void); * - ...only use letters, numbers, and spaces. Avoid punctuation like "Game * Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient. * + * Due to historical mistakes, `org` is allowed to be NULL or "". In such + * cases, SDL will omit the org subdirectory, including on platforms where it + * shouldn't, and including on platforms where this would make your app fail + * certification for an app store. New apps should definitely specify a real + * string for `org`. + * * The returned path is guaranteed to end with a path separator ('\\' on * Windows, '/' on most other platforms). * @@ -144,6 +155,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetBasePath(void); * etc.). This should be freed with SDL_free() when it is no longer * needed. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetBasePath @@ -216,6 +229,8 @@ typedef enum SDL_Folder * \returns either a null-terminated C string containing the full path to the * folder, or NULL if an error happened. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetUserFolder(SDL_Folder folder); @@ -283,6 +298,8 @@ typedef Uint32 SDL_GlobFlags; * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_CreateDirectory(const char *path); @@ -346,6 +363,8 @@ typedef SDL_EnumerationResult (SDLCALL *SDL_EnumerateDirectoryCallback)(void *us * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback callback, void *userdata); @@ -360,6 +379,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_EnumerateDirectory(const char *path, SDL_En * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_RemovePath(const char *path); @@ -367,7 +388,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RemovePath(const char *path); /** * Rename a file or directory. * - * If the file at `newpath` already exists, it will replaced. + * If the file at `newpath` already exists, it will be replaced. * * Note that this will not copy files across filesystems/drives/volumes, as * that is a much more complicated (and possibly time-consuming) operation. @@ -383,6 +404,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RemovePath(const char *path); * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_RenamePath(const char *oldpath, const char *newpath); @@ -423,6 +446,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenamePath(const char *oldpath, const char * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread, but this + * operation is not atomic, so the app might need to protect + * access to specific paths from other threads if appropriate. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_CopyFile(const char *oldpath, const char *newpath); @@ -436,6 +463,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_CopyFile(const char *oldpath, const char *n * \returns true on success or false if the file doesn't exist, or another * failure; call SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetPathInfo(const char *path, SDL_PathInfo *info); @@ -444,10 +473,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetPathInfo(const char *path, SDL_PathInfo * Enumerate a directory tree, filtered by pattern, and return a list. * * Files are filtered out if they don't match the string in `pattern`, which - * may contain wildcard characters '\*' (match everything) and '?' (match one + * may contain wildcard characters `*` (match everything) and `?` (match one * character). If pattern is NULL, no filtering is done and all results are * returned. Subdirectories are permitted, and are specified with a path - * separator of '/'. Wildcard characters '\*' and '?' never match a path + * separator of `/`. Wildcard characters `*` and `?` never match a path * separator. * * `flags` may be set to SDL_GLOB_CASEINSENSITIVE to make the pattern matching @@ -490,6 +519,8 @@ extern SDL_DECLSPEC char ** SDLCALL SDL_GlobDirectory(const char *path, const ch * platform-dependent notation. NULL if there's a problem. This * should be freed with SDL_free() when it is no longer needed. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC char * SDLCALL SDL_GetCurrentDirectory(void); diff --git a/vendor/sdl3/include/SDL_gamepad.h b/vendor/sdl3/include/SDL_gamepad.h index 99f8b6593..0102f1544 100644 --- a/vendor/sdl3/include/SDL_gamepad.h +++ b/vendor/sdl3/include/SDL_gamepad.h @@ -48,6 +48,9 @@ * SDL_INIT_GAMEPAD flag. This causes SDL to scan the system for gamepads, and * load appropriate drivers. * + * If you're using SDL gamepad support in a Steam game, you must call + * SteamAPI_InitEx() before calling SDL_Init(). + * * If you would like to receive gamepad updates while the application is in * the background, you should set the following hint before calling * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS @@ -118,6 +121,7 @@ typedef enum SDL_GamepadType SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT, SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT, SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR, + SDL_GAMEPAD_TYPE_GAMECUBE, SDL_GAMEPAD_TYPE_COUNT } SDL_GamepadType; @@ -127,8 +131,9 @@ typedef enum SDL_GamepadType * For controllers that use a diamond pattern for the face buttons, the * south/east/west/north buttons below correspond to the locations in the * diamond pattern. For Xbox controllers, this would be A/B/X/Y, for Nintendo - * Switch controllers, this would be B/A/Y/X, for PlayStation controllers this - * would be Cross/Circle/Square/Triangle. + * Switch controllers, this would be B/A/Y/X, for GameCube controllers this + * would be A/X/B/Y, for PlayStation controllers this would be + * Cross/Circle/Square/Triangle. * * For controllers that don't use a diamond pattern for the face buttons, the * south/east/west/north buttons indicate the buttons labeled A, B, C, D, or @@ -163,14 +168,14 @@ typedef enum SDL_GamepadButton SDL_GAMEPAD_BUTTON_DPAD_LEFT, SDL_GAMEPAD_BUTTON_DPAD_RIGHT, SDL_GAMEPAD_BUTTON_MISC1, /**< Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button, Google Stadia capture button) */ - SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1, /**< Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1) */ - SDL_GAMEPAD_BUTTON_LEFT_PADDLE1, /**< Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3) */ - SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2, /**< Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2) */ - SDL_GAMEPAD_BUTTON_LEFT_PADDLE2, /**< Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4) */ + SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1, /**< Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1, DualSense Edge RB button, Right Joy-Con SR button) */ + SDL_GAMEPAD_BUTTON_LEFT_PADDLE1, /**< Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3, DualSense Edge LB button, Left Joy-Con SL button) */ + SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2, /**< Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2, DualSense Edge right Fn button, Right Joy-Con SL button) */ + SDL_GAMEPAD_BUTTON_LEFT_PADDLE2, /**< Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4, DualSense Edge left Fn button, Left Joy-Con SR button) */ SDL_GAMEPAD_BUTTON_TOUCHPAD, /**< PS4/PS5 touchpad button */ SDL_GAMEPAD_BUTTON_MISC2, /**< Additional button */ - SDL_GAMEPAD_BUTTON_MISC3, /**< Additional button */ - SDL_GAMEPAD_BUTTON_MISC4, /**< Additional button */ + SDL_GAMEPAD_BUTTON_MISC3, /**< Additional button (e.g. Nintendo GameCube left trigger click) */ + SDL_GAMEPAD_BUTTON_MISC4, /**< Additional button (e.g. Nintendo GameCube right trigger click) */ SDL_GAMEPAD_BUTTON_MISC5, /**< Additional button */ SDL_GAMEPAD_BUTTON_MISC6, /**< Additional button */ SDL_GAMEPAD_BUTTON_COUNT @@ -422,6 +427,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromFile(const char *file) * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_ReloadGamepadMappings(void); @@ -436,6 +443,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReloadGamepadMappings(void); * single allocation that should be freed with SDL_free() when it is * no longer needed. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC char ** SDLCALL SDL_GetGamepadMappings(int *count); @@ -448,6 +457,8 @@ extern SDL_DECLSPEC char ** SDLCALL SDL_GetGamepadMappings(int *count); * information. This should be freed with SDL_free() when it is no * longer needed. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickGUIDForID @@ -465,6 +476,8 @@ extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForGUID(SDL_GUID guid); * available; call SDL_GetError() for more information. This should * be freed with SDL_free() when it is no longer needed. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddGamepadMapping @@ -485,6 +498,8 @@ extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMapping(SDL_Gamepad *gamepad); * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_AddGamepadMapping @@ -497,6 +512,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadMapping(SDL_JoystickID instance_i * * \returns true if a gamepad is connected, false otherwise. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepads @@ -512,6 +529,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_HasGamepad(void); * call SDL_GetError() for more information. This should be freed * with SDL_free() when it is no longer needed. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasGamepad @@ -526,6 +545,8 @@ extern SDL_DECLSPEC SDL_JoystickID * SDLCALL SDL_GetGamepads(int *count); * \returns true if the given joystick is supported by the gamepad interface, * false if it isn't or it's an invalid index. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoysticks @@ -542,6 +563,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_IsGamepad(SDL_JoystickID instance_id); * \returns the name of the selected gamepad. If no name can be found, this * function returns NULL; call SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadName @@ -558,6 +581,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadNameForID(SDL_JoystickID * \returns the path of the selected gamepad. If no path can be found, this * function returns NULL; call SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadPath @@ -573,6 +598,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPathForID(SDL_JoystickID * \param instance_id the joystick instance ID. * \returns the player index of a gamepad, or -1 if it's not available. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadPlayerIndex @@ -589,6 +616,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndexForID(SDL_JoystickID in * \returns the GUID of the selected gamepad. If called on an invalid index, * this function returns a zero GUID. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GUIDToString @@ -606,6 +635,8 @@ extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetGamepadGUIDForID(SDL_JoystickID inst * \returns the USB vendor ID of the selected gamepad. If called on an invalid * index, this function returns zero. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadVendor @@ -623,6 +654,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendorForID(SDL_JoystickID inst * \returns the USB product ID of the selected gamepad. If called on an * invalid index, this function returns zero. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadProduct @@ -640,6 +673,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductForID(SDL_JoystickID ins * \returns the product version of the selected gamepad. If called on an * invalid index, this function returns zero. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadProductVersion @@ -655,6 +690,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersionForID(SDL_Joystic * \param instance_id the joystick instance ID. * \returns the gamepad type. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadType @@ -671,6 +708,8 @@ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeForID(SDL_Joystick * \param instance_id the joystick instance ID. * \returns the gamepad type. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadTypeForID @@ -688,6 +727,8 @@ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadTypeForID(SDL_Joys * \returns the mapping string. Returns NULL if no mapping is available. This * should be freed with SDL_free() when it is no longer needed. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepads @@ -702,6 +743,8 @@ extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForID(SDL_JoystickID ins * \returns a gamepad identifier or NULL if an error occurred; call * SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_CloseGamepad @@ -717,6 +760,8 @@ extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_OpenGamepad(SDL_JoystickID instanc * \returns an SDL_Gamepad on success or NULL on failure or if it hasn't been * opened yet; call SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromID(SDL_JoystickID instance_id); @@ -727,6 +772,8 @@ extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromID(SDL_JoystickID in * \param player_index the player index, which different from the instance ID. * \returns the SDL_Gamepad associated with a player index. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadPlayerIndex @@ -757,6 +804,8 @@ extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromPlayerIndex(int play * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGamepadProperties(SDL_Gamepad *gamepad); @@ -775,6 +824,8 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGamepadProperties(SDL_Gamepa * \returns the instance ID of the specified gamepad on success or 0 on * failure; call SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetGamepadID(SDL_Gamepad *gamepad); @@ -787,6 +838,8 @@ extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetGamepadID(SDL_Gamepad *gamepad * \returns the implementation dependent name for the gamepad, or NULL if * there is no name or the identifier passed is invalid. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadNameForID @@ -801,6 +854,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadName(SDL_Gamepad *gamepad * \returns the implementation dependent path for the gamepad, or NULL if * there is no path or the identifier passed is invalid. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadPathForID @@ -814,6 +869,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPath(SDL_Gamepad *gamepad * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not * available. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadTypeForID @@ -827,6 +884,8 @@ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadType(SDL_Gamepad *game * \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not * available. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetRealGamepadTypeForID @@ -841,6 +900,8 @@ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadType(SDL_Gamepad * * \param gamepad the gamepad object to query. * \returns the player index for gamepad, or -1 if it's not available. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetGamepadPlayerIndex @@ -856,6 +917,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndex(SDL_Gamepad *gamepad); * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadPlayerIndex @@ -870,6 +933,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadPlayerIndex(SDL_Gamepad *gamepad, * \param gamepad the gamepad object to query. * \returns the USB vendor ID, or zero if unavailable. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadVendorForID @@ -884,6 +949,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendor(SDL_Gamepad *gamepad); * \param gamepad the gamepad object to query. * \returns the USB product ID, or zero if unavailable. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadProductForID @@ -898,6 +965,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProduct(SDL_Gamepad *gamepad); * \param gamepad the gamepad object to query. * \returns the USB product version, or zero if unavailable. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadProductVersionForID @@ -912,6 +981,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersion(SDL_Gamepad *gam * \param gamepad the gamepad object to query. * \returns the gamepad firmware version, or zero if unavailable. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadFirmwareVersion(SDL_Gamepad *gamepad); @@ -924,6 +995,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadFirmwareVersion(SDL_Gamepad *ga * \param gamepad the gamepad object to query. * \returns the serial number, or NULL if unavailable. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadSerial(SDL_Gamepad *gamepad); @@ -937,6 +1010,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadSerial(SDL_Gamepad *gamep * \param gamepad the gamepad object to query. * \returns the gamepad handle, or 0 if unavailable. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetGamepadSteamHandle(SDL_Gamepad *gamepad); @@ -949,6 +1024,8 @@ extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetGamepadSteamHandle(SDL_Gamepad *gamepa * `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError() * for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetGamepadConnectionState(SDL_Gamepad *gamepad); @@ -969,6 +1046,8 @@ extern SDL_DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetGamepadConnection * battery. * \returns the current battery state. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetGamepadPowerInfo(SDL_Gamepad *gamepad, int *percent); @@ -981,6 +1060,8 @@ extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetGamepadPowerInfo(SDL_Gamepad * * \returns true if the gamepad has been opened and is currently connected, or * false if not. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadConnected(SDL_Gamepad *gamepad); @@ -1001,6 +1082,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadConnected(SDL_Gamepad *gamepad); * \returns an SDL_Joystick object, or NULL on failure; call SDL_GetError() * for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetGamepadJoystick(SDL_Gamepad *gamepad); @@ -1013,6 +1096,8 @@ extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetGamepadJoystick(SDL_Gamepad *g * * \param enabled whether to process gamepad events or not. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GamepadEventsEnabled @@ -1028,6 +1113,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_SetGamepadEventsEnabled(bool enabled); * * \returns true if gamepad events are being processed, false otherwise. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetGamepadEventsEnabled @@ -1044,6 +1131,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadEventsEnabled(void); * single allocation that should be freed with SDL_free() when it is * no longer needed. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_GamepadBinding ** SDLCALL SDL_GetGamepadBindings(SDL_Gamepad *gamepad, int *count); @@ -1055,6 +1144,8 @@ extern SDL_DECLSPEC SDL_GamepadBinding ** SDLCALL SDL_GetGamepadBindings(SDL_Gam * enabled. Under such circumstances, it will not be necessary to call this * function. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_UpdateGamepads(void); @@ -1071,6 +1162,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_UpdateGamepads(void); * \returns the SDL_GamepadType enum corresponding to the input string, or * `SDL_GAMEPAD_TYPE_UNKNOWN` if no match was found. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadStringForType @@ -1085,6 +1178,8 @@ extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeFromString(const c * specified. The string returned is of the format used by * SDL_Gamepad mapping strings. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadTypeFromString @@ -1107,6 +1202,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForType(SDL_Gamepad * \returns the SDL_GamepadAxis enum corresponding to the input string, or * `SDL_GAMEPAD_AXIS_INVALID` if no match was found. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadStringForAxis @@ -1121,6 +1218,8 @@ extern SDL_DECLSPEC SDL_GamepadAxis SDLCALL SDL_GetGamepadAxisFromString(const c * specified. The string returned is of the format used by * SDL_Gamepad mapping strings. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadAxisFromString @@ -1137,6 +1236,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForAxis(SDL_Gamepad * \param axis an axis enum value (an SDL_GamepadAxis value). * \returns true if the gamepad has this axis, false otherwise. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GamepadHasButton @@ -1156,10 +1257,14 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasAxis(SDL_Gamepad *gamepad, SDL_Ga * return a negative value. Note that this differs from the value reported by * the lower-level SDL_GetJoystickAxis(), which normally uses the full range. * + * Note that for invalid gamepads or axes, this will return 0. Zero is also a + * valid value in normal operation; usually it means a centered axis. + * * \param gamepad a gamepad. * \param axis an axis index (one of the SDL_GamepadAxis values). - * \returns axis state (including 0) on success or 0 (also) on failure; call - * SDL_GetError() for more information. + * \returns axis state. + * + * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * @@ -1176,10 +1281,12 @@ extern SDL_DECLSPEC Sint16 SDLCALL SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_ * You do not normally need to call this function unless you are parsing * SDL_Gamepad mappings in your own code. * - * \param str string representing a SDL_Gamepad axis. + * \param str string representing a SDL_Gamepad button. * \returns the SDL_GamepadButton enum corresponding to the input string, or * `SDL_GAMEPAD_BUTTON_INVALID` if no match was found. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadStringForButton @@ -1194,6 +1301,8 @@ extern SDL_DECLSPEC SDL_GamepadButton SDLCALL SDL_GetGamepadButtonFromString(con * specified. The string returned is of the format used by * SDL_Gamepad mapping strings. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadButtonFromString @@ -1210,6 +1319,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForButton(SDL_Gamep * \param button a button enum value (an SDL_GamepadButton value). * \returns true if the gamepad has this button, false otherwise. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GamepadHasAxis @@ -1223,6 +1334,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasButton(SDL_Gamepad *gamepad, SDL_ * \param button a button index (one of the SDL_GamepadButton values). * \returns true if the button is pressed, false otherwise. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GamepadHasButton @@ -1237,6 +1350,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_ * \param button a button index (one of the SDL_GamepadButton values). * \returns the SDL_GamepadButtonLabel enum corresponding to the button label. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadButtonLabel @@ -1250,6 +1365,8 @@ extern SDL_DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabelForT * \param button a button index (one of the SDL_GamepadButton values). * \returns the SDL_GamepadButtonLabel enum corresponding to the button label. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadButtonLabelForType @@ -1262,6 +1379,8 @@ extern SDL_DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabel(SDL * \param gamepad a gamepad. * \returns number of touchpads. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetNumGamepadTouchpadFingers @@ -1276,6 +1395,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpads(SDL_Gamepad *gamepad) * \param touchpad a touchpad. * \returns number of supported simultaneous fingers. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadTouchpadFinger @@ -1299,6 +1420,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpadFingers(SDL_Gamepad *ga * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetNumGamepadTouchpadFingers @@ -1312,6 +1435,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadTouchpadFinger(SDL_Gamepad *gamep * \param type the type of sensor to query. * \returns true if the sensor exists, false otherwise. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadSensorData @@ -1329,6 +1454,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasSensor(SDL_Gamepad *gamepad, SDL_ * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GamepadHasSensor @@ -1343,6 +1470,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadSensorEnabled(SDL_Gamepad *gamepa * \param type the type of sensor to query. * \returns true if the sensor is enabled, false otherwise. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetGamepadSensorEnabled @@ -1356,6 +1485,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GamepadSensorEnabled(SDL_Gamepad *gamepad, * \param type the type of sensor to query. * \returns the data rate, or 0.0f if the data rate is not available. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *gamepad, SDL_SensorType type); @@ -1364,7 +1495,7 @@ extern SDL_DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *game * Get the current state of a gamepad sensor. * * The number of values and interpretation of the data is sensor dependent. - * See SDL_sensor.h for the details for each type of sensor. + * See the remarks in SDL_SensorType for details for each type of sensor. * * \param gamepad the gamepad to query. * \param type the type of sensor to query. @@ -1373,6 +1504,8 @@ extern SDL_DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *game * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, SDL_SensorType type, float *data, int num_values); @@ -1395,6 +1528,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); @@ -1421,6 +1556,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_RumbleGamepad @@ -1443,6 +1580,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad, * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue); @@ -1456,6 +1595,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 r * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SendGamepadEffect(SDL_Gamepad *gamepad, const void *data, int size); @@ -1466,6 +1607,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SendGamepadEffect(SDL_Gamepad *gamepad, con * \param gamepad a gamepad identifier previously returned by * SDL_OpenGamepad(). * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_OpenGamepad @@ -1480,6 +1623,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_CloseGamepad(SDL_Gamepad *gamepad); * \param button a button on the gamepad. * \returns the sfSymbolsName or NULL if the name can't be found. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadAppleSFSymbolsNameForAxis @@ -1493,6 +1638,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForButt * \param axis an axis on the gamepad. * \returns the sfSymbolsName or NULL if the name can't be found. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetGamepadAppleSFSymbolsNameForButton diff --git a/vendor/sdl3/include/SDL_gpu.h b/vendor/sdl3/include/SDL_gpu.h index b61661909..d35104a7d 100644 --- a/vendor/sdl3/include/SDL_gpu.h +++ b/vendor/sdl3/include/SDL_gpu.h @@ -206,14 +206,20 @@ * underlying graphics API. While it's possible that we have done something * inefficiently, it's very unlikely especially if you are relatively * inexperienced with GPU rendering. Please see the performance tips above and - * make sure you are following them. Additionally, tools like RenderDoc can be - * very helpful for diagnosing incorrect behavior and performance issues. + * make sure you are following them. Additionally, tools like + * [RenderDoc](https://renderdoc.org/) + * can be very helpful for diagnosing incorrect behavior and performance + * issues. * * ## System Requirements * - * **Vulkan:** Supported on Windows, Linux, Nintendo Switch, and certain - * Android devices. Requires Vulkan 1.0 with the following extensions and - * device features: + * ### Vulkan + * + * SDL driver name: "vulkan" (for use in SDL_CreateGPUDevice() and + * SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING) + * + * Supported on Windows, Linux, Nintendo Switch, and certain Android devices. + * Requires Vulkan 1.0 with the following extensions and device features: * * - `VK_KHR_swapchain` * - `VK_KHR_maintenance1` @@ -222,13 +228,37 @@ * - `depthClamp` * - `shaderClipDistance` * - `drawIndirectFirstInstance` + * - `sampleRateShading` * - * **D3D12:** Supported on Windows 10 or newer, Xbox One (GDK), and Xbox - * Series X|S (GDK). Requires a GPU that supports DirectX 12 Feature Level - * 11_1. + * You can remove some of these requirements to increase compatibility with + * Android devices by using these properties when creating the GPU device with + * SDL_CreateGPUDeviceWithProperties(): * - * **Metal:** Supported on macOS 10.14+ and iOS/tvOS 13.0+. Hardware - * requirements vary by operating system: + * - SDL_PROP_GPU_DEVICE_CREATE_FEATURE_CLIP_DISTANCE_BOOLEAN + * - SDL_PROP_GPU_DEVICE_CREATE_FEATURE_DEPTH_CLAMPING_BOOLEAN + * - SDL_PROP_GPU_DEVICE_CREATE_FEATURE_INDIRECT_DRAW_FIRST_INSTANCE_BOOLEAN + * - SDL_PROP_GPU_DEVICE_CREATE_FEATURE_ANISOTROPY_BOOLEAN + * + * ### D3D12 + * + * SDL driver name: "direct3d12" + * + * Supported on Windows 10 or newer, Xbox One (GDK), and Xbox Series X|S + * (GDK). Requires a GPU that supports DirectX 12 Feature Level 11_0 and + * Resource Binding Tier 2 or above. + * + * You can remove the Tier 2 resource binding requirement to support Intel + * Haswell and Broadwell GPUs by using this property when creating the GPU + * device with SDL_CreateGPUDeviceWithProperties(): + * + * - SDL_PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN + * + * ### Metal + * + * SDL driver name: "metal" + * + * Supported on macOS 10.14+ and iOS/tvOS 13.0+. Hardware requirements vary by + * operating system: * * - macOS requires an Apple Silicon or * [Intel Mac2 family](https://developer.apple.com/documentation/metal/mtlfeatureset/mtlfeatureset_macos_gpufamily2_v1?language=objc) @@ -236,6 +266,26 @@ * - iOS/tvOS requires an A9 GPU or newer * - iOS Simulator and tvOS Simulator are unsupported * + * ## Coordinate System + * + * The GPU API uses a left-handed coordinate system, following the convention + * of D3D12 and Metal. Specifically: + * + * - **Normalized Device Coordinates:** The lower-left corner has an x,y + * coordinate of `(-1.0, -1.0)`. The upper-right corner is `(1.0, 1.0)`. Z + * values range from `[0.0, 1.0]` where 0 is the near plane. + * - **Viewport Coordinates:** The top-left corner has an x,y coordinate of + * `(0, 0)` and extends to the bottom-right corner at `(viewportWidth, + * viewportHeight)`. +Y is down. + * - **Texture Coordinates:** The top-left corner has an x,y coordinate of + * `(0, 0)` and extends to the bottom-right corner at `(1.0, 1.0)`. +Y is + * down. + * + * If the backend driver differs from this convention (e.g. Vulkan, which has + * an NDC that assumes +Y is down), SDL will automatically convert the + * coordinate system behind the scenes, so you don't need to perform any + * coordinate flipping logic in your shaders. + * * ## Uniform Data * * Uniforms are for passing data to shaders. The uniform data will be constant @@ -301,6 +351,39 @@ * unreferenced data in a bound resource without cycling, but overwriting a * section of data that has already been referenced will produce unexpected * results. + * + * ## Debugging + * + * At some point of your GPU journey, you will probably encounter issues that + * are not traceable with regular debugger - for example, your code compiles + * but you get an empty screen, or your shader fails in runtime. + * + * For debugging such cases, there are tools that allow visually inspecting + * the whole GPU frame, every drawcall, every bound resource, memory buffers, + * etc. They are the following, per platform: + * + * * For Windows/Linux, use + * [RenderDoc](https://renderdoc.org/) + * * For MacOS (Metal), use Xcode built-in debugger (Open XCode, go to Debug > + * Debug Executable..., select your application, set "GPU Frame Capture" to + * "Metal" in scheme "Options" window, run your app, and click the small + * Metal icon on the bottom to capture a frame) + * + * Aside from that, you may want to enable additional debug layers to receive + * more detailed error messages, based on your GPU backend: + * + * * For D3D12, the debug layer is an optional feature that can be installed + * via "Windows Settings -> System -> Optional features" and adding the + * "Graphics Tools" optional feature. + * * For Vulkan, you will need to install Vulkan SDK on Windows, and on Linux, + * you usually have some sort of `vulkan-validation-layers` system package + * that should be installed. + * * For Metal, it should be enough just to run the application from XCode to + * receive detailed errors or warnings in the output. + * + * Don't hesitate to use tools as RenderDoc when encountering runtime issues + * or unexpected output on screen, quick GPU frame inspection can usually help + * you fix the majority of such problems. */ #ifndef SDL_gpu_h_ @@ -1091,7 +1174,7 @@ typedef enum SDL_GPUCompareOp SDL_GPU_COMPAREOP_LESS_OR_EQUAL, /**< The comparison evaluates reference <= test. */ SDL_GPU_COMPAREOP_GREATER, /**< The comparison evaluates reference > test. */ SDL_GPU_COMPAREOP_NOT_EQUAL, /**< The comparison evaluates reference != test. */ - SDL_GPU_COMPAREOP_GREATER_OR_EQUAL, /**< The comparison evalutes reference >= test. */ + SDL_GPU_COMPAREOP_GREATER_OR_EQUAL, /**< The comparison evaluates reference >= test. */ SDL_GPU_COMPAREOP_ALWAYS /**< The comparison always evaluates true. */ } SDL_GPUCompareOp; @@ -1310,6 +1393,17 @@ typedef struct SDL_GPUViewport * A structure specifying parameters related to transferring data to or from a * texture. * + * If either of `pixels_per_row` or `rows_per_layer` is zero, then width and + * height of passed SDL_GPUTextureRegion to SDL_UploadToGPUTexture or + * SDL_DownloadFromGPUTexture are used as default values respectively and data + * is considered to be tightly packed. + * + * **WARNING**: Direct3D 12 requires texture data row pitch to be 256 byte + * aligned, and offsets to be aligned to 512 bytes. If they are not, SDL will + * make a temporary copy of the data that is properly aligned, but this adds + * overhead to the transfer process. Apps can avoid this by aligning their + * data appropriately, or using a different GPU backend than Direct3D 12. + * * \since This struct is available since SDL 3.2.0. * * \sa SDL_UploadToGPUTexture @@ -1391,7 +1485,7 @@ typedef struct SDL_GPUTextureRegion */ typedef struct SDL_GPUBlitRegion { - SDL_GPUTexture *texture; /**< The texture. */ + SDL_GPUTexture *texture; /**< The texture. */ Uint32 mip_level; /**< The mip level index of the region. */ Uint32 layer_or_depth_plane; /**< The layer index or depth plane of the region. This value is treated as a layer index on 2D array and cube textures, and as a depth plane on 3D textures. */ Uint32 x; /**< The left offset of the region. */ @@ -1520,8 +1614,8 @@ typedef struct SDL_GPUSamplerCreateInfo SDL_GPUCompareOp compare_op; /**< The comparison operator to apply to fetched data before filtering. */ float min_lod; /**< Clamps the minimum of the computed LOD value. */ float max_lod; /**< Clamps the maximum of the computed LOD value. */ - bool enable_anisotropy; /**< true to enable anisotropic filtering. */ - bool enable_compare; /**< true to enable comparison against a reference value during lookups. */ + bool enable_anisotropy; /**< true to enable anisotropic filtering. */ + bool enable_compare; /**< true to enable comparison against a reference value during lookups. */ Uint8 padding1; Uint8 padding2; @@ -1549,7 +1643,7 @@ typedef struct SDL_GPUSamplerCreateInfo typedef struct SDL_GPUVertexBufferDescription { Uint32 slot; /**< The binding slot of the vertex buffer. */ - Uint32 pitch; /**< The byte pitch between consecutive elements of the vertex buffer. */ + Uint32 pitch; /**< The size of a single element + the offset between elements. */ SDL_GPUVertexInputRate input_rate; /**< Whether attribute addressing is a function of the vertex index or instance index. */ Uint32 instance_step_rate; /**< Reserved for future use. Must be set to 0. */ } SDL_GPUVertexBufferDescription; @@ -1613,6 +1707,9 @@ typedef struct SDL_GPUStencilOpState * \since This struct is available since SDL 3.2.0. * * \sa SDL_GPUColorTargetDescription + * \sa SDL_GPUBlendFactor + * \sa SDL_GPUBlendOp + * \sa SDL_GPUColorComponentFlags */ typedef struct SDL_GPUColorTargetBlendState { @@ -1623,8 +1720,8 @@ typedef struct SDL_GPUColorTargetBlendState SDL_GPUBlendFactor dst_alpha_blendfactor; /**< The value to be multiplied by the destination alpha. */ SDL_GPUBlendOp alpha_blend_op; /**< The blend operation for the alpha component. */ SDL_GPUColorComponentFlags color_write_mask; /**< A bitmask specifying which of the RGBA components are enabled for writing. Writes to all channels if enable_color_write_mask is false. */ - bool enable_blend; /**< Whether blending is enabled for the color target. */ - bool enable_color_write_mask; /**< Whether the color write mask is enabled. */ + bool enable_blend; /**< Whether blending is enabled for the color target. */ + bool enable_color_write_mask; /**< Whether the color write mask is enabled. */ Uint8 padding1; Uint8 padding2; } SDL_GPUColorTargetBlendState; @@ -1636,6 +1733,8 @@ typedef struct SDL_GPUColorTargetBlendState * \since This struct is available since SDL 3.2.0. * * \sa SDL_CreateGPUShader + * \sa SDL_GPUShaderFormat + * \sa SDL_GPUShaderStage */ typedef struct SDL_GPUShaderCreateInfo { @@ -1741,8 +1840,8 @@ typedef struct SDL_GPURasterizerState float depth_bias_constant_factor; /**< A scalar factor controlling the depth value added to each fragment. */ float depth_bias_clamp; /**< The maximum depth bias of a fragment. */ float depth_bias_slope_factor; /**< A scalar factor applied to a fragment's slope in depth calculations. */ - bool enable_depth_bias; /**< true to bias fragment depth values. */ - bool enable_depth_clip; /**< true to enable depth clip, false to enable depth clamp. */ + bool enable_depth_bias; /**< true to bias fragment depth values. */ + bool enable_depth_clip; /**< true to enable depth clip, false to enable depth clamp. */ Uint8 padding1; Uint8 padding2; } SDL_GPURasterizerState; @@ -1759,8 +1858,8 @@ typedef struct SDL_GPUMultisampleState { SDL_GPUSampleCount sample_count; /**< The number of samples to be used in rasterization. */ Uint32 sample_mask; /**< Reserved for future use. Must be set to 0. */ - bool enable_mask; /**< Reserved for future use. Must be set to false. */ - Uint8 padding1; + bool enable_mask; /**< Reserved for future use. Must be set to false. */ + bool enable_alpha_to_coverage; /**< true enables the alpha-to-coverage feature. */ Uint8 padding2; Uint8 padding3; } SDL_GPUMultisampleState; @@ -1780,9 +1879,9 @@ typedef struct SDL_GPUDepthStencilState SDL_GPUStencilOpState front_stencil_state; /**< The stencil op state for front-facing triangles. */ Uint8 compare_mask; /**< Selects the bits of the stencil values participating in the stencil test. */ Uint8 write_mask; /**< Selects the bits of the stencil values updated by the stencil test. */ - bool enable_depth_test; /**< true enables the depth test. */ - bool enable_depth_write; /**< true enables depth writes. Depth writes are always disabled when enable_depth_test is false. */ - bool enable_stencil_test; /**< true enables the stencil test. */ + bool enable_depth_test; /**< true enables the depth test. */ + bool enable_depth_write; /**< true enables depth writes. Depth writes are always disabled when enable_depth_test is false. */ + bool enable_stencil_test; /**< true enables the stencil test. */ Uint8 padding1; Uint8 padding2; Uint8 padding3; @@ -1817,7 +1916,7 @@ typedef struct SDL_GPUGraphicsPipelineTargetInfo const SDL_GPUColorTargetDescription *color_target_descriptions; /**< A pointer to an array of color target descriptions. */ Uint32 num_color_targets; /**< The number of color target descriptions in the above array. */ SDL_GPUTextureFormat depth_stencil_format; /**< The pixel format of the depth-stencil target. Ignored if has_depth_stencil_target is false. */ - bool has_depth_stencil_target; /**< true specifies that the pipeline uses a depth-stencil target. */ + bool has_depth_stencil_target; /**< true specifies that the pipeline uses a depth-stencil target. */ Uint8 padding1; Uint8 padding2; Uint8 padding3; @@ -1912,6 +2011,7 @@ typedef struct SDL_GPUComputePipelineCreateInfo * \since This struct is available since SDL 3.2.0. * * \sa SDL_BeginGPURenderPass + * \sa SDL_FColor */ typedef struct SDL_GPUColorTargetInfo { @@ -1924,8 +2024,8 @@ typedef struct SDL_GPUColorTargetInfo SDL_GPUTexture *resolve_texture; /**< The texture that will receive the results of a multisample resolve operation. Ignored if a RESOLVE* store_op is not used. */ Uint32 resolve_mip_level; /**< The mip level of the resolve texture to use for the resolve operation. Ignored if a RESOLVE* store_op is not used. */ Uint32 resolve_layer; /**< The layer index of the resolve texture to use for the resolve operation. Ignored if a RESOLVE* store_op is not used. */ - bool cycle; /**< true cycles the texture if the texture is bound and load_op is not LOAD */ - bool cycle_resolve_texture; /**< true cycles the resolve texture if the resolve texture is bound. Ignored if a RESOLVE* store_op is not used. */ + bool cycle; /**< true cycles the texture if the texture is bound and load_op is not LOAD */ + bool cycle_resolve_texture; /**< true cycles the resolve texture if the resolve texture is bound. Ignored if a RESOLVE* store_op is not used. */ Uint8 padding1; Uint8 padding2; } SDL_GPUColorTargetInfo; @@ -1970,6 +2070,9 @@ typedef struct SDL_GPUColorTargetInfo * * Note that depth/stencil targets do not support multisample resolves. * + * Due to ABI limitations, depth textures with more than 255 layers are not + * supported. + * * \since This struct is available since SDL 3.2.0. * * \sa SDL_BeginGPURenderPass @@ -1982,10 +2085,10 @@ typedef struct SDL_GPUDepthStencilTargetInfo SDL_GPUStoreOp store_op; /**< What is done with the depth results of the render pass. */ SDL_GPULoadOp stencil_load_op; /**< What is done with the stencil contents at the beginning of the render pass. */ SDL_GPUStoreOp stencil_store_op; /**< What is done with the stencil results of the render pass. */ - bool cycle; /**< true cycles the texture if the texture is bound and any load ops are not LOAD */ + bool cycle; /**< true cycles the texture if the texture is bound and any load ops are not LOAD */ Uint8 clear_stencil; /**< The value to clear the stencil component to at the beginning of the render pass. Ignored if SDL_GPU_LOADOP_CLEAR is not used. */ - Uint8 padding1; - Uint8 padding2; + Uint8 mip_level; /**< The mip level to use as the depth stencil target. */ + Uint8 layer; /**< The layer index to use as the depth stencil target. */ } SDL_GPUDepthStencilTargetInfo; /** @@ -2002,7 +2105,7 @@ typedef struct SDL_GPUBlitInfo { SDL_FColor clear_color; /**< The color to clear the destination region to before the blit. Ignored if load_op is not SDL_GPU_LOADOP_CLEAR. */ SDL_FlipMode flip_mode; /**< The flip mode for the source region. */ SDL_GPUFilter filter; /**< The filter mode used when blitting. */ - bool cycle; /**< true cycles the destination texture if it is already bound. */ + bool cycle; /**< true cycles the destination texture if it is already bound. */ Uint8 padding1; Uint8 padding2; Uint8 padding3; @@ -2031,6 +2134,8 @@ typedef struct SDL_GPUBufferBinding * * \sa SDL_BindGPUVertexSamplers * \sa SDL_BindGPUFragmentSamplers + * \sa SDL_GPUTexture + * \sa SDL_GPUSampler */ typedef struct SDL_GPUTextureSamplerBinding { @@ -2111,6 +2216,13 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GPUSupportsProperties( /** * Creates a GPU context. * + * The GPU driver name can be one of the following: + * + * - "vulkan": [Vulkan](CategoryGPU#vulkan) + * - "direct3d12": [D3D12](CategoryGPU#d3d12) + * - "metal": [Metal](CategoryGPU#metal) + * - NULL: let SDL pick the optimal driver + * * \param format_flags a bitflag indicating which shader formats the app is * able to provide. * \param debug_mode enable debug mode properties and validations. @@ -2121,6 +2233,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GPUSupportsProperties( * * \since This function is available since SDL 3.2.0. * + * \sa SDL_CreateGPUDeviceWithProperties * \sa SDL_GetGPUShaderFormats * \sa SDL_GetGPUDeviceDriver * \sa SDL_DestroyGPUDevice @@ -2140,8 +2253,31 @@ extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDevice( * properties and validations, defaults to true. * - `SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEAN`: enable to prefer * energy efficiency over maximum GPU performance, defaults to false. + * - `SDL_PROP_GPU_DEVICE_CREATE_VERBOSE_BOOLEAN`: enable to automatically log + * useful debug information on device creation, defaults to true. * - `SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING`: the name of the GPU driver to * use, if a specific one is desired. + * - `SDL_PROP_GPU_DEVICE_CREATE_FEATURE_CLIP_DISTANCE_BOOLEAN`: Enable Vulkan + * device feature shaderClipDistance. If disabled, clip distances are not + * supported in shader code: gl_ClipDistance[] built-ins of GLSL, + * SV_ClipDistance0/1 semantics of HLSL and [[clip_distance]] attribute of + * Metal. Disabling optional features allows the application to run on some + * older Android devices. Defaults to true. + * - `SDL_PROP_GPU_DEVICE_CREATE_FEATURE_DEPTH_CLAMPING_BOOLEAN`: Enable + * Vulkan device feature depthClamp. If disabled, there is no depth clamp + * support and enable_depth_clip in SDL_GPURasterizerState must always be + * set to true. Disabling optional features allows the application to run on + * some older Android devices. Defaults to true. + * - `SDL_PROP_GPU_DEVICE_CREATE_FEATURE_INDIRECT_DRAW_FIRST_INSTANCE_BOOLEAN`: + * Enable Vulkan device feature drawIndirectFirstInstance. If disabled, the + * argument first_instance of SDL_GPUIndirectDrawCommand must be set to + * zero. Disabling optional features allows the application to run on some + * older Android devices. Defaults to true. + * - `SDL_PROP_GPU_DEVICE_CREATE_FEATURE_ANISOTROPY_BOOLEAN`: Enable Vulkan + * device feature samplerAnisotropy. If disabled, enable_anisotropy of + * SDL_GPUSamplerCreateInfo must be set to false. Disabling optional + * features allows the application to run on some older Android devices. + * Defaults to true. * * These are the current shader format properties: * @@ -2158,10 +2294,32 @@ extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDevice( * - `SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN`: The app is able to * provide Metal shader libraries if applicable. * - * With the D3D12 renderer: + * With the D3D12 backend: * * - `SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING`: the prefix to * use for all vertex semantics, default is "TEXCOORD". + * - `SDL_PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN`: By + * default, Resourcing Binding Tier 2 is required for D3D12 support. + * However, an application can set this property to true to enable Tier 1 + * support, if (and only if) the application uses 8 or fewer storage + * resources across all shader stages. As of writing, this property is + * useful for targeting Intel Haswell and Broadwell GPUs; other hardware + * either supports Tier 2 Resource Binding or does not support D3D12 in any + * capacity. Defaults to false. + * + * With the Vulkan backend: + * + * - `SDL_PROP_GPU_DEVICE_CREATE_VULKAN_REQUIRE_HARDWARE_ACCELERATION_BOOLEAN`: + * By default, Vulkan device enumeration includes drivers of all types, + * including software renderers (for example, the Lavapipe Mesa driver). + * This can be useful if your application _requires_ SDL_GPU, but if you can + * provide your own fallback renderer (for example, an OpenGL renderer) this + * property can be set to true. Defaults to false. + * - `SDL_PROP_GPU_DEVICE_CREATE_VULKAN_OPTIONS_POINTER`: a pointer to an + * SDL_GPUVulkanOptions structure to be processed during device creation. + * This allows configuring a variety of Vulkan-specific options such as + * increasing the API version and opting into extensions aside from the + * minimal set SDL requires. * * \param props the properties to use. * \returns a GPU context on success or NULL on failure; call SDL_GetError() @@ -2177,16 +2335,52 @@ extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDevice( extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDeviceWithProperties( SDL_PropertiesID props); -#define SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOLEAN "SDL.gpu.device.create.debugmode" -#define SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEAN "SDL.gpu.device.create.preferlowpower" -#define SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING "SDL.gpu.device.create.name" -#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOLEAN "SDL.gpu.device.create.shaders.private" -#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOLEAN "SDL.gpu.device.create.shaders.spirv" -#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOLEAN "SDL.gpu.device.create.shaders.dxbc" -#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOLEAN "SDL.gpu.device.create.shaders.dxil" -#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOLEAN "SDL.gpu.device.create.shaders.msl" -#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN "SDL.gpu.device.create.shaders.metallib" -#define SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING "SDL.gpu.device.create.d3d12.semantic" +#define SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOLEAN "SDL.gpu.device.create.debugmode" +#define SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEAN "SDL.gpu.device.create.preferlowpower" +#define SDL_PROP_GPU_DEVICE_CREATE_VERBOSE_BOOLEAN "SDL.gpu.device.create.verbose" +#define SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING "SDL.gpu.device.create.name" +#define SDL_PROP_GPU_DEVICE_CREATE_FEATURE_CLIP_DISTANCE_BOOLEAN "SDL.gpu.device.create.feature.clip_distance" +#define SDL_PROP_GPU_DEVICE_CREATE_FEATURE_DEPTH_CLAMPING_BOOLEAN "SDL.gpu.device.create.feature.depth_clamping" +#define SDL_PROP_GPU_DEVICE_CREATE_FEATURE_INDIRECT_DRAW_FIRST_INSTANCE_BOOLEAN "SDL.gpu.device.create.feature.indirect_draw_first_instance" +#define SDL_PROP_GPU_DEVICE_CREATE_FEATURE_ANISOTROPY_BOOLEAN "SDL.gpu.device.create.feature.anisotropy" +#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOLEAN "SDL.gpu.device.create.shaders.private" +#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOLEAN "SDL.gpu.device.create.shaders.spirv" +#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOLEAN "SDL.gpu.device.create.shaders.dxbc" +#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOLEAN "SDL.gpu.device.create.shaders.dxil" +#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOLEAN "SDL.gpu.device.create.shaders.msl" +#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN "SDL.gpu.device.create.shaders.metallib" +#define SDL_PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN "SDL.gpu.device.create.d3d12.allowtier1resourcebinding" +#define SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING "SDL.gpu.device.create.d3d12.semantic" +#define SDL_PROP_GPU_DEVICE_CREATE_VULKAN_REQUIRE_HARDWARE_ACCELERATION_BOOLEAN "SDL.gpu.device.create.vulkan.requirehardwareacceleration" +#define SDL_PROP_GPU_DEVICE_CREATE_VULKAN_OPTIONS_POINTER "SDL.gpu.device.create.vulkan.options" + + +/** + * A structure specifying additional options when using Vulkan. + * + * When no such structure is provided, SDL will use Vulkan API version 1.0 and + * a minimal set of features. The requested API version influences how the + * feature_list is processed by SDL. When requesting API version 1.0, the + * feature_list is ignored. Only the vulkan_10_physical_device_features and + * the extension lists are used. When requesting API version 1.1, the + * feature_list is scanned for feature structures introduced in Vulkan 1.1. + * When requesting Vulkan 1.2 or higher, the feature_list is additionally + * scanned for compound feature structs such as + * VkPhysicalDeviceVulkan11Features. The device and instance extension lists, + * as well as vulkan_10_physical_device_features, are always processed. + * + * \since This struct is available since SDL 3.4.0. + */ +typedef struct SDL_GPUVulkanOptions +{ + Uint32 vulkan_api_version; /**< The Vulkan API version to request for the instance. Use Vulkan's VK_MAKE_VERSION or VK_MAKE_API_VERSION. */ + void *feature_list; /**< Pointer to the first element of a chain of Vulkan feature structs. (Requires API version 1.1 or higher.)*/ + void *vulkan_10_physical_device_features; /**< Pointer to a VkPhysicalDeviceFeatures struct to enable additional Vulkan 1.0 features. */ + Uint32 device_extension_count; /**< Number of additional device extensions to require. */ + const char **device_extension_names; /**< Pointer to a list of additional device extensions to require. */ + Uint32 instance_extension_count; /**< Number of additional instance extensions to require. */ + const char **instance_extension_names; /**< Pointer to a list of additional instance extensions to require. */ +} SDL_GPUVulkanOptions; /** * Destroys a GPU context previously returned by SDL_CreateGPUDevice. @@ -2250,6 +2444,116 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetGPUDeviceDriver(SDL_GPUDevice *d */ extern SDL_DECLSPEC SDL_GPUShaderFormat SDLCALL SDL_GetGPUShaderFormats(SDL_GPUDevice *device); +/** + * Get the properties associated with a GPU device. + * + * All properties are optional and may differ between GPU backends and SDL + * versions. + * + * The following properties are provided by SDL: + * + * `SDL_PROP_GPU_DEVICE_NAME_STRING`: Contains the name of the underlying + * device as reported by the system driver. This string has no standardized + * format, is highly inconsistent between hardware devices and drivers, and is + * able to change at any time. Do not attempt to parse this string as it is + * bound to fail at some point in the future when system drivers are updated, + * new hardware devices are introduced, or when SDL adds new GPU backends or + * modifies existing ones. + * + * Strings that have been found in the wild include: + * + * - GTX 970 + * - GeForce GTX 970 + * - NVIDIA GeForce GTX 970 + * - Microsoft Direct3D12 (NVIDIA GeForce GTX 970) + * - NVIDIA Graphics Device + * - GeForce GPU + * - P106-100 + * - AMD 15D8:C9 + * - AMD Custom GPU 0405 + * - AMD Radeon (TM) Graphics + * - ASUS Radeon RX 470 Series + * - Intel(R) Arc(tm) A380 Graphics (DG2) + * - Virtio-GPU Venus (NVIDIA TITAN V) + * - SwiftShader Device (LLVM 16.0.0) + * - llvmpipe (LLVM 15.0.4, 256 bits) + * - Microsoft Basic Render Driver + * - unknown device + * + * The above list shows that the same device can have different formats, the + * vendor name may or may not appear in the string, the included vendor name + * may not be the vendor of the chipset on the device, some manufacturers + * include pseudo-legal marks while others don't, some devices may not use a + * marketing name in the string, the device string may be wrapped by the name + * of a translation interface, the device may be emulated in software, or the + * string may contain generic text that does not identify the device at all. + * + * `SDL_PROP_GPU_DEVICE_DRIVER_NAME_STRING`: Contains the self-reported name + * of the underlying system driver. + * + * Strings that have been found in the wild include: + * + * - Intel Corporation + * - Intel open-source Mesa driver + * - Qualcomm Technologies Inc. Adreno Vulkan Driver + * - MoltenVK + * - Mali-G715 + * - venus + * + * `SDL_PROP_GPU_DEVICE_DRIVER_VERSION_STRING`: Contains the self-reported + * version of the underlying system driver. This is a relatively short version + * string in an unspecified format. If SDL_PROP_GPU_DEVICE_DRIVER_INFO_STRING + * is available then that property should be preferred over this one as it may + * contain additional information that is useful for identifying the exact + * driver version used. + * + * Strings that have been found in the wild include: + * + * - 53.0.0 + * - 0.405.2463 + * - 32.0.15.6614 + * + * `SDL_PROP_GPU_DEVICE_DRIVER_INFO_STRING`: Contains the detailed version + * information of the underlying system driver as reported by the driver. This + * is an arbitrary string with no standardized format and it may contain + * newlines. This property should be preferred over + * SDL_PROP_GPU_DEVICE_DRIVER_VERSION_STRING if it is available as it usually + * contains the same information but in a format that is easier to read. + * + * Strings that have been found in the wild include: + * + * - 101.6559 + * - 1.2.11 + * - Mesa 21.2.2 (LLVM 12.0.1) + * - Mesa 22.2.0-devel (git-f226222 2022-04-14 impish-oibaf-ppa) + * - v1.r53p0-00eac0.824c4f31403fb1fbf8ee1042422c2129 + * + * This string has also been observed to be a multiline string (which has a + * trailing newline): + * + * ``` + * Driver Build: 85da404, I46ff5fc46f, 1606794520 + * Date: 11/30/20 + * Compiler Version: EV031.31.04.01 + * Driver Branch: promo490_3_Google + * ``` + * + * \param device a GPU context to query. + * \returns a valid property ID on success or 0 on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGPUDeviceProperties(SDL_GPUDevice *device); + +#define SDL_PROP_GPU_DEVICE_NAME_STRING "SDL.gpu.device.name" +#define SDL_PROP_GPU_DEVICE_DRIVER_NAME_STRING "SDL.gpu.device.driver_name" +#define SDL_PROP_GPU_DEVICE_DRIVER_VERSION_STRING "SDL.gpu.device.driver_version" +#define SDL_PROP_GPU_DEVICE_DRIVER_INFO_STRING "SDL.gpu.device.driver_info" + + /* State Creation */ /** @@ -2440,7 +2744,8 @@ extern SDL_DECLSPEC SDL_GPUShader * SDLCALL SDL_CreateGPUShader( * Creates a texture object to be used in graphics or compute workflows. * * The contents of this texture are undefined until data is written to the - * texture. + * texture, either via SDL_UploadToGPUTexture or by performing a render or + * compute pass with this texture as a target. * * Note that certain combinations of usage flags are invalid. For example, a * texture cannot have both the SAMPLER and GRAPHICS_STORAGE_READ flags. @@ -2482,6 +2787,8 @@ extern SDL_DECLSPEC SDL_GPUShader * SDLCALL SDL_CreateGPUShader( * * \sa SDL_UploadToGPUTexture * \sa SDL_DownloadFromGPUTexture + * \sa SDL_BeginGPURenderPass + * \sa SDL_BeginGPUComputePass * \sa SDL_BindGPUVertexSamplers * \sa SDL_BindGPUVertexStorageTextures * \sa SDL_BindGPUFragmentSamplers @@ -2638,6 +2945,12 @@ extern SDL_DECLSPEC void SDLCALL SDL_SetGPUTextureName( * * Useful for debugging. * + * On Direct3D 12, using SDL_InsertGPUDebugLabel requires + * WinPixEventRuntime.dll to be in your PATH or in the same directory as your + * executable. See + * [here](https://devblogs.microsoft.com/pix/winpixeventruntime/) + * for instructions on how to obtain it. + * * \param command_buffer a command buffer. * \param text a UTF-8 string constant to insert as the label. * @@ -2648,7 +2961,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_InsertGPUDebugLabel( const char *text); /** - * Begins a debug group with an arbitary name. + * Begins a debug group with an arbitrary name. * * Used for denoting groups of calls when viewing the command buffer * callstream in a graphics debugging tool. @@ -2656,6 +2969,11 @@ extern SDL_DECLSPEC void SDLCALL SDL_InsertGPUDebugLabel( * Each call to SDL_PushGPUDebugGroup must have a corresponding call to * SDL_PopGPUDebugGroup. * + * On Direct3D 12, using SDL_PushGPUDebugGroup requires WinPixEventRuntime.dll + * to be in your PATH or in the same directory as your executable. See + * [here](https://devblogs.microsoft.com/pix/winpixeventruntime/) + * for instructions on how to obtain it. + * * On some backends (e.g. Metal), pushing a debug group during a * render/blit/compute pass will create a group that is scoped to the native * pass rather than the command buffer. For best results, if you push a debug @@ -2675,6 +2993,11 @@ extern SDL_DECLSPEC void SDLCALL SDL_PushGPUDebugGroup( /** * Ends the most-recently pushed debug group. * + * On Direct3D 12, using SDL_PopGPUDebugGroup requires WinPixEventRuntime.dll + * to be in your PATH or in the same directory as your executable. See + * [here](https://devblogs.microsoft.com/pix/winpixeventruntime/) + * for instructions on how to obtain it. + * * \param command_buffer a command buffer. * * \since This function is available since SDL 3.2.0. @@ -2816,12 +3139,15 @@ extern SDL_DECLSPEC SDL_GPUCommandBuffer * SDLCALL SDL_AcquireGPUCommandBuffer( /** * Pushes data to a vertex uniform slot on the command buffer. * - * Subsequent draw calls will use this uniform data. + * Subsequent draw calls in this command buffer will use this uniform data. * * The data being pushed must respect std140 layout conventions. In practical * terms this means you must ensure that vec3 and vec4 fields are 16-byte * aligned. * + * For detailed information about accessing uniform data from a shader, please + * refer to SDL_CreateGPUShader. + * * \param command_buffer a command buffer. * \param slot_index the vertex uniform slot to push data to. * \param data client data to write. @@ -2838,7 +3164,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_PushGPUVertexUniformData( /** * Pushes data to a fragment uniform slot on the command buffer. * - * Subsequent draw calls will use this uniform data. + * Subsequent draw calls in this command buffer will use this uniform data. * * The data being pushed must respect std140 layout conventions. In practical * terms this means you must ensure that vec3 and vec4 fields are 16-byte @@ -2860,7 +3186,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_PushGPUFragmentUniformData( /** * Pushes data to a uniform slot on the command buffer. * - * Subsequent draw calls will use this uniform data. + * Subsequent draw calls in this command buffer will use this uniform data. * * The data being pushed must respect std140 layout conventions. In practical * terms this means you must ensure that vec3 and vec4 fields are 16-byte @@ -2892,6 +3218,14 @@ extern SDL_DECLSPEC void SDLCALL SDL_PushGPUComputeUniformData( * is called. You cannot begin another render pass, or begin a compute pass or * copy pass until you have ended the render pass. * + * Using SDL_GPU_LOADOP_LOAD before any contents have been written to the + * texture subresource will result in undefined behavior. SDL_GPU_LOADOP_CLEAR + * will set the contents of the texture subresource to a single value before + * any rendering is performed. It's fine to do an empty render pass using + * SDL_GPU_STOREOP_STORE to clear a texture, but in general it's better to + * think of clearing not as an independent operation but as something that's + * done as the beginning of a render pass. + * * \param command_buffer a command buffer. * \param color_target_infos an array of texture subresources with * corresponding clear values and load/store ops. @@ -3338,7 +3672,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputePipeline( * The textures must have been created with SDL_GPU_TEXTUREUSAGE_SAMPLER. * * Be sure your shader is set up according to the requirements documented in - * SDL_CreateGPUShader(). + * SDL_CreateGPUComputePipeline(). * * \param compute_pass a compute pass handle. * \param first_slot the compute sampler slot to begin binding from. @@ -3349,7 +3683,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputePipeline( * * \since This function is available since SDL 3.2.0. * - * \sa SDL_CreateGPUShader + * \sa SDL_CreateGPUComputePipeline */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeSamplers( SDL_GPUComputePass *compute_pass, @@ -3364,7 +3698,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeSamplers( * SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ. * * Be sure your shader is set up according to the requirements documented in - * SDL_CreateGPUShader(). + * SDL_CreateGPUComputePipeline(). * * \param compute_pass a compute pass handle. * \param first_slot the compute storage texture slot to begin binding from. @@ -3373,7 +3707,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeSamplers( * * \since This function is available since SDL 3.2.0. * - * \sa SDL_CreateGPUShader + * \sa SDL_CreateGPUComputePipeline */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageTextures( SDL_GPUComputePass *compute_pass, @@ -3388,7 +3722,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageTextures( * SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ. * * Be sure your shader is set up according to the requirements documented in - * SDL_CreateGPUShader(). + * SDL_CreateGPUComputePipeline(). * * \param compute_pass a compute pass handle. * \param first_slot the compute storage buffer slot to begin binding from. @@ -3397,7 +3731,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageTextures( * * \since This function is available since SDL 3.2.0. * - * \sa SDL_CreateGPUShader + * \sa SDL_CreateGPUComputePipeline */ extern SDL_DECLSPEC void SDLCALL SDL_BindGPUComputeStorageBuffers( SDL_GPUComputePass *compute_pass, @@ -3514,6 +3848,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_UnmapGPUTransferBuffer( * \returns a copy pass handle. * * \since This function is available since SDL 3.2.0. + * + * \sa SDL_EndGPUCopyPass */ extern SDL_DECLSPEC SDL_GPUCopyPass * SDLCALL SDL_BeginGPUCopyPass( SDL_GPUCommandBuffer *command_buffer); @@ -3567,6 +3903,10 @@ extern SDL_DECLSPEC void SDLCALL SDL_UploadToGPUBuffer( * This copy occurs on the GPU timeline. You may assume the copy has finished * in subsequent commands. * + * This function does not support copying between depth and color textures. + * For those, copy the texture to a buffer and then to the destination + * texture. + * * \param copy_pass a copy pass handle. * \param source a source texture region. * \param destination a destination texture region. @@ -3775,7 +4115,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseWindowFromGPUDevice( * supported via SDL_WindowSupportsGPUPresentMode / * SDL_WindowSupportsGPUSwapchainComposition prior to calling this function. * - * SDL_GPU_PRESENTMODE_VSYNC with SDL_GPU_SWAPCHAINCOMPOSITION_SDR are always + * SDL_GPU_PRESENTMODE_VSYNC with SDL_GPU_SWAPCHAINCOMPOSITION_SDR is always * supported. * * \param device a GPU context. @@ -3849,7 +4189,9 @@ extern SDL_DECLSPEC SDL_GPUTextureFormat SDLCALL SDL_GetGPUSwapchainTextureForma * buffer used to acquire it. * * This function will fill the swapchain texture handle with NULL if too many - * frames are in flight. This is not an error. + * frames are in flight. This is not an error. This NULL pointer should not be + * passed back into SDL. Instead, it should be considered as an indication to + * wait until the swapchain is available. * * If you use this function, it is possible to create a situation where many * command buffers are allocated while the rendering context waits for the GPU @@ -4171,6 +4513,29 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_CalculateGPUTextureFormatSize( Uint32 height, Uint32 depth_or_layer_count); +/** + * Get the SDL pixel format corresponding to a GPU texture format. + * + * \param format a texture format. + * \returns the corresponding pixel format, or SDL_PIXELFORMAT_UNKNOWN if + * there is no corresponding pixel format. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC SDL_PixelFormat SDLCALL SDL_GetPixelFormatFromGPUTextureFormat(SDL_GPUTextureFormat format); + +/** + * Get the GPU texture format corresponding to an SDL pixel format. + * + * \param format a pixel format. + * \returns the corresponding GPU texture format, or + * SDL_GPU_TEXTUREFORMAT_INVALID if there is no corresponding GPU + * texture format. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC SDL_GPUTextureFormat SDLCALL SDL_GetGPUTextureFormatFromPixelFormat(SDL_PixelFormat format); + #ifdef SDL_PLATFORM_GDK /** diff --git a/vendor/sdl3/include/SDL_haptic.h b/vendor/sdl3/include/SDL_haptic.h index a45335b28..9a20396d3 100644 --- a/vendor/sdl3/include/SDL_haptic.h +++ b/vendor/sdl3/include/SDL_haptic.h @@ -70,7 +70,7 @@ * { * SDL_Haptic *haptic; * SDL_HapticEffect effect; - * int effect_id; + * SDL_HapticEffectID effect_id; * * // Open the device * haptic = SDL_OpenHapticFromJoystick(joystick); @@ -149,6 +149,19 @@ extern "C" { */ typedef struct SDL_Haptic SDL_Haptic; +/* + * Misc defines. + */ + +/** + * Used to play a device an infinite number of times. + * + * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_RunHapticEffect + */ +#define SDL_HAPTIC_INFINITY 4294967295U + /** * \name Haptic features @@ -162,6 +175,11 @@ typedef struct SDL_Haptic SDL_Haptic; */ /* @{ */ +/** + * Type of haptic effect. + */ +typedef Uint16 SDL_HapticEffectType; + /** * Constant effect supported. * @@ -383,6 +401,11 @@ typedef struct SDL_Haptic SDL_Haptic; */ /* @{ */ +/** + * Type of coordinates used for haptic direction. + */ +typedef Uint8 SDL_HapticDirectionType; + /** * Uses polar coordinates for the direction. * @@ -426,18 +449,15 @@ typedef struct SDL_Haptic SDL_Haptic; /* @} *//* Haptic features */ -/* - * Misc defines. - */ /** - * Used to play a device an infinite number of times. + * ID for haptic effects. * - * \since This macro is available since SDL 3.2.0. + * This is -1 if the ID is invalid. * - * \sa SDL_RunHapticEffect + * \sa SDL_CreateHapticEffect */ -#define SDL_HAPTIC_INFINITY 4294967295U +typedef int SDL_HapticEffectID; /** @@ -545,8 +565,8 @@ typedef struct SDL_Haptic SDL_Haptic; */ typedef struct SDL_HapticDirection { - Uint8 type; /**< The type of encoding. */ - Sint32 dir[3]; /**< The encoded direction. */ + SDL_HapticDirectionType type; /**< The type of encoding. */ + Sint32 dir[3]; /**< The encoded direction. */ } SDL_HapticDirection; @@ -566,7 +586,7 @@ typedef struct SDL_HapticDirection typedef struct SDL_HapticConstant { /* Header */ - Uint16 type; /**< SDL_HAPTIC_CONSTANT */ + SDL_HapticEffectType type; /**< SDL_HAPTIC_CONSTANT */ SDL_HapticDirection direction; /**< Direction of the effect. */ /* Replay */ @@ -652,9 +672,9 @@ typedef struct SDL_HapticConstant typedef struct SDL_HapticPeriodic { /* Header */ - Uint16 type; /**< SDL_HAPTIC_SINE, SDL_HAPTIC_SQUARE - SDL_HAPTIC_TRIANGLE, SDL_HAPTIC_SAWTOOTHUP or - SDL_HAPTIC_SAWTOOTHDOWN */ + SDL_HapticEffectType type; /**< SDL_HAPTIC_SINE, SDL_HAPTIC_SQUARE + SDL_HAPTIC_TRIANGLE, SDL_HAPTIC_SAWTOOTHUP or + SDL_HAPTIC_SAWTOOTHDOWN */ SDL_HapticDirection direction; /**< Direction of the effect. */ /* Replay */ @@ -708,8 +728,8 @@ typedef struct SDL_HapticPeriodic typedef struct SDL_HapticCondition { /* Header */ - Uint16 type; /**< SDL_HAPTIC_SPRING, SDL_HAPTIC_DAMPER, - SDL_HAPTIC_INERTIA or SDL_HAPTIC_FRICTION */ + SDL_HapticEffectType type; /**< SDL_HAPTIC_SPRING, SDL_HAPTIC_DAMPER, + SDL_HAPTIC_INERTIA or SDL_HAPTIC_FRICTION */ SDL_HapticDirection direction; /**< Direction of the effect. */ /* Replay */ @@ -747,7 +767,7 @@ typedef struct SDL_HapticCondition typedef struct SDL_HapticRamp { /* Header */ - Uint16 type; /**< SDL_HAPTIC_RAMP */ + SDL_HapticEffectType type; /**< SDL_HAPTIC_RAMP */ SDL_HapticDirection direction; /**< Direction of the effect. */ /* Replay */ @@ -786,7 +806,7 @@ typedef struct SDL_HapticRamp typedef struct SDL_HapticLeftRight { /* Header */ - Uint16 type; /**< SDL_HAPTIC_LEFTRIGHT */ + SDL_HapticEffectType type; /**< SDL_HAPTIC_LEFTRIGHT */ /* Replay */ Uint32 length; /**< Duration of the effect in milliseconds. */ @@ -816,7 +836,7 @@ typedef struct SDL_HapticLeftRight typedef struct SDL_HapticCustom { /* Header */ - Uint16 type; /**< SDL_HAPTIC_CUSTOM */ + SDL_HapticEffectType type; /**< SDL_HAPTIC_CUSTOM */ SDL_HapticDirection direction; /**< Direction of the effect. */ /* Replay */ @@ -915,7 +935,7 @@ typedef struct SDL_HapticCustom typedef union SDL_HapticEffect { /* Common for all force feedback effects */ - Uint16 type; /**< Effect type. */ + SDL_HapticEffectType type; /**< Effect type. */ SDL_HapticConstant constant; /**< Constant effect. */ SDL_HapticPeriodic periodic; /**< Periodic effect. */ SDL_HapticCondition condition; /**< Condition effect. */ @@ -1193,7 +1213,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_HapticEffectSupported(SDL_Haptic *haptic, c * \sa SDL_RunHapticEffect * \sa SDL_UpdateHapticEffect */ -extern SDL_DECLSPEC int SDLCALL SDL_CreateHapticEffect(SDL_Haptic *haptic, const SDL_HapticEffect *effect); +extern SDL_DECLSPEC SDL_HapticEffectID SDLCALL SDL_CreateHapticEffect(SDL_Haptic *haptic, const SDL_HapticEffect *effect); /** * Update the properties of an effect. @@ -1215,7 +1235,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_CreateHapticEffect(SDL_Haptic *haptic, const * \sa SDL_CreateHapticEffect * \sa SDL_RunHapticEffect */ -extern SDL_DECLSPEC bool SDLCALL SDL_UpdateHapticEffect(SDL_Haptic *haptic, int effect, const SDL_HapticEffect *data); +extern SDL_DECLSPEC bool SDLCALL SDL_UpdateHapticEffect(SDL_Haptic *haptic, SDL_HapticEffectID effect, const SDL_HapticEffect *data); /** * Run the haptic effect on its associated haptic device. @@ -1239,7 +1259,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_UpdateHapticEffect(SDL_Haptic *haptic, int * \sa SDL_StopHapticEffect * \sa SDL_StopHapticEffects */ -extern SDL_DECLSPEC bool SDLCALL SDL_RunHapticEffect(SDL_Haptic *haptic, int effect, Uint32 iterations); +extern SDL_DECLSPEC bool SDLCALL SDL_RunHapticEffect(SDL_Haptic *haptic, SDL_HapticEffectID effect, Uint32 iterations); /** * Stop the haptic effect on its associated haptic device. @@ -1254,7 +1274,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RunHapticEffect(SDL_Haptic *haptic, int eff * \sa SDL_RunHapticEffect * \sa SDL_StopHapticEffects */ -extern SDL_DECLSPEC bool SDLCALL SDL_StopHapticEffect(SDL_Haptic *haptic, int effect); +extern SDL_DECLSPEC bool SDLCALL SDL_StopHapticEffect(SDL_Haptic *haptic, SDL_HapticEffectID effect); /** * Destroy a haptic effect on the device. @@ -1269,7 +1289,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_StopHapticEffect(SDL_Haptic *haptic, int ef * * \sa SDL_CreateHapticEffect */ -extern SDL_DECLSPEC void SDLCALL SDL_DestroyHapticEffect(SDL_Haptic *haptic, int effect); +extern SDL_DECLSPEC void SDLCALL SDL_DestroyHapticEffect(SDL_Haptic *haptic, SDL_HapticEffectID effect); /** * Get the status of the current effect on the specified haptic device. @@ -1285,7 +1305,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_DestroyHapticEffect(SDL_Haptic *haptic, int * * \sa SDL_GetHapticFeatures */ -extern SDL_DECLSPEC bool SDLCALL SDL_GetHapticEffectStatus(SDL_Haptic *haptic, int effect); +extern SDL_DECLSPEC bool SDLCALL SDL_GetHapticEffectStatus(SDL_Haptic *haptic, SDL_HapticEffectID effect); /** * Set the global gain of the specified haptic device. diff --git a/vendor/sdl3/include/SDL_hidapi.h b/vendor/sdl3/include/SDL_hidapi.h index 131b03723..67e29c2a1 100644 --- a/vendor/sdl3/include/SDL_hidapi.h +++ b/vendor/sdl3/include/SDL_hidapi.h @@ -55,6 +55,7 @@ #include #include +#include #include /* Set up for C function definitions, even when using C++ */ @@ -283,6 +284,24 @@ extern SDL_DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open(unsigned short vendor_ */ extern SDL_DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open_path(const char *path); +/** + * Get the properties associated with an SDL_hid_device. + * + * The following read-only properties are provided by SDL: + * + * - `SDL_PROP_HIDAPI_LIBUSB_DEVICE_HANDLE_POINTER`: the libusb_device_handle + * associated with the device, if it was opened using libusb. + * + * \param dev a device handle returned from SDL_hid_open(). + * \returns a valid property ID on success or 0 on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_hid_get_properties(SDL_hid_device *dev); + +#define SDL_PROP_HIDAPI_LIBUSB_DEVICE_HANDLE_POINTER "SDL.hidapi.libusb.device.handle" + /** * Write an Output report to a HID device. * diff --git a/vendor/sdl3/include/SDL_hints.h b/vendor/sdl3/include/SDL_hints.h index a08153571..474e97f04 100644 --- a/vendor/sdl3/include/SDL_hints.h +++ b/vendor/sdl3/include/SDL_hints.h @@ -391,12 +391,46 @@ extern "C" { * concept, so it applies to a physical audio device in this case, and not an * SDL_AudioStream, nor an SDL logical audio device. * + * For Windows WASAPI audio, the following roles are supported, and map to + * `AUDIO_STREAM_CATEGORY`: + * + * - "Other" (default) + * - "Communications" - Real-time communications, such as VOIP or chat + * - "Game" - Game audio + * - "GameChat" - Game chat audio, similar to "Communications" except that + * this will not attenuate other audio streams + * - "Movie" - Music or sound with dialog + * - "Media" - Music or sound without dialog + * + * If your application applies its own echo cancellation, gain control, and + * noise reduction it should also set SDL_HINT_AUDIO_DEVICE_RAW_STREAM. + * * This hint should be set before an audio device is opened. * * \since This hint is available since SDL 3.2.0. */ #define SDL_HINT_AUDIO_DEVICE_STREAM_ROLE "SDL_AUDIO_DEVICE_STREAM_ROLE" +/** + * Specify whether this audio device should do audio processing. + * + * Some operating systems perform echo cancellation, gain control, and noise + * reduction as needed. If your application already handles these, you can set + * this hint to prevent the OS from doing additional audio processing. + * + * This corresponds to the WASAPI audio option `AUDCLNT_STREAMOPTIONS_RAW`. + * + * The variable can be set to the following values: + * + * - "0": audio processing can be done by the OS. (default) + * - "1": audio processing is done by the application. + * + * This hint should be set before an audio device is opened. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_AUDIO_DEVICE_RAW_STREAM "SDL_AUDIO_DEVICE_RAW_STREAM" + /** * Specify the input file when recording audio using the disk audio driver. * @@ -595,7 +629,7 @@ extern "C" { * A variable that limits what CPU features are available. * * By default, SDL marks all features the current CPU supports as available. - * This hint allows to limit these to a subset. + * This hint allows the enabled features to be limited to a subset. * * When the hint is unset, or empty, SDL will enable all detected CPU * features. @@ -685,6 +719,21 @@ extern "C" { */ #define SDL_HINT_DISPLAY_USABLE_BOUNDS "SDL_DISPLAY_USABLE_BOUNDS" +/** + * Set the level of checking for invalid parameters passed to SDL functions. + * + * The variable can be set to the following values: + * + * - "1": Enable fast parameter error checking, e.g. quick NULL checks, etc. + * - "2": Enable full parameter error checking, e.g. validating objects are + * the correct type, etc. (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_INVALID_PARAM_CHECKS "SDL_INVALID_PARAM_CHECKS" + /** * Disable giving back control to the browser automatically when running with * asyncify. @@ -711,8 +760,6 @@ extern "C" { * * This hint only applies to the emscripten platform. * - * The default value is "#canvas" - * * This hint should be set before creating a window. * * \since This hint is available since SDL 3.2.0. @@ -726,7 +773,7 @@ extern "C" { * * The variable can be one of: * - * - "#window": the javascript window object (default) + * - "#window": the javascript window object * - "#document": the javascript document object * - "#screen": the javascript window.screen object * - "#canvas": the WebGL canvas element @@ -1037,6 +1084,21 @@ extern "C" { */ #define SDL_HINT_HIDAPI_LIBUSB "SDL_HIDAPI_LIBUSB" + +/** + * A variable to control whether HIDAPI uses libusb for GameCube adapters. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI will not use libusb for GameCube adapters. + * - "1": HIDAPI will use libusb for GameCube adapters if available. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.0. + */ +#define SDL_HINT_HIDAPI_LIBUSB_GAMECUBE "SDL_HIDAPI_LIBUSB_GAMECUBE" + /** * A variable to control whether HIDAPI uses libusb only for whitelisted * devices. @@ -1143,8 +1205,8 @@ extern "C" { #define SDL_HINT_IME_IMPLEMENTED_UI "SDL_IME_IMPLEMENTED_UI" /** - * A variable controlling whether the home indicator bar on iPhone X should be - * hidden. + * A variable controlling whether the home indicator bar on iPhone X and later + * should be hidden. * * The variable can be set to the following values: * @@ -1723,6 +1785,69 @@ extern "C" { */ #define SDL_HINT_JOYSTICK_HIDAPI_STEAM_HORI "SDL_JOYSTICK_HIDAPI_STEAM_HORI" +/** + * A variable controlling whether the HIDAPI driver for some Logitech wheels + * should be used. + * + * This variable can be set to the following values: + * + * - "0": HIDAPI driver is not used + * - "1": HIDAPI driver is used + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI + */ +#define SDL_HINT_JOYSTICK_HIDAPI_LG4FF "SDL_JOYSTICK_HIDAPI_LG4FF" + +/** + * A variable controlling whether the HIDAPI driver for 8BitDo controllers + * should be used. + * + * This variable can be set to the following values: + * + * "0" - HIDAPI driver is not used. "1" - HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI + */ +#define SDL_HINT_JOYSTICK_HIDAPI_8BITDO "SDL_JOYSTICK_HIDAPI_8BITDO" + +/** + * A variable controlling whether the HIDAPI driver for SInput controllers + * should be used. + * + * More info - https://github.com/HandHeldLegend/SInput-HID + * + * This variable can be set to the following values: + * + * "0" - HIDAPI driver is not used. "1" - HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI + */ +#define SDL_HINT_JOYSTICK_HIDAPI_SINPUT "SDL_JOYSTICK_HIDAPI_SINPUT" + +/** + * A variable controlling whether the HIDAPI driver for ZUIKI controllers + * should be used. + * + * This variable can be set to the following values: + * + * "0" - HIDAPI driver is not used. "1" - HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI + */ +#define SDL_HINT_JOYSTICK_HIDAPI_ZUIKI "SDL_JOYSTICK_HIDAPI_ZUIKI" + +/** + * A variable controlling whether the HIDAPI driver for Flydigi controllers + * should be used. + * + * This variable can be set to the following values: + * + * "0" - HIDAPI driver is not used. "1" - HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI + */ +#define SDL_HINT_JOYSTICK_HIDAPI_FLYDIGI "SDL_JOYSTICK_HIDAPI_FLYDIGI" + /** * A variable controlling whether the HIDAPI driver for Nintendo Switch * controllers should be used. @@ -1774,6 +1899,23 @@ extern "C" { */ #define SDL_HINT_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED "SDL_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED" +/** + * A variable controlling whether the HIDAPI driver for Nintendo Switch 2 + * controllers should be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. + * - "1": HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI. + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_SWITCH2 "SDL_JOYSTICK_HIDAPI_SWITCH2" + /** * A variable controlling whether Nintendo Switch Joy-Con controllers will be * in vertical mode when using the HIDAPI driver. @@ -1926,6 +2068,41 @@ extern "C" { */ #define SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED "SDL_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED" +/** + * A variable controlling whether the new HIDAPI driver for wired Xbox One + * (GIP) controllers should be used. + * + * The variable can be set to the following values: + * + * - "0": HIDAPI driver is not used. + * - "1": HIDAPI driver is used. + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE. + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_GIP "SDL_JOYSTICK_HIDAPI_GIP" + +/** + * A variable controlling whether the new HIDAPI driver for wired Xbox One + * (GIP) controllers should reset the controller if it can't get the metadata + * from the controller. + * + * The variable can be set to the following values: + * + * - "0": Assume this is a generic controller. + * - "1": Reset the controller to get metadata. + * + * By default the controller is not reset. + * + * This hint should be set before initializing joysticks and gamepads. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_GIP_RESET_FOR_METADATA "SDL_JOYSTICK_HIDAPI_GIP_RESET_FOR_METADATA" + /** * A variable controlling whether IOKit should be used for controller * handling. @@ -2126,8 +2303,8 @@ extern "C" { * * The variable can be set to the following values: * - * - "0": WGI is not used. - * - "1": WGI is used. (default) + * - "0": WGI is not used. (default) + * - "1": WGI is used. * * This hint should be set before SDL is initialized. * @@ -2228,9 +2405,9 @@ extern "C" { * pressing the 1 key would yield the keycode SDLK_1, or '1', instead of * SDLK_AMPERSAND, or '&' * - "latin_letters": For keyboards using non-Latin letters, such as Russian - * or Thai, the letter keys generate keycodes as though it had an en_US - * layout. e.g. pressing the key associated with SDL_SCANCODE_A on a Russian - * keyboard would yield 'a' instead of a Cyrillic letter. + * or Thai, the letter keys generate keycodes as though it had an English + * QWERTY layout. e.g. pressing the key associated with SDL_SCANCODE_A on a + * Russian keyboard would yield 'a' instead of a Cyrillic letter. * * The default value for this hint is "french_numbers,latin_letters" * @@ -2289,6 +2466,27 @@ extern "C" { */ #define SDL_HINT_KMSDRM_REQUIRE_DRM_MASTER "SDL_KMSDRM_REQUIRE_DRM_MASTER" +/** + * A variable that controls whether KMSDRM will use "atomic" functionality. + * + * The KMSDRM backend can use atomic commits, if both DRM_CLIENT_CAP_ATOMIC + * and DRM_CLIENT_CAP_UNIVERSAL_PLANES is supported by the system. As of SDL + * 3.4.0, it will favor this functionality, but in case this doesn't work well + * on a given system or other surprises, this hint can be used to disable it. + * + * This hint can not enable the functionality if it isn't available. + * + * The variable can be set to the following values: + * + * - "0": SDL will not use the KMSDRM "atomic" functionality. + * - "1": SDL will allow usage of the KMSDRM "atomic" functionality. (default) + * + * This hint should be set before SDL is initialized. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_KMSDRM_ATOMIC "SDL_KMSDRM_ATOMIC" + /** * A variable controlling the default SDL log levels. * @@ -2309,6 +2507,11 @@ extern "C" { * * `app=info,assert=warn,test=verbose,*=error` * + * If the `DEBUG_INVOCATION` environment variable is set to "1", the default + * log levels are equivalent to: + * + * `assert=warn,test=verbose,*=debug` + * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. @@ -2410,6 +2613,21 @@ extern "C" { */ #define SDL_HINT_MAC_SCROLL_MOMENTUM "SDL_MAC_SCROLL_MOMENTUM" +/** + * A variable controlling whether holding down a key will repeat the pressed + * key or open the accents menu on macOS. + * + * The variable can be set to the following values: + * + * - "0": Holding a key will open the accents menu for that key. + * - "1": Holding a key will repeat the pressed key. (default) + * + * This hint needs to be set before SDL_Init(). + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_MAC_PRESS_AND_HOLD "SDL_MAC_PRESS_AND_HOLD" + /** * Request SDL_AppIterate() be called at a specific rate. * @@ -2430,6 +2648,10 @@ extern "C" { * This defaults to 0, and specifying NULL for the hint's value will restore * the default. * + * This doesn't have to be an integer value. For example, "59.94" won't be + * rounded to an integer rate; the digits after the decimal are actually + * respected. + * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. @@ -2485,6 +2707,24 @@ extern "C" { */ #define SDL_HINT_MOUSE_DEFAULT_SYSTEM_CURSOR "SDL_MOUSE_DEFAULT_SYSTEM_CURSOR" +/** + * A variable setting whether we should scale cursors by the current display + * scale. + * + * The variable can be set to the following values: + * + * - "0": Cursors will not change size based on the display content scale. + * (default) + * - "1": Cursors will automatically match the display content scale (e.g. a + * 2x sized cursor will be used when the window is on a monitor with 200% + * scale). This is currently implemented on Windows and Wayland. + * + * This hint needs to be set before creating cursors. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_MOUSE_DPI_SCALE_CURSORS "SDL_MOUSE_DPI_SCALE_CURSORS" + /** * A variable controlling whether warping a hidden mouse cursor will activate * relative mouse mode. @@ -2493,7 +2733,7 @@ extern "C" { * the window center occur within a short time period, SDL will emulate mouse * warps using relative mouse mode. This can provide smoother and more * reliable mouse motion for some older games, which continuously calculate - * the distance travelled by the mouse pointer and warp it back to the center + * the distance traveled by the mouse pointer and warp it back to the center * of the window, rather than using relative mouse motion. * * Note that relative mouse mode may have different mouse acceleration @@ -2859,6 +3099,24 @@ extern "C" { */ #define SDL_HINT_RENDER_DIRECT3D11_DEBUG "SDL_RENDER_DIRECT3D11_DEBUG" +/** + * A variable controlling whether to use the Direct3D 11 WARP software + * rasterizer. + * + * For more information, see: + * https://learn.microsoft.com/en-us/windows/win32/direct3darticles/directx-warp + * + * The variable can be set to the following values: + * + * - "0": Disable WARP rasterizer. (default) + * - "1": Enable WARP rasterizer. + * + * This hint should be set before creating a renderer. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_RENDER_DIRECT3D11_WARP "SDL_RENDER_DIRECT3D11_WARP" + /** * A variable controlling whether to enable Vulkan Validation Layers. * @@ -3041,6 +3299,37 @@ extern "C" { */ #define SDL_HINT_ROG_GAMEPAD_MICE_EXCLUDED "SDL_ROG_GAMEPAD_MICE_EXCLUDED" +/** + * Variable controlling the width of the PS2's framebuffer in pixels + * + * By default, this variable is "640" + */ +#define SDL_HINT_PS2_GS_WIDTH "SDL_PS2_GS_WIDTH" + +/** + * Variable controlling the height of the PS2's framebuffer in pixels + * + * By default, this variable is "448" + */ +#define SDL_HINT_PS2_GS_HEIGHT "SDL_PS2_GS_HEIGHT" + +/** + * Variable controlling whether the signal is interlaced or progressive + * + * - "0": Image is interlaced. (default) + * - "1": Image is progressive + */ +#define SDL_HINT_PS2_GS_PROGRESSIVE "SDL_PS2_GS_PROGRESSIVE" + +/** + * Variable controlling the video mode of the console + * + * - "": Console-native. (default) + * - "NTSC": 60hz region + * - "PAL": 50hz region + */ +#define SDL_HINT_PS2_GS_MODE "SDL_PS2_GS_MODE" + /** * A variable controlling which Dispmanx layer to use on a Raspberry PI. * @@ -3267,10 +3556,12 @@ extern "C" { * prioritized in the list of displays, as exposed by calling * SDL_GetDisplays(), with the first listed becoming the primary display. The * naming convention can vary depending on the environment, but it is usually - * a connector name (e.g. 'DP-1', 'DP-2', 'HDMI-A-1',etc...). + * a connector name (e.g. 'DP-1', 'DP-2', 'HDMI-A-1', etc...). * - * On Wayland and X11 desktops, the connector names associated with displays - * can typically be found by using the `xrandr` utility. + * On Wayland desktops, the connector names associated with displays can be + * found in the `name` property of the info output from `wayland-info -i + * wl_output`. On X11 desktops, the `xrandr` utility can be used to retrieve + * the connector names associated with displays. * * This hint is currently supported on the following drivers: * @@ -3407,6 +3698,43 @@ extern "C" { */ #define SDL_HINT_VIDEO_MAC_FULLSCREEN_MENU_VISIBILITY "SDL_VIDEO_MAC_FULLSCREEN_MENU_VISIBILITY" +/** + * A variable indicating whether the metal layer drawable size should be + * updated for the SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event on macOS. + * + * The variable can be set to the following values: + * + * - "0": the metal layer drawable size will not be updated on the + * SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event. + * - "1": the metal layer drawable size will be updated on the + * SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event. (default) + * + * This hint should be set before SDL_Metal_CreateView called. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_VIDEO_METAL_AUTO_RESIZE_DRAWABLE "SDL_VIDEO_METAL_AUTO_RESIZE_DRAWABLE" + +/** + * A variable controlling whether SDL will attempt to automatically set the + * destination display to a mode most closely matching that of the previous + * display if an exclusive fullscreen window is moved onto it. + * + * The variable can be set to the following values: + * + * - "0": SDL will not attempt to automatically set a matching mode on the + * destination display. If an exclusive fullscreen window is moved to a new + * display, the window will become fullscreen desktop. + * - "1": SDL will attempt to automatically set a mode on the destination + * display that most closely matches the mode of the display that the + * exclusive fullscreen window was previously on. (default) + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_VIDEO_MATCH_EXCLUSIVE_MODE_ON_MOVE "SDL_VIDEO_MATCH_EXCLUSIVE_MODE_ON_MOVE" + /** * A variable controlling whether fullscreen windows are minimized when they * lose focus. @@ -3414,8 +3742,10 @@ extern "C" { * The variable can be set to the following values: * * - "0": Fullscreen windows will not be minimized when they lose focus. - * (default) * - "1": Fullscreen windows are minimized when they lose focus. + * - "auto": Fullscreen windows are minimized when they lose focus if they use + * exclusive fullscreen modes, so the desktop video mode is restored. + * (default) * * This hint can be set anytime. * @@ -4061,15 +4391,14 @@ extern "C" { * * The variable can be set to the following values: * - * - "0": GameInput is not used for raw keyboard and mouse events. + * - "0": GameInput is not used for raw keyboard and mouse events. (default) * - "1": GameInput is used for raw keyboard and mouse events, if available. - * (default) * * This hint should be set before SDL is initialized. * * \since This hint is available since SDL 3.2.0. */ -#define SDL_HINT_WINDOWS_GAMEINPUT "SDL_WINDOWS_GAMEINPUT" +#define SDL_HINT_WINDOWS_GAMEINPUT "SDL_WINDOWS_GAMEINPUT" /** * A variable controlling whether raw keyboard events are used on Windows. @@ -4085,6 +4414,28 @@ extern "C" { */ #define SDL_HINT_WINDOWS_RAW_KEYBOARD "SDL_WINDOWS_RAW_KEYBOARD" +/** + * A variable controlling whether or not the RIDEV_NOHOTKEYS flag is set when + * enabling Windows raw keyboard events. + * + * This blocks any hotkeys that have been registered by applications from + * having any effect beyond generating raw WM_INPUT events. + * + * This flag does not affect system-hotkeys like ALT-TAB or CTRL-ALT-DEL, but + * does affect the Windows Logo key since it is a userland hotkey registered + * by explorer.exe. + * + * The variable can be set to the following values: + * + * - "0": Hotkeys are not excluded. (default) + * - "1": Hotkeys are excluded. + * + * This hint can be set anytime. + * + * \since This hint is available since SDL 3.4.0. + */ +#define SDL_HINT_WINDOWS_RAW_KEYBOARD_EXCLUDE_HOTKEYS "SDL_WINDOWS_RAW_KEYBOARD_EXCLUDE_HOTKEYS" + /** * A variable controlling whether SDL uses Kernel Semaphores on Windows. * @@ -4114,7 +4465,7 @@ extern "C" { * * \since This hint is available since SDL 3.2.0. */ -#define SDL_HINT_WINDOWS_INTRESOURCE_ICON "SDL_WINDOWS_INTRESOURCE_ICON" +#define SDL_HINT_WINDOWS_INTRESOURCE_ICON "SDL_WINDOWS_INTRESOURCE_ICON" /** * A variable to specify custom icon resource id from RC file on Windows @@ -4287,7 +4638,6 @@ extern "C" { */ #define SDL_HINT_PEN_TOUCH_EVENTS "SDL_PEN_TOUCH_EVENTS" - /** * An enumeration of hint priorities. * @@ -4386,19 +4736,14 @@ extern SDL_DECLSPEC void SDLCALL SDL_ResetHints(void); * \param name the hint to query. * \returns the string value of a hint or NULL if the hint isn't set. * - * \threadsafety It is safe to call this function from any thread, however the - * return value only remains valid until the hint is changed; if - * another thread might do so, the app should supply locks - * and/or make a copy of the string. Note that using a hint - * callback instead is always thread-safe, as SDL holds a lock - * on the thread subsystem during the callback. + * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetHint * \sa SDL_SetHintWithPriority */ -extern SDL_DECLSPEC const char * SDLCALL SDL_GetHint(const char *name); +extern SDL_DECLSPEC const char *SDLCALL SDL_GetHint(const char *name); /** * Get the boolean value of a hint variable. @@ -4474,8 +4819,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_AddHintCallback(const char *name, SDL_HintC * \sa SDL_AddHintCallback */ extern SDL_DECLSPEC void SDLCALL SDL_RemoveHintCallback(const char *name, - SDL_HintCallback callback, - void *userdata); + SDL_HintCallback callback, + void *userdata); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/vendor/sdl3/include/SDL_init.h b/vendor/sdl3/include/SDL_init.h index 27ebe4b0e..557f2b995 100644 --- a/vendor/sdl3/include/SDL_init.h +++ b/vendor/sdl3/include/SDL_init.h @@ -101,7 +101,7 @@ typedef Uint32 SDL_InitFlags; * to run. * * See - * [Main callbacks in SDL3](https://wiki.libsdl.org/SDL3/README/main-functions#main-callbacks-in-sdl3) + * [Main callbacks in SDL3](https://wiki.libsdl.org/SDL3/README-main-functions#main-callbacks-in-sdl3) * for complete details. * * \since This enum is available since SDL 3.2.0. diff --git a/vendor/sdl3/include/SDL_intrin.h b/vendor/sdl3/include/SDL_intrin.h index bac6d7ad4..802c1953b 100644 --- a/vendor/sdl3/include/SDL_intrin.h +++ b/vendor/sdl3/include/SDL_intrin.h @@ -268,6 +268,7 @@ _m_prefetch(void *__P) #endif /* compiler version */ #ifdef SDL_WIKI_DOCUMENTATION_SECTION + /** * A macro to decide if the compiler supports `__attribute__((target))`. * @@ -280,12 +281,14 @@ _m_prefetch(void *__P) * \sa SDL_TARGETING */ #define SDL_HAS_TARGET_ATTRIBS - +#elif defined(__loongarch64) && defined(__GNUC__) && (__GNUC__ >= 15) +/* LoongArch requires GCC 15+ for target attribute support */ +# define SDL_HAS_TARGET_ATTRIBS #elif defined(__clang__) && defined(__has_attribute) # if __has_attribute(target) # define SDL_HAS_TARGET_ATTRIBS # endif -#elif defined(__GNUC__) && (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) /* gcc >= 4.9 */ +#elif defined(__GNUC__) && !defined(__loongarch64) && (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) /* gcc >= 4.9 */ # define SDL_HAS_TARGET_ATTRIBS #elif defined(__ICC) && __ICC >= 1600 # define SDL_HAS_TARGET_ATTRIBS diff --git a/vendor/sdl3/include/SDL_iostream.h b/vendor/sdl3/include/SDL_iostream.h index 4ca16093e..dfe6f6a9c 100644 --- a/vendor/sdl3/include/SDL_iostream.h +++ b/vendor/sdl3/include/SDL_iostream.h @@ -111,7 +111,7 @@ typedef struct SDL_IOStreamInterface /** * Read up to `size` bytes from the data stream to the area pointed - * at by `ptr`. + * at by `ptr`. `size` will always be > 0. * * On an incomplete read, you should set `*status` to a value from the * SDL_IOStatus enum. You do not have to explicitly set this on @@ -123,7 +123,7 @@ typedef struct SDL_IOStreamInterface /** * Write exactly `size` bytes from the area pointed at by `ptr` - * to data stream. + * to data stream. `size` will always be > 0. * * On an incomplete write, you should set `*status` to a value from the * SDL_IOStatus enum. You do not have to explicitly set this on @@ -203,6 +203,8 @@ typedef struct SDL_IOStream SDL_IOStream; * - "w": Create an empty file for writing. If a file with the same name * already exists its content is erased and the file is treated as a new * empty file. + * - "wx": Create an empty file for writing. If a file with the same name + * already exists, the call fails. * - "a": Append to a file. Writing operations append data at the end of the * file. The file is created if it does not exist. * - "r+": Open a file for update both reading and writing. The file must @@ -210,6 +212,8 @@ typedef struct SDL_IOStream SDL_IOStream; * - "w+": Create an empty file for both reading and writing. If a file with * the same name already exists its content is erased and the file is * treated as a new empty file. + * - "w+x": Create an empty file for both reading and writing. If a file with + * the same name already exists, the call fails. * - "a+": Open a file for reading and appending. All writing operations are * performed at the end of the file, protecting the previous content to be * overwritten. You can reposition (fseek, rewind) the internal pointer to @@ -260,7 +264,7 @@ typedef struct SDL_IOStream SDL_IOStream; * \returns a pointer to the SDL_IOStream structure that is created or NULL on * failure; call SDL_GetError() for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * @@ -286,8 +290,7 @@ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromFile(const char *file, cons * certain size, for both read and write access. * * This memory buffer is not copied by the SDL_IOStream; the pointer you - * provide must remain valid until you close the stream. Closing the stream - * will not free the original buffer. + * provide must remain valid until you close the stream. * * If you need to make sure the SDL_IOStream never writes to the memory * buffer, you should use SDL_IOFromConstMem() with a read-only buffer of @@ -300,6 +303,13 @@ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromFile(const char *file, cons * - `SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER`: this will be the `size` parameter * that was passed to this function. * + * Additionally, the following properties are recognized: + * + * - `SDL_PROP_IOSTREAM_MEMORY_FREE_FUNC_POINTER`: if this property is set to + * a non-NULL value it will be interpreted as a function of SDL_free_func + * type and called with the passed `mem` pointer when closing the stream. By + * default it is unset, i.e., the memory will not be freed. + * * \param mem a pointer to a buffer to feed an SDL_IOStream stream. * \param size the buffer size, in bytes. * \returns a pointer to a new SDL_IOStream structure or NULL on failure; call @@ -321,6 +331,7 @@ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromMem(void *mem, size_t size) #define SDL_PROP_IOSTREAM_MEMORY_POINTER "SDL.iostream.memory.base" #define SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER "SDL.iostream.memory.size" +#define SDL_PROP_IOSTREAM_MEMORY_FREE_FUNC_POINTER "SDL.iostream.memory.free" /** * Use this function to prepare a read-only memory buffer for use with @@ -333,8 +344,7 @@ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromMem(void *mem, size_t size) * without writing to the memory buffer. * * This memory buffer is not copied by the SDL_IOStream; the pointer you - * provide must remain valid until you close the stream. Closing the stream - * will not free the original buffer. + * provide must remain valid until you close the stream. * * If you need to write to a memory buffer, you should use SDL_IOFromMem() * with a writable buffer of memory instead. @@ -346,6 +356,13 @@ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_IOFromMem(void *mem, size_t size) * - `SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER`: this will be the `size` parameter * that was passed to this function. * + * Additionally, the following properties are recognized: + * + * - `SDL_PROP_IOSTREAM_MEMORY_FREE_FUNC_POINTER`: if this property is set to + * a non-NULL value it will be interpreted as a function of SDL_free_func + * type and called with the passed `mem` pointer when closing the stream. By + * default it is unset, i.e., the memory will not be freed. + * * \param mem a pointer to a read-only buffer to feed an SDL_IOStream stream. * \param size the buffer size, in bytes. * \returns a pointer to a new SDL_IOStream structure or NULL on failure; call @@ -452,7 +469,7 @@ extern SDL_DECLSPEC SDL_IOStream * SDLCALL SDL_OpenIO(const SDL_IOStreamInterfac * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. * @@ -467,7 +484,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_CloseIO(SDL_IOStream *context); * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -487,7 +504,7 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetIOProperties(SDL_IOStream *c * \param context the SDL_IOStream to query. * \returns an SDL_IOStatus enum with the current state. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -501,7 +518,7 @@ extern SDL_DECLSPEC SDL_IOStatus SDLCALL SDL_GetIOStatus(SDL_IOStream *context); * negative error code on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -528,7 +545,7 @@ extern SDL_DECLSPEC Sint64 SDLCALL SDL_GetIOSize(SDL_IOStream *context); * \returns the final offset in the data stream after the seek or -1 on * failure; call SDL_GetError() for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. * @@ -548,7 +565,7 @@ extern SDL_DECLSPEC Sint64 SDLCALL SDL_SeekIO(SDL_IOStream *context, Sint64 offs * \returns the current offset in the stream, or -1 if the information can not * be determined. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. * @@ -567,13 +584,17 @@ extern SDL_DECLSPEC Sint64 SDLCALL SDL_TellIO(SDL_IOStream *context); * the stream is not at EOF, SDL_GetIOStatus() will return a different error * value and SDL_GetError() will offer a human-readable message. * + * A request for zero bytes on a valid stream will return zero immediately + * without accessing the stream, so the stream status (EOF, err, etc) will not + * change. + * * \param context a pointer to an SDL_IOStream structure. * \param ptr a pointer to a buffer to read data into. * \param size the number of bytes to read from the data source. * \returns the number of bytes read, or 0 on end of file or other failure; * call SDL_GetError() for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. * @@ -596,13 +617,17 @@ extern SDL_DECLSPEC size_t SDLCALL SDL_ReadIO(SDL_IOStream *context, void *ptr, * recoverable, such as a non-blocking write that can simply be retried later, * or a fatal error. * + * A request for zero bytes on a valid stream will return zero immediately + * without accessing the stream, so the stream status (EOF, err, etc) will not + * change. + * * \param context a pointer to an SDL_IOStream structure. * \param ptr a pointer to a buffer containing data to write. * \param size the number of bytes to write. * \returns the number of bytes written, which will be less than `size` on * failure; call SDL_GetError() for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. * @@ -626,7 +651,7 @@ extern SDL_DECLSPEC size_t SDLCALL SDL_WriteIO(SDL_IOStream *context, const void * \returns the number of bytes written or 0 on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. * @@ -646,7 +671,7 @@ extern SDL_DECLSPEC size_t SDLCALL SDL_IOprintf(SDL_IOStream *context, SDL_PRINT * \returns the number of bytes written or 0 on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. * @@ -666,7 +691,7 @@ extern SDL_DECLSPEC size_t SDLCALL SDL_IOvprintf(SDL_IOStream *context, SDL_PRIN * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. * @@ -692,7 +717,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_FlushIO(SDL_IOStream *context); * \returns the data or NULL on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. * @@ -715,7 +740,7 @@ extern SDL_DECLSPEC void * SDLCALL SDL_LoadFile_IO(SDL_IOStream *src, size_t *da * \returns the data or NULL on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * @@ -736,7 +761,7 @@ extern SDL_DECLSPEC void * SDLCALL SDL_LoadFile(const char *file, size_t *datasi * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. * @@ -755,7 +780,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SaveFile_IO(SDL_IOStream *src, const void * * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * @@ -784,7 +809,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SaveFile(const char *file, const void *data * \returns true on success or false on failure or EOF; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -803,7 +828,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU8(SDL_IOStream *src, Uint8 *value); * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -823,10 +848,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS8(SDL_IOStream *src, Sint8 *value); * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. - * \returns true on successful write or false on failure; call SDL_GetError() + * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -846,10 +871,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU16LE(SDL_IOStream *src, Uint16 *value) * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. - * \returns true on successful write or false on failure; call SDL_GetError() + * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -869,10 +894,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS16LE(SDL_IOStream *src, Sint16 *value) * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. - * \returns true on successful write or false on failure; call SDL_GetError() + * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -892,10 +917,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU16BE(SDL_IOStream *src, Uint16 *value) * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. - * \returns true on successful write or false on failure; call SDL_GetError() + * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -915,10 +940,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS16BE(SDL_IOStream *src, Sint16 *value) * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. - * \returns true on successful write or false on failure; call SDL_GetError() + * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -938,10 +963,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU32LE(SDL_IOStream *src, Uint32 *value) * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. - * \returns true on successful write or false on failure; call SDL_GetError() + * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -961,10 +986,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS32LE(SDL_IOStream *src, Sint32 *value) * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. - * \returns true on successful write or false on failure; call SDL_GetError() + * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -984,10 +1009,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU32BE(SDL_IOStream *src, Uint32 *value) * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. - * \returns true on successful write or false on failure; call SDL_GetError() + * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -1007,10 +1032,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS32BE(SDL_IOStream *src, Sint32 *value) * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. - * \returns true on successful write or false on failure; call SDL_GetError() + * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -1030,10 +1055,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU64LE(SDL_IOStream *src, Uint64 *value) * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. - * \returns true on successful write or false on failure; call SDL_GetError() + * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -1053,10 +1078,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS64LE(SDL_IOStream *src, Sint64 *value) * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. - * \returns true on successful write or false on failure; call SDL_GetError() + * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -1076,10 +1101,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU64BE(SDL_IOStream *src, Uint64 *value) * * \param src the stream from which to read data. * \param value a pointer filled in with the data read. - * \returns true on successful write or false on failure; call SDL_GetError() + * \returns true on successful read or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -1101,7 +1126,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS64BE(SDL_IOStream *src, Sint64 *value) * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -1115,7 +1140,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU8(SDL_IOStream *dst, Uint8 value); * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -1134,7 +1159,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteS8(SDL_IOStream *dst, Sint8 value); * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -1153,7 +1178,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU16LE(SDL_IOStream *dst, Uint16 value) * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -1171,7 +1196,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteS16LE(SDL_IOStream *dst, Sint16 value) * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -1189,7 +1214,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU16BE(SDL_IOStream *dst, Uint16 value) * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -1208,7 +1233,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteS16BE(SDL_IOStream *dst, Sint16 value) * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -1227,7 +1252,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU32LE(SDL_IOStream *dst, Uint32 value) * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -1245,7 +1270,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteS32LE(SDL_IOStream *dst, Sint32 value) * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -1263,7 +1288,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU32BE(SDL_IOStream *dst, Uint32 value) * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -1282,7 +1307,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteS32BE(SDL_IOStream *dst, Sint32 value) * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -1301,7 +1326,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU64LE(SDL_IOStream *dst, Uint64 value) * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -1319,7 +1344,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteS64LE(SDL_IOStream *dst, Sint64 value) * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ @@ -1337,7 +1362,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteU64BE(SDL_IOStream *dst, Uint64 value) * \returns true on successful write or false on failure; call SDL_GetError() * for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety Do not use the same SDL_IOStream from two threads at once. * * \since This function is available since SDL 3.2.0. */ diff --git a/vendor/sdl3/include/SDL_joystick.h b/vendor/sdl3/include/SDL_joystick.h index d15668b66..af04f0979 100644 --- a/vendor/sdl3/include/SDL_joystick.h +++ b/vendor/sdl3/include/SDL_joystick.h @@ -29,8 +29,8 @@ * instead. * * The term "instance_id" is the current instantiation of a joystick device in - * the system, if the joystick is removed and then re-inserted then it will - * get a new instance_id, instance_id's are monotonically increasing + * the system. If the joystick is removed and then re-inserted then it will + * get a new instance_id. instance_id's are monotonically increasing * identifiers of a joystick plugged in. * * The term "player_index" is the number assigned to a player on a specific @@ -48,6 +48,14 @@ * If you would like to receive joystick updates while the application is in * the background, you should set the following hint before calling * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS + * + * SDL can provide virtual joysticks as well: the app defines an imaginary + * controller with SDL_AttachVirtualJoystick(), and then can provide inputs + * for it via SDL_SetJoystickVirtualAxis(), SDL_SetJoystickVirtualButton(), + * etc. As this data is supplied, it will look like a normal joystick to SDL, + * just not backed by a hardware driver. This has been used to make unusual + * devices, like VR headset controllers, look like normal joysticks, or + * provide recording/playback of game inputs, etc. */ #ifndef SDL_joystick_h_ @@ -107,6 +115,10 @@ typedef Uint32 SDL_JoystickID; * This is by no means a complete list of everything that can be plugged into * a computer. * + * You may refer to + * [XInput Controller Types](https://learn.microsoft.com/en-us/windows/win32/xinput/xinput-and-controller-subtypes) + * table for a general understanding of each joystick type. + * * \since This enum is available since SDL 3.2.0. */ typedef enum SDL_JoystickType @@ -170,6 +182,8 @@ typedef enum SDL_JoystickConnectionState * joysticks while processing to guarantee that the joystick list won't change * and joystick and gamepad events will not be delivered. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_LockJoysticks(void) SDL_ACQUIRE(SDL_joystick_lock); @@ -177,6 +191,9 @@ extern SDL_DECLSPEC void SDLCALL SDL_LockJoysticks(void) SDL_ACQUIRE(SDL_joystic /** * Unlocking for atomic access to the joystick API. * + * \threadsafety This should be called from the same thread that called + * SDL_LockJoysticks(). + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_UnlockJoysticks(void) SDL_RELEASE(SDL_joystick_lock); @@ -186,6 +203,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_UnlockJoysticks(void) SDL_RELEASE(SDL_joyst * * \returns true if a joystick is connected, false otherwise. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoysticks @@ -201,6 +220,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_HasJoystick(void); * call SDL_GetError() for more information. This should be freed * with SDL_free() when it is no longer needed. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_HasJoystick @@ -217,6 +238,8 @@ extern SDL_DECLSPEC SDL_JoystickID * SDLCALL SDL_GetJoysticks(int *count); * \returns the name of the selected joystick. If no name can be found, this * function returns NULL; call SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickName @@ -233,6 +256,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickNameForID(SDL_JoystickID * \returns the path of the selected joystick. If no path can be found, this * function returns NULL; call SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickPath @@ -248,6 +273,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickPathForID(SDL_JoystickID * \param instance_id the joystick instance ID. * \returns the player index of a joystick, or -1 if it's not available. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickPlayerIndex @@ -264,6 +291,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetJoystickPlayerIndexForID(SDL_JoystickID i * \returns the GUID of the selected joystick. If called with an invalid * instance_id, this function returns a zero GUID. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickGUID @@ -281,6 +310,8 @@ extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetJoystickGUIDForID(SDL_JoystickID ins * \returns the USB vendor ID of the selected joystick. If called with an * invalid instance_id, this function returns 0. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickVendor @@ -298,6 +329,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickVendorForID(SDL_JoystickID ins * \returns the USB product ID of the selected joystick. If called with an * invalid instance_id, this function returns 0. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickProduct @@ -315,6 +348,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickProductForID(SDL_JoystickID in * \returns the product version of the selected joystick. If called with an * invalid instance_id, this function returns 0. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickProductVersion @@ -332,6 +367,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickProductVersionForID(SDL_Joysti * invalid instance_id, this function returns * `SDL_JOYSTICK_TYPE_UNKNOWN`. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickType @@ -349,6 +386,8 @@ extern SDL_DECLSPEC SDL_JoystickType SDLCALL SDL_GetJoystickTypeForID(SDL_Joysti * \returns a joystick identifier or NULL on failure; call SDL_GetError() for * more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_CloseJoystick @@ -362,6 +401,8 @@ extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_OpenJoystick(SDL_JoystickID insta * \returns an SDL_Joystick on success or NULL on failure or if it hasn't been * opened yet; call SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetJoystickFromID(SDL_JoystickID instance_id); @@ -373,6 +414,8 @@ extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetJoystickFromID(SDL_JoystickID * \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError() * for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickPlayerIndex @@ -465,13 +508,33 @@ SDL_COMPILE_TIME_ASSERT(SDL_VirtualJoystickDesc_SIZE, /** * Attach a new virtual joystick. * + * Apps can create virtual joysticks, that exist without hardware directly + * backing them, and have program-supplied inputs. Once attached, a virtual + * joystick looks like any other joystick that SDL can access. These can be + * used to make other things look like joysticks, or provide pre-recorded + * input, etc. + * + * Once attached, the app can send joystick inputs to the new virtual joystick + * using SDL_SetJoystickVirtualAxis(), etc. + * + * When no longer needed, the virtual joystick can be removed by calling + * SDL_DetachVirtualJoystick(). + * * \param desc joystick description, initialized using SDL_INIT_INTERFACE(). * \returns the joystick instance ID, or 0 on failure; call SDL_GetError() for * more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_DetachVirtualJoystick + * \sa SDL_SetJoystickVirtualAxis + * \sa SDL_SetJoystickVirtualButton + * \sa SDL_SetJoystickVirtualBall + * \sa SDL_SetJoystickVirtualHat + * \sa SDL_SetJoystickVirtualTouchpad + * \sa SDL_SetJoystickVirtualSensorData */ extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_AttachVirtualJoystick(const SDL_VirtualJoystickDesc *desc); @@ -483,6 +546,8 @@ extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_AttachVirtualJoystick(const SDL_V * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_AttachVirtualJoystick @@ -495,6 +560,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_DetachVirtualJoystick(SDL_JoystickID instan * \param instance_id the joystick instance ID. * \returns true if the joystick is virtual, false otherwise. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_IsJoystickVirtual(SDL_JoystickID instance_id); @@ -518,7 +585,15 @@ extern SDL_DECLSPEC bool SDLCALL SDL_IsJoystickVirtual(SDL_JoystickID instance_i * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetJoystickVirtualButton + * \sa SDL_SetJoystickVirtualBall + * \sa SDL_SetJoystickVirtualHat + * \sa SDL_SetJoystickVirtualTouchpad + * \sa SDL_SetJoystickVirtualSensorData */ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value); @@ -538,7 +613,15 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualAxis(SDL_Joystick *joysti * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetJoystickVirtualAxis + * \sa SDL_SetJoystickVirtualButton + * \sa SDL_SetJoystickVirtualHat + * \sa SDL_SetJoystickVirtualTouchpad + * \sa SDL_SetJoystickVirtualSensorData */ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualBall(SDL_Joystick *joystick, int ball, Sint16 xrel, Sint16 yrel); @@ -557,7 +640,15 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualBall(SDL_Joystick *joysti * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetJoystickVirtualAxis + * \sa SDL_SetJoystickVirtualBall + * \sa SDL_SetJoystickVirtualHat + * \sa SDL_SetJoystickVirtualTouchpad + * \sa SDL_SetJoystickVirtualSensorData */ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualButton(SDL_Joystick *joystick, int button, bool down); @@ -576,7 +667,15 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualButton(SDL_Joystick *joys * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetJoystickVirtualAxis + * \sa SDL_SetJoystickVirtualButton + * \sa SDL_SetJoystickVirtualBall + * \sa SDL_SetJoystickVirtualTouchpad + * \sa SDL_SetJoystickVirtualSensorData */ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value); @@ -602,7 +701,15 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualHat(SDL_Joystick *joystic * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetJoystickVirtualAxis + * \sa SDL_SetJoystickVirtualButton + * \sa SDL_SetJoystickVirtualBall + * \sa SDL_SetJoystickVirtualHat + * \sa SDL_SetJoystickVirtualSensorData */ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualTouchpad(SDL_Joystick *joystick, int touchpad, int finger, bool down, float x, float y, float pressure); @@ -624,7 +731,15 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickVirtualTouchpad(SDL_Joystick *jo * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. + * + * \sa SDL_SetJoystickVirtualAxis + * \sa SDL_SetJoystickVirtualButton + * \sa SDL_SetJoystickVirtualBall + * \sa SDL_SetJoystickVirtualHat + * \sa SDL_SetJoystickVirtualTouchpad */ extern SDL_DECLSPEC bool SDLCALL SDL_SendJoystickVirtualSensorData(SDL_Joystick *joystick, SDL_SensorType type, Uint64 sensor_timestamp, const float *data, int num_values); @@ -648,6 +763,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SendJoystickVirtualSensorData(SDL_Joystick * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetJoystickProperties(SDL_Joystick *joystick); @@ -665,6 +782,8 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetJoystickProperties(SDL_Joyst * \returns the name of the selected joystick. If no name can be found, this * function returns NULL; call SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickNameForID @@ -678,6 +797,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickName(SDL_Joystick *joyst * \returns the path of the selected joystick. If no path can be found, this * function returns NULL; call SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickPathForID @@ -693,6 +814,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickPath(SDL_Joystick *joyst * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \returns the player index, or -1 if it's not available. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetJoystickPlayerIndex @@ -708,6 +831,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetJoystickPlayerIndex(SDL_Joystick *joystic * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickPlayerIndex @@ -724,6 +849,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickPlayerIndex(SDL_Joystick *joysti * this function returns a zero GUID; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickGUIDForID @@ -739,6 +866,8 @@ extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetJoystickGUID(SDL_Joystick *joystick) * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \returns the USB vendor ID of the selected joystick, or 0 if unavailable. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickVendorForID @@ -753,6 +882,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickVendor(SDL_Joystick *joystick) * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \returns the USB product ID of the selected joystick, or 0 if unavailable. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickProductForID @@ -767,6 +898,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickProduct(SDL_Joystick *joystick * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \returns the product version of the selected joystick, or 0 if unavailable. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickProductVersionForID @@ -782,6 +915,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickProductVersion(SDL_Joystick *j * \returns the firmware version of the selected joystick, or 0 if * unavailable. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickFirmwareVersion(SDL_Joystick *joystick); @@ -795,6 +930,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickFirmwareVersion(SDL_Joystick * * \returns the serial number of the selected joystick, or NULL if * unavailable. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickSerial(SDL_Joystick *joystick); @@ -805,6 +942,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickSerial(SDL_Joystick *joy * \param joystick the SDL_Joystick obtained from SDL_OpenJoystick(). * \returns the SDL_JoystickType of the selected joystick. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickTypeForID @@ -824,6 +963,8 @@ extern SDL_DECLSPEC SDL_JoystickType SDLCALL SDL_GetJoystickType(SDL_Joystick *j * \param crc16 a pointer filled in with a CRC used to distinguish different * products with the same VID/PID, or 0 if not available. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickGUIDForID @@ -837,6 +978,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_GetJoystickGUIDInfo(SDL_GUID guid, Uint16 * * \returns true if the joystick has been opened, false if it has not; call * SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_JoystickConnected(SDL_Joystick *joystick); @@ -848,6 +991,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_JoystickConnected(SDL_Joystick *joystick); * \returns the instance ID of the specified joystick on success or 0 on * failure; call SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetJoystickID(SDL_Joystick *joystick); @@ -863,6 +1008,8 @@ extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetJoystickID(SDL_Joystick *joyst * \returns the number of axis controls/number of axes on success or -1 on * failure; call SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickAxis @@ -884,6 +1031,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickAxes(SDL_Joystick *joystick); * \returns the number of trackballs on success or -1 on failure; call * SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickBall @@ -900,6 +1049,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickBalls(SDL_Joystick *joystick); * \returns the number of POV hats on success or -1 on failure; call * SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickHat @@ -916,6 +1067,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickHats(SDL_Joystick *joystick); * \returns the number of buttons on success or -1 on failure; call * SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetJoystickButton @@ -934,6 +1087,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumJoystickButtons(SDL_Joystick *joystick * * \param enabled whether to process joystick events or not. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_JoystickEventsEnabled @@ -950,6 +1105,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_SetJoystickEventsEnabled(bool enabled); * * \returns true if joystick events are being processed, false otherwise. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_SetJoystickEventsEnabled @@ -962,6 +1119,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_JoystickEventsEnabled(void); * This is called automatically by the event loop if any joystick events are * enabled. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC void SDLCALL SDL_UpdateJoysticks(void); @@ -984,6 +1143,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_UpdateJoysticks(void); * \returns a 16-bit signed integer representing the current position of the * axis or 0 on failure; call SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetNumJoystickAxes @@ -1002,6 +1163,8 @@ extern SDL_DECLSPEC Sint16 SDLCALL SDL_GetJoystickAxis(SDL_Joystick *joystick, i * \param state upon return, the initial value is supplied here. * \returns true if this axis has any initial value, or false if not. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_GetJoystickAxisInitialState(SDL_Joystick *joystick, int axis, Sint16 *state); @@ -1021,6 +1184,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetJoystickAxisInitialState(SDL_Joystick *j * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetNumJoystickBalls @@ -1036,6 +1201,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetJoystickBall(SDL_Joystick *joystick, int * \param hat the hat index to get the state from; indices start at index 0. * \returns the current hat position. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetNumJoystickHats @@ -1060,6 +1227,8 @@ extern SDL_DECLSPEC Uint8 SDLCALL SDL_GetJoystickHat(SDL_Joystick *joystick, int * index 0. * \returns true if the button is pressed, false otherwise. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_GetNumJoystickButtons @@ -1083,6 +1252,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetJoystickButton(SDL_Joystick *joystick, i * \param duration_ms the duration of the rumble effect, in milliseconds. * \returns true, or false if rumble isn't supported on this joystick. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_RumbleJoystick(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); @@ -1110,6 +1281,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RumbleJoystick(SDL_Joystick *joystick, Uint * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_RumbleJoystick @@ -1132,6 +1305,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RumbleJoystickTriggers(SDL_Joystick *joysti * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue); @@ -1145,6 +1320,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetJoystickLED(SDL_Joystick *joystick, Uint * \returns true on success or false on failure; call SDL_GetError() for more * information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_SendJoystickEffect(SDL_Joystick *joystick, const void *data, int size); @@ -1154,6 +1331,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SendJoystickEffect(SDL_Joystick *joystick, * * \param joystick the joystick device to close. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. * * \sa SDL_OpenJoystick @@ -1168,6 +1347,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_CloseJoystick(SDL_Joystick *joystick); * `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError() * for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetJoystickConnectionState(SDL_Joystick *joystick); @@ -1189,6 +1370,8 @@ extern SDL_DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetJoystickConnectio * \returns the current battery state or `SDL_POWERSTATE_ERROR` on failure; * call SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetJoystickPowerInfo(SDL_Joystick *joystick, int *percent); diff --git a/vendor/sdl3/include/SDL_keyboard.h b/vendor/sdl3/include/SDL_keyboard.h index afa77b6c2..eb984de58 100644 --- a/vendor/sdl3/include/SDL_keyboard.h +++ b/vendor/sdl3/include/SDL_keyboard.h @@ -174,8 +174,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_ResetKeyboard(void); /** * Get the current key modifier state for the keyboard. * - * \returns an OR'd combination of the modifier keys for the keyboard. See - * SDL_Keymod for details. + * \returns an OR'd combination of the modifier keys for the keyboard. * * \threadsafety It is safe to call this function from any thread. * diff --git a/vendor/sdl3/include/SDL_keycode.h b/vendor/sdl3/include/SDL_keycode.h index 61b68e794..c43660eef 100644 --- a/vendor/sdl3/include/SDL_keycode.h +++ b/vendor/sdl3/include/SDL_keycode.h @@ -45,12 +45,16 @@ * `SDLK_*` constant for those keys that do not generate characters. * * A special exception is the number keys at the top of the keyboard which map - * to SDLK_0...SDLK_9 on AZERTY layouts. + * by default to SDLK_0...SDLK_9 on AZERTY layouts. * * Keys with the `SDLK_EXTENDED_MASK` bit set do not map to a scancode or - * unicode code point. + * Unicode code point. + * + * Many common keycodes are listed below, but this list is not exhaustive. * * \since This datatype is available since SDL 3.2.0. + * + * \sa SDL_HINT_KEYCODE_OPTIONS */ typedef Uint32 SDL_Keycode; diff --git a/vendor/sdl3/include/SDL_log.h b/vendor/sdl3/include/SDL_log.h index 3fd7ec2ed..aceaabe77 100644 --- a/vendor/sdl3/include/SDL_log.h +++ b/vendor/sdl3/include/SDL_log.h @@ -206,6 +206,9 @@ extern SDL_DECLSPEC void SDLCALL SDL_ResetLogPriorities(void); * SDL_LOG_PRIORITY_WARN and higher have a prefix showing their priority, e.g. * "WARNING: ". * + * This function makes a copy of its string argument, **prefix**, so it is not + * necessary to keep the value of **prefix** alive after the call returns. + * * \param priority the SDL_LogPriority to modify. * \param prefix the prefix to use for that log priority, or NULL to use no * prefix. @@ -263,7 +266,6 @@ extern SDL_DECLSPEC void SDLCALL SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fm * \sa SDL_LogInfo * \sa SDL_LogMessage * \sa SDL_LogMessageV - * \sa SDL_LogTrace * \sa SDL_LogVerbose * \sa SDL_LogWarn */ diff --git a/vendor/sdl3/include/SDL_main.h b/vendor/sdl3/include/SDL_main.h index 905d78e96..ff497a4c3 100644 --- a/vendor/sdl3/include/SDL_main.h +++ b/vendor/sdl3/include/SDL_main.h @@ -47,7 +47,7 @@ * * For more information, see: * - * https://wiki.libsdl.org/SDL3/README/main-functions + * https://wiki.libsdl.org/SDL3/README-main-functions */ #ifndef SDL_main_h_ @@ -68,7 +68,7 @@ * proper entry point for the platform, and all the other magic details * needed, like manually calling SDL_SetMainReady. * - * Please see [README/main-functions](README/main-functions), (or + * Please see [README-main-functions](README-main-functions), (or * docs/README-main-functions.md in the source tree) for a more detailed * explanation. * @@ -85,7 +85,7 @@ * SDL_AppQuit. The app should not provide a `main` function in this case, and * doing so will likely cause the build to fail. * - * Please see [README/main-functions](README/main-functions), (or + * Please see [README-main-functions](README-main-functions), (or * docs/README-main-functions.md in the source tree) for a more detailed * explanation. * @@ -110,7 +110,8 @@ * Even if available, an app can define SDL_MAIN_HANDLED and provide their * own, if they know what they're doing. * - * This macro is used internally by SDL, and apps probably shouldn't rely on it. + * This macro is used internally by SDL, and apps probably shouldn't rely on + * it. * * \since This macro is available since SDL 3.2.0. */ @@ -125,10 +126,11 @@ * This macro is defined by `SDL_main.h`, which is not automatically included * by `SDL.h`. * - * Even if required, an app can define SDL_MAIN_HANDLED and provide their - * own, if they know what they're doing. + * Even if required, an app can define SDL_MAIN_HANDLED and provide their own, + * if they know what they're doing. * - * This macro is used internally by SDL, and apps probably shouldn't rely on it. + * This macro is used internally by SDL, and apps probably shouldn't rely on + * it. * * \since This macro is available since SDL 3.2.0. */ @@ -165,12 +167,10 @@ */ #define SDL_MAIN_NEEDED - #elif defined(SDL_PLATFORM_IOS) - /* On iOS SDL provides a main function that creates an application delegate - and starts the iOS application run loop. + #elif defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS) + /* On iOS and tvOS SDL provides a main function that creates an application delegate and starts the application run loop. - To use it, just #include SDL_main.h in the source file that contains your - main() function. + To use it, just #include in the source file that contains your main() function. See src/video/uikit/SDL_uikitappdelegate.m for more details. */ @@ -347,10 +347,10 @@ extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppInit(void **appstate, int a * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a * standard "main" function, you should not supply this. * - * This function is called repeatedly by SDL after SDL_AppInit returns 0. The - * function should operate as a single iteration the program's primary loop; - * it should update whatever state it needs and draw a new frame of video, - * usually. + * This function is called repeatedly by SDL after SDL_AppInit returns + * SDL_APP_CONTINUE. The function should operate as a single iteration the + * program's primary loop; it should update whatever state it needs and draw a + * new frame of video, usually. * * On some platforms, this function will be called at the refresh rate of the * display (which might change during the life of your app!). There are no @@ -449,8 +449,8 @@ extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppEvent(void *appstate, SDL_E * * This function is called once by SDL before terminating the program. * - * This function will be called no matter what, even if SDL_AppInit requests - * termination. + * This function will be called in all cases, even if SDL_AppInit requests + * termination at startup. * * This function should not go into an infinite mainloop; it should * deinitialize any resources necessary, perform whatever shutdown activities, @@ -512,7 +512,7 @@ typedef int (SDLCALL *SDL_main_func)(int argc, char *argv[]); * SDL_MAIN_USE_CALLBACKS. * * Program startup is a surprisingly complex topic. Please see - * [README/main-functions](README/main-functions), (or + * [README-main-functions](README-main-functions), (or * docs/README-main-functions.md in the source tree) for a more detailed * explanation. * @@ -553,6 +553,9 @@ extern SDL_DECLSPEC void SDLCALL SDL_SetMainReady(void); * using SDL_main (like when using SDL_MAIN_HANDLED). When using this, you do * *not* need SDL_SetMainReady(). * + * If `argv` is NULL, SDL will provide command line arguments, either by + * querying the OS for them if possible, or supplying a filler array if not. + * * \param argc the argc parameter from the application's main() function, or 0 * if the platform's main-equivalent has no argc. * \param argv the argv parameter from the application's main() function, or @@ -615,11 +618,12 @@ extern SDL_DECLSPEC int SDLCALL SDL_EnterAppMainCallbacks(int argc, char *argv[] * Most applications do not need to, and should not, call this directly; SDL * will call it when initializing the video subsystem. * + * If `name` is NULL, SDL currently uses `(CS_BYTEALIGNCLIENT | CS_OWNDC)` for + * the style, regardless of what is specified here. + * * \param name the window class name, in UTF-8 encoding. If NULL, SDL * currently uses "SDL_app" but this isn't guaranteed. - * \param style the value to use in WNDCLASSEX::style. If `name` is NULL, SDL - * currently uses `(CS_BYTEALIGNCLIENT | CS_OWNDC)` regardless of - * what is specified here. + * \param style the value to use in WNDCLASSEX::style. * \param hInst the HINSTANCE to use in WNDCLASSEX::hInstance. If zero, SDL * will use `GetModuleHandle(NULL)` instead. * \returns true on success or false on failure; call SDL_GetError() for more diff --git a/vendor/sdl3/include/SDL_mouse.h b/vendor/sdl3/include/SDL_mouse.h index 864135d2b..d502005a7 100644 --- a/vendor/sdl3/include/SDL_mouse.h +++ b/vendor/sdl3/include/SDL_mouse.h @@ -130,6 +130,17 @@ typedef enum SDL_MouseWheelDirection SDL_MOUSEWHEEL_FLIPPED /**< The scroll direction is flipped / natural */ } SDL_MouseWheelDirection; +/** + * Animated cursor frame info. + * + * \since This struct is available since SDL 3.4.0. + */ +typedef struct SDL_CursorFrameInfo +{ + SDL_Surface *surface; /**< The surface data for this frame */ + Uint32 duration; /**< The frame duration in milliseconds (a duration of 0 is infinite) */ +} SDL_CursorFrameInfo; + /** * A bitmask of pressed mouse buttons, as reported by SDL_GetMouseState, etc. * @@ -160,6 +171,44 @@ typedef Uint32 SDL_MouseButtonFlags; #define SDL_BUTTON_X1MASK SDL_BUTTON_MASK(SDL_BUTTON_X1) #define SDL_BUTTON_X2MASK SDL_BUTTON_MASK(SDL_BUTTON_X2) +/** + * A callback used to transform mouse motion delta from raw values. + * + * This is called during SDL's handling of platform mouse events to scale the + * values of the resulting motion delta. + * + * \param userdata what was passed as `userdata` to + * SDL_SetRelativeMouseTransform(). + * \param timestamp the associated time at which this mouse motion event was + * received. + * \param window the associated window to which this mouse motion event was + * addressed. + * \param mouseID the associated mouse from which this mouse motion event was + * emitted. + * \param x pointer to a variable that will be treated as the resulting x-axis + * motion. + * \param y pointer to a variable that will be treated as the resulting y-axis + * motion. + * + * \threadsafety This callback is called by SDL's internal mouse input + * processing procedure, which may be a thread separate from the + * main event loop that is run at realtime priority. Stalling + * this thread with too much work in the callback can therefore + * potentially freeze the entire system. Care should be taken + * with proper synchronization practices when adding other side + * effects beyond mutation of the x and y values. + * + * \since This datatype is available since SDL 3.4.0. + * + * \sa SDL_SetRelativeMouseTransform + */ +typedef void (SDLCALL *SDL_MouseMotionTransformCallback)( + void *userdata, + Uint64 timestamp, + SDL_Window *window, + SDL_MouseID mouseID, + float *x, float *y +); /* Function prototypes */ @@ -380,6 +429,24 @@ extern SDL_DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window *window, */ extern SDL_DECLSPEC bool SDLCALL SDL_WarpMouseGlobal(float x, float y); +/** + * Set a user-defined function by which to transform relative mouse inputs. + * + * This overrides the relative system scale and relative speed scale hints. + * Should be called prior to enabling relative mouse mode, fails otherwise. + * + * \param callback a callback used to transform relative mouse motion, or NULL + * for default behavior. + * \param userdata a pointer that will be passed to `callback`. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetRelativeMouseTransform(SDL_MouseMotionTransformCallback callback, void *userdata); + /** * Set relative mouse mode for a window. * @@ -509,6 +576,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_CaptureMouse(bool enabled); * * \since This function is available since SDL 3.2.0. * + * \sa SDL_CreateAnimatedCursor * \sa SDL_CreateColorCursor * \sa SDL_CreateSystemCursor * \sa SDL_DestroyCursor @@ -522,15 +590,17 @@ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor(const Uint8 *data, /** * Create a color cursor. * - * If this function is passed a surface with alternate representations, the - * surface will be interpreted as the content to be used for 100% display - * scale, and the alternate representations will be used for high DPI - * situations. For example, if the original surface is 32x32, then on a 2x - * macOS display or 200% display scale on Windows, a 64x64 version of the - * image will be used, if available. If a matching version of the image isn't - * available, the closest larger size image will be downscaled to the - * appropriate size and be used instead, if available. Otherwise, the closest - * smaller image will be upscaled and be used instead. + * If this function is passed a surface with alternate representations added + * with SDL_AddSurfaceAlternateImage(), the surface will be interpreted as the + * content to be used for 100% display scale, and the alternate + * representations will be used for high DPI situations if + * SDL_HINT_MOUSE_DPI_SCALE_CURSORS is enabled. For example, if the original + * surface is 32x32, then on a 2x macOS display or 200% display scale on + * Windows, a 64x64 version of the image will be used, if available. If a + * matching version of the image isn't available, the closest larger size + * image will be downscaled to the appropriate size and be used instead, if + * available. Otherwise, the closest smaller image will be upscaled and be + * used instead. * * \param surface an SDL_Surface structure representing the cursor image. * \param hot_x the x position of the cursor hot spot. @@ -542,6 +612,8 @@ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor(const Uint8 *data, * * \since This function is available since SDL 3.2.0. * + * \sa SDL_AddSurfaceAlternateImage + * \sa SDL_CreateAnimatedCursor * \sa SDL_CreateCursor * \sa SDL_CreateSystemCursor * \sa SDL_DestroyCursor @@ -551,6 +623,57 @@ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_CreateColorCursor(SDL_Surface *surf int hot_x, int hot_y); +/** + * Create an animated color cursor. + * + * Animated cursors are composed of a sequential array of frames, specified as + * surfaces and durations in an array of SDL_CursorFrameInfo structs. The hot + * spot coordinates are universal to all frames, and all frames must have the + * same dimensions. + * + * Frame durations are specified in milliseconds. A duration of 0 implies an + * infinite frame time, and the animation will stop on that frame. To create a + * one-shot animation, set the duration of the last frame in the sequence to + * 0. + * + * If this function is passed surfaces with alternate representations added + * with SDL_AddSurfaceAlternateImage(), the surfaces will be interpreted as + * the content to be used for 100% display scale, and the alternate + * representations will be used for high DPI situations. For example, if the + * original surfaces are 32x32, then on a 2x macOS display or 200% display + * scale on Windows, a 64x64 version of the image will be used, if available. + * If a matching version of the image isn't available, the closest larger size + * image will be downscaled to the appropriate size and be used instead, if + * available. Otherwise, the closest smaller image will be upscaled and be + * used instead. + * + * If the underlying platform does not support animated cursors, this function + * will fall back to creating a static color cursor using the first frame in + * the sequence. + * + * \param frames an array of cursor images composing the animation. + * \param frame_count the number of frames in the sequence. + * \param hot_x the x position of the cursor hot spot. + * \param hot_y the y position of the cursor hot spot. + * \returns the new cursor on success or NULL on failure; call SDL_GetError() + * for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_AddSurfaceAlternateImage + * \sa SDL_CreateCursor + * \sa SDL_CreateColorCursor + * \sa SDL_CreateSystemCursor + * \sa SDL_DestroyCursor + * \sa SDL_SetCursor + */ +extern SDL_DECLSPEC SDL_Cursor *SDLCALL SDL_CreateAnimatedCursor(SDL_CursorFrameInfo *frames, + int frame_count, + int hot_x, + int hot_y); + /** * Create a system cursor. * @@ -608,7 +731,7 @@ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_GetCursor(void); * You do not have to call SDL_DestroyCursor() on the return value, but it is * safe to do so. * - * \returns the default cursor on success or NULL on failuree; call + * \returns the default cursor on success or NULL on failure; call * SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. @@ -629,6 +752,7 @@ extern SDL_DECLSPEC SDL_Cursor * SDLCALL SDL_GetDefaultCursor(void); * * \since This function is available since SDL 3.2.0. * + * \sa SDL_CreateAnimatedCursor * \sa SDL_CreateColorCursor * \sa SDL_CreateCursor * \sa SDL_CreateSystemCursor diff --git a/vendor/sdl3/include/SDL_mutex.h b/vendor/sdl3/include/SDL_mutex.h index c88ec1531..024ce0b37 100644 --- a/vendor/sdl3/include/SDL_mutex.h +++ b/vendor/sdl3/include/SDL_mutex.h @@ -360,7 +360,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_LockMutex(SDL_Mutex *mutex) SDL_ACQUIRE(mut * \sa SDL_LockMutex * \sa SDL_UnlockMutex */ -extern SDL_DECLSPEC bool SDLCALL SDL_TryLockMutex(SDL_Mutex *mutex) SDL_TRY_ACQUIRE(0, mutex); +extern SDL_DECLSPEC bool SDLCALL SDL_TryLockMutex(SDL_Mutex *mutex) SDL_TRY_ACQUIRE(true, mutex); /** * Unlock the mutex. @@ -559,7 +559,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_LockRWLockForWriting(SDL_RWLock *rwlock) SD * \sa SDL_TryLockRWLockForWriting * \sa SDL_UnlockRWLock */ -extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForReading(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE_SHARED(0, rwlock); +extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForReading(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE_SHARED(true, rwlock); /** * Try to lock a read/write lock _for writing_ without blocking. @@ -589,7 +589,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForReading(SDL_RWLock *rwlock) * \sa SDL_TryLockRWLockForReading * \sa SDL_UnlockRWLock */ -extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForWriting(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE(0, rwlock); +extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForWriting(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE(true, rwlock); /** * Unlock the read/write lock. @@ -942,7 +942,7 @@ typedef enum SDL_InitStatus * Here is an example of using this: * * ```c - * static SDL_AtomicInitState init; + * static SDL_InitState init; * * bool InitSystem(void) * { diff --git a/vendor/sdl3/include/SDL_pen.h b/vendor/sdl3/include/SDL_pen.h index 5182eeb0c..97c22e506 100644 --- a/vendor/sdl3/include/SDL_pen.h +++ b/vendor/sdl3/include/SDL_pen.h @@ -28,12 +28,37 @@ * handling, e.g., for input and drawing tablets or suitably equipped mobile / * tablet devices. * - * To get started with pens, simply handle SDL_EVENT_PEN_* events. When a pen - * starts providing input, SDL will assign it a unique SDL_PenID, which will - * remain for the life of the process, as long as the pen stays connected. + * To get started with pens, simply handle pen events: + * + * - SDL_EVENT_PEN_PROXIMITY_IN, SDL_EVENT_PEN_PROXIMITY_OUT + * (SDL_PenProximityEvent) + * - SDL_EVENT_PEN_DOWN, SDL_EVENT_PEN_UP (SDL_PenTouchEvent) + * - SDL_EVENT_PEN_MOTION (SDL_PenMotionEvent) + * - SDL_EVENT_PEN_BUTTON_DOWN, SDL_EVENT_PEN_BUTTON_UP (SDL_PenButtonEvent) + * - SDL_EVENT_PEN_AXIS (SDL_PenAxisEvent) * * Pens may provide more than simple touch input; they might have other axes, * such as pressure, tilt, rotation, etc. + * + * When a pen starts providing input, SDL will assign it a unique SDL_PenID, + * which will remain for the life of the process, as long as the pen stays + * connected. A pen leaving proximity (being taken far enough away from the + * digitizer tablet that it no longer reponds) and then coming back should + * fire proximity events, but the SDL_PenID should remain consistent. + * Unplugging the digitizer and reconnecting may cause future input to have a + * new SDL_PenID, as SDL may not know that this is the same hardware. + * + * Please note that various platforms vary wildly in how (and how well) they + * support pen input. If your pen supports some piece of functionality but SDL + * doesn't seem to, it might actually be the operating system's fault. For + * example, some platforms can manage multiple devices at the same time, but + * others will make any connected pens look like a single logical device, much + * how all USB mice connected to a computer will move the same system cursor. + * cursor. Other platforms might not support pen buttons, or the distance + * axis, etc. Very few platforms can even report _what_ functionality the pen + * supports in the first place, so best practices is to either build UI to let + * the user configure their pens, or be prepared to handle new functionality + * for a pen the first time an event is reported. */ #ifndef SDL_pen_h_ @@ -43,6 +68,7 @@ #include #include +#include /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { @@ -55,7 +81,12 @@ extern "C" { * * These show up in pen events when SDL sees input from them. They remain * consistent as long as SDL can recognize a tool to be the same pen; but if a - * pen physically leaves the area and returns, it might get a new ID. + * pen's digitizer table is physically detached from the computer, it might + * get a new ID when reconnected, as SDL won't know it's the same device. + * + * These IDs are only stable within a single run of a program; the next time a + * program is run, the pen's ID will likely be different, even if the hardware + * hasn't been disconnected, etc. * * \since This datatype is available since SDL 3.2.0. */ @@ -75,7 +106,6 @@ typedef Uint32 SDL_PenID; */ #define SDL_PEN_TOUCHID ((SDL_TouchID)-2) - /** * Pen input flags, as reported by various pen events' `pen_state` field. * @@ -83,13 +113,14 @@ typedef Uint32 SDL_PenID; */ typedef Uint32 SDL_PenInputFlags; -#define SDL_PEN_INPUT_DOWN (1u << 0) /**< pen is pressed down */ -#define SDL_PEN_INPUT_BUTTON_1 (1u << 1) /**< button 1 is pressed */ -#define SDL_PEN_INPUT_BUTTON_2 (1u << 2) /**< button 2 is pressed */ -#define SDL_PEN_INPUT_BUTTON_3 (1u << 3) /**< button 3 is pressed */ -#define SDL_PEN_INPUT_BUTTON_4 (1u << 4) /**< button 4 is pressed */ -#define SDL_PEN_INPUT_BUTTON_5 (1u << 5) /**< button 5 is pressed */ -#define SDL_PEN_INPUT_ERASER_TIP (1u << 30) /**< eraser tip is used */ +#define SDL_PEN_INPUT_DOWN (1u << 0) /**< pen is pressed down */ +#define SDL_PEN_INPUT_BUTTON_1 (1u << 1) /**< button 1 is pressed */ +#define SDL_PEN_INPUT_BUTTON_2 (1u << 2) /**< button 2 is pressed */ +#define SDL_PEN_INPUT_BUTTON_3 (1u << 3) /**< button 3 is pressed */ +#define SDL_PEN_INPUT_BUTTON_4 (1u << 4) /**< button 4 is pressed */ +#define SDL_PEN_INPUT_BUTTON_5 (1u << 5) /**< button 5 is pressed */ +#define SDL_PEN_INPUT_ERASER_TIP (1u << 30) /**< eraser tip is used */ +#define SDL_PEN_INPUT_IN_PROXIMITY (1u << 31) /**< pen is in proximity (since SDL 3.4.0) */ /** * Pen axis indices. @@ -118,10 +149,50 @@ typedef enum SDL_PenAxis SDL_PEN_AXIS_COUNT /**< Total known pen axis types in this version of SDL. This number may grow in future releases! */ } SDL_PenAxis; +/** + * An enum that describes the type of a pen device. + * + * A "direct" device is a pen that touches a graphic display (like an Apple + * Pencil on an iPad's screen). "Indirect" devices touch an external tablet + * surface that is connected to the machine but is not a display (like a + * lower-end Wacom tablet connected over USB). + * + * Apps may use this information to decide if they should draw a cursor; if + * the pen is touching the screen directly, a cursor doesn't make sense and + * can be in the way, but becomes necessary for indirect devices to know where + * on the display they are interacting. + * + * \since This enum is available since SDL 3.4.0. + */ +typedef enum SDL_PenDeviceType +{ + SDL_PEN_DEVICE_TYPE_INVALID = -1, /**< Not a valid pen device. */ + SDL_PEN_DEVICE_TYPE_UNKNOWN, /**< Don't know specifics of this pen. */ + SDL_PEN_DEVICE_TYPE_DIRECT, /**< Pen touches display. */ + SDL_PEN_DEVICE_TYPE_INDIRECT /**< Pen touches something that isn't the display. */ +} SDL_PenDeviceType; + +/** + * Get the device type of the given pen. + * + * Many platforms do not supply this information, so an app must always be + * prepared to get an SDL_PEN_DEVICE_TYPE_UNKNOWN result. + * + * \param instance_id the pen instance ID. + * \returns the device type of the given pen, or SDL_PEN_DEVICE_TYPE_INVALID + * on failure; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC SDL_PenDeviceType SDLCALL SDL_GetPenDeviceType(SDL_PenID instance_id); + /* Ends C function definitions when using C++ */ #ifdef __cplusplus } #endif +#include #endif /* SDL_pen_h_ */ diff --git a/vendor/sdl3/include/SDL_pixels.h b/vendor/sdl3/include/SDL_pixels.h index 39596c1c9..54ef954ed 100644 --- a/vendor/sdl3/include/SDL_pixels.h +++ b/vendor/sdl3/include/SDL_pixels.h @@ -451,7 +451,7 @@ typedef enum SDL_PackedLayout * expressions with side-effects here. * * \param format an SDL_PixelFormat to check. - * \returns true if the format is 10-bit, false otherwise. + * \returns true if the format is a floating point, false otherwise. * * \threadsafety It is safe to call this macro from any thread. * @@ -1096,7 +1096,7 @@ typedef enum SDL_Colorspace SDL_CHROMA_LOCATION_LEFT), */ SDL_COLORSPACE_RGB_DEFAULT = SDL_COLORSPACE_SRGB, /**< The default colorspace for RGB surfaces if no colorspace is specified */ - SDL_COLORSPACE_YUV_DEFAULT = SDL_COLORSPACE_JPEG /**< The default colorspace for YUV surfaces if no colorspace is specified */ + SDL_COLORSPACE_YUV_DEFAULT = SDL_COLORSPACE_BT601_LIMITED /**< The default colorspace for YUV surfaces if no colorspace is specified */ } SDL_Colorspace; /** @@ -1379,7 +1379,7 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormatDetails *for * (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, * 0xff, 0xff] not [0xf8, 0xfc, 0xf8]). * - * \param pixel a pixel value. + * \param pixelvalue a pixel value. * \param format a pointer to SDL_PixelFormatDetails describing the pixel * format. * \param palette an optional palette for indexed formats, may be NULL. @@ -1397,7 +1397,7 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormatDetails *for * \sa SDL_MapRGB * \sa SDL_MapRGBA */ -extern SDL_DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b); +extern SDL_DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixelvalue, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b); /** * Get RGBA values from a pixel in the specified format. @@ -1410,7 +1410,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, const SDL_PixelFormatD * If the surface has no alpha component, the alpha will be returned as 0xff * (100% opaque). * - * \param pixel a pixel value. + * \param pixelvalue a pixel value. * \param format a pointer to SDL_PixelFormatDetails describing the pixel * format. * \param palette an optional palette for indexed formats, may be NULL. @@ -1429,7 +1429,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, const SDL_PixelFormatD * \sa SDL_MapRGB * \sa SDL_MapRGBA */ -extern SDL_DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a); +extern SDL_DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixelvalue, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a); /* Ends C function definitions when using C++ */ diff --git a/vendor/sdl3/include/SDL_platform_defines.h b/vendor/sdl3/include/SDL_platform_defines.h index 6b240a8be..7de110e03 100644 --- a/vendor/sdl3/include/SDL_platform_defines.h +++ b/vendor/sdl3/include/SDL_platform_defines.h @@ -190,7 +190,7 @@ #if TARGET_OS_VISION /** - * A preprocessor macro that is only defined if compiling for VisionOS. + * A preprocessor macro that is only defined if compiling for visionOS. * * \since This macro is available since SDL 3.2.0. * @@ -202,7 +202,7 @@ #if TARGET_OS_IPHONE /** - * A preprocessor macro that is only defined if compiling for iOS. + * A preprocessor macro that is only defined if compiling for iOS or visionOS. * * \since This macro is available since SDL 3.2.0. * @@ -317,7 +317,7 @@ #define SDL_PLATFORM_CYGWIN 1 #endif -#if defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN) +#if (defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN)) && !defined(__NGAGE__) /** * A preprocessor macro that is only defined if compiling for Windows. @@ -473,4 +473,25 @@ #define SDL_PLATFORM_3DS 1 #endif +#ifdef __NGAGE__ + +/** + * A preprocessor macro that is only defined if compiling for the Nokia + * N-Gage. + * + * \since This macro is available since SDL 3.4.0. + */ +#define SDL_PLATFORM_NGAGE 1 +#endif + +#ifdef __GNU__ + +/** + * A preprocessor macro that is only defined if compiling for GNU/Hurd. + * + * \since This macro is available since SDL 3.4.0. + */ +#define SDL_PLATFORM_HURD 1 +#endif + #endif /* SDL_platform_defines_h_ */ diff --git a/vendor/sdl3/include/SDL_power.h b/vendor/sdl3/include/SDL_power.h index 694fb0924..bc2d9d53e 100644 --- a/vendor/sdl3/include/SDL_power.h +++ b/vendor/sdl3/include/SDL_power.h @@ -88,8 +88,8 @@ typedef enum SDL_PowerState * can't determine a value or there is no battery. * \param percent a pointer filled in with the percentage of battery life * left, between 0 and 100, or NULL to ignore. This will be - * filled in with -1 we can't determine a value or there is no - * battery. + * filled in with -1 when we can't determine a value or there + * is no battery. * \returns the current battery state or `SDL_POWERSTATE_ERROR` on failure; * call SDL_GetError() for more information. * diff --git a/vendor/sdl3/include/SDL_process.h b/vendor/sdl3/include/SDL_process.h index 511b2f9c5..57e3afd94 100644 --- a/vendor/sdl3/include/SDL_process.h +++ b/vendor/sdl3/include/SDL_process.h @@ -166,6 +166,9 @@ typedef enum SDL_ProcessIO * - `SDL_PROP_PROCESS_CREATE_ENVIRONMENT_POINTER`: an SDL_Environment * pointer. If this property is set, it will be the entire environment for * the process, otherwise the current environment is used. + * - `SDL_PROP_PROCESS_CREATE_WORKING_DIRECTORY_STRING`: a UTF-8 encoded + * string representing the working directory for the process, defaults to + * the current working directory. * - `SDL_PROP_PROCESS_CREATE_STDIN_NUMBER`: an SDL_ProcessIO value describing * where standard input for the process comes from, defaults to * `SDL_PROCESS_STDIO_NULL`. @@ -192,6 +195,12 @@ typedef enum SDL_ProcessIO * run in the background. In this case the default input and output is * `SDL_PROCESS_STDIO_NULL` and the exitcode of the process is not * available, and will always be 0. + * - `SDL_PROP_PROCESS_CREATE_CMDLINE_STRING`: a string containing the program + * to run and any parameters. This string is passed directly to + * `CreateProcess` on Windows, and does nothing on other platforms. This + * property is only important if you want to start programs that does + * non-standard command-line processing, and in most cases using + * `SDL_PROP_PROCESS_CREATE_ARGS_POINTER` is sufficient. * * On POSIX platforms, wait() and waitpid(-1, ...) should not be called, and * SIGCHLD should not be ignored or handled because those would prevent SDL @@ -219,6 +228,7 @@ extern SDL_DECLSPEC SDL_Process * SDLCALL SDL_CreateProcessWithProperties(SDL_Pr #define SDL_PROP_PROCESS_CREATE_ARGS_POINTER "SDL.process.create.args" #define SDL_PROP_PROCESS_CREATE_ENVIRONMENT_POINTER "SDL.process.create.environment" +#define SDL_PROP_PROCESS_CREATE_WORKING_DIRECTORY_STRING "SDL.process.create.working_directory" #define SDL_PROP_PROCESS_CREATE_STDIN_NUMBER "SDL.process.create.stdin_option" #define SDL_PROP_PROCESS_CREATE_STDIN_POINTER "SDL.process.create.stdin_source" #define SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER "SDL.process.create.stdout_option" @@ -227,6 +237,7 @@ extern SDL_DECLSPEC SDL_Process * SDLCALL SDL_CreateProcessWithProperties(SDL_Pr #define SDL_PROP_PROCESS_CREATE_STDERR_POINTER "SDL.process.create.stderr_source" #define SDL_PROP_PROCESS_CREATE_STDERR_TO_STDOUT_BOOLEAN "SDL.process.create.stderr_to_stdout" #define SDL_PROP_PROCESS_CREATE_BACKGROUND_BOOLEAN "SDL.process.create.background" +#define SDL_PROP_PROCESS_CREATE_CMDLINE_STRING "SDL.process.create.cmdline" /** * Get the properties associated with a process. diff --git a/vendor/sdl3/include/SDL_properties.h b/vendor/sdl3/include/SDL_properties.h index 1f47d5f4a..8e87dfce4 100644 --- a/vendor/sdl3/include/SDL_properties.h +++ b/vendor/sdl3/include/SDL_properties.h @@ -59,7 +59,7 @@ extern "C" { #endif /** - * SDL properties ID + * An ID that represents a properties set. * * \since This datatype is available since SDL 3.2.0. */ @@ -80,6 +80,31 @@ typedef enum SDL_PropertyType SDL_PROPERTY_TYPE_BOOLEAN } SDL_PropertyType; +/** + * A generic property for naming things. + * + * This property is intended to be added to any SDL_PropertiesID that needs a + * generic name associated with the property set. It is not guaranteed that + * any property set will include this key, but it is convenient to have a + * standard key that any piece of code could reasonably agree to use. + * + * For example, the properties associated with an SDL_Texture might have a + * name string of "player sprites", or an SDL_AudioStream might have + * "background music", etc. This might also be useful for an SDL_IOStream to + * list the path to its asset. + * + * There is no format for the value set with this key; it is expected to be + * human-readable and informational in nature, possibly for logging or + * debugging purposes. + * + * SDL does not currently set this property on any objects it creates, but + * this may change in later versions; it is currently expected that apps and + * external libraries will take advantage of it, when appropriate. + * + * \since This macro is available since SDL 3.4.0. + */ +#define SDL_PROP_NAME_STRING "SDL.name" + /** * Get the global SDL properties. * @@ -119,7 +144,9 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_CreateProperties(void); * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety It is safe to call this function from any thread. + * \threadsafety It is safe to call this function from any thread. This + * function acquires simultaneous mutex locks on both the source + * and destination property sets. * * \since This function is available since SDL 3.2.0. */ diff --git a/vendor/sdl3/include/SDL_rect.h b/vendor/sdl3/include/SDL_rect.h index eb2d34a69..56eb6ffe6 100644 --- a/vendor/sdl3/include/SDL_rect.h +++ b/vendor/sdl3/include/SDL_rect.h @@ -88,8 +88,11 @@ typedef struct SDL_Rect /** - * A rectangle, with the origin at the upper left (using floating point - * values). + * A rectangle stored using floating point values. + * + * The origin of the coordinate space is in the top-left, with increasing + * values moving down and right. The properties `x` and `y` represent the + * coordinates of the top-left corner of the rectangle. * * \since This struct is available since SDL 3.2.0. * @@ -125,10 +128,10 @@ typedef struct SDL_FRect */ SDL_FORCE_INLINE void SDL_RectToFRect(const SDL_Rect *rect, SDL_FRect *frect) { - frect->x = (float)rect->x; - frect->y = (float)rect->y; - frect->w = (float)rect->w; - frect->h = (float)rect->h; + frect->x = SDL_static_cast(float, rect->x); + frect->y = SDL_static_cast(float, rect->y); + frect->w = SDL_static_cast(float, rect->w); + frect->h = SDL_static_cast(float, rect->h); } /** @@ -324,7 +327,7 @@ SDL_FORCE_INLINE bool SDL_PointInRectFloat(const SDL_FPoint *p, const SDL_FRect } /** - * Determine whether a floating point rectangle can contain any point. + * Determine whether a floating point rectangle takes no space. * * A rectangle is considered "empty" for this function if `r` is NULL, or if * `r`'s width and/or height are < 0.0f. diff --git a/vendor/sdl3/include/SDL_render.h b/vendor/sdl3/include/SDL_render.h index c9d184cc0..3d5139f59 100644 --- a/vendor/sdl3/include/SDL_render.h +++ b/vendor/sdl3/include/SDL_render.h @@ -39,9 +39,9 @@ * may also be stretched with linear interpolation. * * This API is designed to accelerate simple 2D operations. You may want more - * functionality such as polygons and particle effects and in that case you - * should use SDL's OpenGL/Direct3D support, the SDL3 GPU API, or one of the - * many good 3D engines. + * functionality such as 3D polygons and particle effects, and in that case + * you should use SDL's OpenGL/Direct3D support, the SDL3 GPU API, or one of + * the many good 3D engines. * * These functions must be called from the main thread. See this bug for * details: https://github.com/libsdl-org/SDL/issues/986 @@ -59,6 +59,7 @@ #include #include #include +#include #include /* Set up for C function definitions, even when using C++ */ @@ -73,6 +74,13 @@ extern "C" { */ #define SDL_SOFTWARE_RENDERER "software" +/** + * The name of the GPU renderer. + * + * \since This macro is available since SDL 3.4.0. + */ +#define SDL_GPU_RENDERER "gpu" + /** * Vertex structure. * @@ -97,6 +105,25 @@ typedef enum SDL_TextureAccess SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */ } SDL_TextureAccess; +/** + * The addressing mode for a texture when used in SDL_RenderGeometry(). + * + * This affects how texture coordinates are interpreted outside of [0, 1] + * + * Texture wrapping is always supported for power of two texture sizes, and is + * supported for other texture sizes if + * SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN is set to true. + * + * \since This enum is available since SDL 3.4.0. + */ +typedef enum SDL_TextureAddressMode +{ + SDL_TEXTURE_ADDRESS_INVALID = -1, + SDL_TEXTURE_ADDRESS_AUTO, /**< Wrapping is enabled if texture coordinates are outside [0, 1], this is the default */ + SDL_TEXTURE_ADDRESS_CLAMP, /**< Texture coordinates are clamped to the [0, 1] range */ + SDL_TEXTURE_ADDRESS_WRAP /**< The texture is repeated (tiled) */ +} SDL_TextureAddressMode; + /** * How the logical size is mapped to the output. * @@ -106,7 +133,7 @@ typedef enum SDL_RendererLogicalPresentation { SDL_LOGICAL_PRESENTATION_DISABLED, /**< There is no logical size in effect */ SDL_LOGICAL_PRESENTATION_STRETCH, /**< The rendered content is stretched to the output resolution */ - SDL_LOGICAL_PRESENTATION_LETTERBOX, /**< The rendered content is fit to the largest dimension and the other dimension is letterboxed with black bars */ + SDL_LOGICAL_PRESENTATION_LETTERBOX, /**< The rendered content is fit to the largest dimension and the other dimension is letterboxed with the clear color */ SDL_LOGICAL_PRESENTATION_OVERSCAN, /**< The rendered content is fit to the smallest dimension and the other dimension extends beyond the output bounds */ SDL_LOGICAL_PRESENTATION_INTEGER_SCALE /**< The rendered content is scaled up by integer multiples to fit the output resolution */ } SDL_RendererLogicalPresentation; @@ -267,6 +294,17 @@ extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window *window * present synchronized with the refresh rate. This property can take any * value that is supported by SDL_SetRenderVSync() for the renderer. * + * With the SDL GPU renderer (since SDL 3.4.0): + * + * - `SDL_PROP_RENDERER_CREATE_GPU_DEVICE_POINTER`: the device to use with the + * renderer, optional. + * - `SDL_PROP_RENDERER_CREATE_GPU_SHADERS_SPIRV_BOOLEAN`: the app is able to + * provide SPIR-V shaders to SDL_GPURenderState, optional. + * - `SDL_PROP_RENDERER_CREATE_GPU_SHADERS_DXIL_BOOLEAN`: the app is able to + * provide DXIL shaders to SDL_GPURenderState, optional. + * - `SDL_PROP_RENDERER_CREATE_GPU_SHADERS_MSL_BOOLEAN`: the app is able to + * provide MSL shaders to SDL_GPURenderState, optional. + * * With the vulkan renderer: * * - `SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER`: the VkInstance to use @@ -303,6 +341,10 @@ extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRendererWithProperties(SDL_ #define SDL_PROP_RENDERER_CREATE_SURFACE_POINTER "SDL.renderer.create.surface" #define SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.create.output_colorspace" #define SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER "SDL.renderer.create.present_vsync" +#define SDL_PROP_RENDERER_CREATE_GPU_DEVICE_POINTER "SDL.renderer.create.gpu.device" +#define SDL_PROP_RENDERER_CREATE_GPU_SHADERS_SPIRV_BOOLEAN "SDL.renderer.create.gpu.shaders_spirv" +#define SDL_PROP_RENDERER_CREATE_GPU_SHADERS_DXIL_BOOLEAN "SDL.renderer.create.gpu.shaders_dxil" +#define SDL_PROP_RENDERER_CREATE_GPU_SHADERS_MSL_BOOLEAN "SDL.renderer.create.gpu.shaders_msl" #define SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER "SDL.renderer.create.vulkan.instance" #define SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER "SDL.renderer.create.vulkan.surface" #define SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER "SDL.renderer.create.vulkan.physical_device" @@ -310,6 +352,53 @@ extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRendererWithProperties(SDL_ #define SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.create.vulkan.graphics_queue_family_index" #define SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.create.vulkan.present_queue_family_index" +/** + * Create a 2D GPU rendering context. + * + * The GPU device to use is passed in as a parameter. If this is NULL, then a + * device will be created normally and can be retrieved using + * SDL_GetGPURendererDevice(). + * + * The window to use is passed in as a parameter. If this is NULL, then this + * will become an offscreen renderer. In that case, you should call + * SDL_SetRenderTarget() to setup rendering to a texture, and then call + * SDL_RenderPresent() normally to complete drawing a frame. + * + * \param device the GPU device to use with the renderer, or NULL to create a + * device. + * \param window the window where rendering is displayed, or NULL to create an + * offscreen renderer. + * \returns a valid rendering context or NULL if there was an error; call + * SDL_GetError() for more information. + * + * \threadsafety If this function is called with a valid GPU device, it should + * be called on the thread that created the device. If this + * function is called with a valid window, it should be called + * on the thread that created the window. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_CreateRendererWithProperties + * \sa SDL_GetGPURendererDevice + * \sa SDL_CreateGPUShader + * \sa SDL_CreateGPURenderState + * \sa SDL_SetGPURenderState + */ +extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateGPURenderer(SDL_GPUDevice *device, SDL_Window *window); + +/** + * Return the GPU device used by a renderer. + * + * \param renderer the rendering context. + * \returns the GPU device used by the renderer, or NULL if the renderer is + * not a GPU renderer; call SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_GetGPURendererDevice(SDL_Renderer *renderer); + /** * Create a 2D software rendering context for a surface. * @@ -323,7 +412,7 @@ extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRendererWithProperties(SDL_ * \returns a valid rendering context or NULL if there was an error; call * SDL_GetError() for more information. * - * \threadsafety This function should only be called on the main thread. + * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. * @@ -389,6 +478,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetRendererName(SDL_Renderer *rende * - `SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER`: a (const SDL_PixelFormat *) * array of pixel formats, terminated with SDL_PIXELFORMAT_UNKNOWN, * representing the available texture formats for this renderer. + * - `SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN`: true if the renderer + * supports SDL_TEXTURE_ADDRESS_WRAP on non-power-of-two textures. * - `SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER`: an SDL_Colorspace value * describing the colorspace for output to the display, defaults to * SDL_COLORSPACE_SRGB. @@ -465,6 +556,7 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetRendererProperties(SDL_Rende #define SDL_PROP_RENDERER_VSYNC_NUMBER "SDL.renderer.vsync" #define SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER "SDL.renderer.max_texture_size" #define SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER "SDL.renderer.texture_formats" +#define SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN "SDL.renderer.texture_wrapping" #define SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.output_colorspace" #define SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN "SDL.renderer.HDR_enabled" #define SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT "SDL.renderer.SDR_white_point" @@ -601,6 +693,9 @@ extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Rende * pixels, required * - `SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER`: the height of the texture in * pixels, required + * - `SDL_PROP_TEXTURE_CREATE_PALETTE_POINTER`: an SDL_Palette to use with + * palettized texture formats. This can be set later with + * SDL_SetTexturePalette() * - `SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating * point textures, this defines the value of 100% diffuse white, with higher * values being displayed in the High Dynamic Range headroom. This defaults @@ -673,9 +768,24 @@ extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Rende * * With the vulkan renderer: * - * - `SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER`: the VkImage with layout - * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL associated with the texture, if - * you want to wrap an existing texture. + * - `SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER`: the VkImage associated + * with the texture, if you want to wrap an existing texture. + * - `SDL_PROP_TEXTURE_CREATE_VULKAN_LAYOUT_NUMBER`: the VkImageLayout for the + * VkImage, defaults to VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL. + * + * With the GPU renderer: + * + * - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_POINTER`: the SDL_GPUTexture + * associated with the texture, if you want to wrap an existing texture. + * - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_NUMBER`: the SDL_GPUTexture + * associated with the UV plane of an NV12 texture, if you want to wrap an + * existing texture. + * - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_U_NUMBER`: the SDL_GPUTexture + * associated with the U plane of a YUV texture, if you want to wrap an + * existing texture. + * - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_V_NUMBER`: the SDL_GPUTexture + * associated with the V plane of a YUV texture, if you want to wrap an + * existing texture. * * \param renderer the rendering context. * \param props the properties to use. @@ -695,29 +805,35 @@ extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Rende */ extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_PropertiesID props); -#define SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER "SDL.texture.create.colorspace" -#define SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER "SDL.texture.create.format" -#define SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER "SDL.texture.create.access" -#define SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER "SDL.texture.create.width" -#define SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER "SDL.texture.create.height" -#define SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT "SDL.texture.create.SDR_white_point" -#define SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT "SDL.texture.create.HDR_headroom" -#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER "SDL.texture.create.d3d11.texture" -#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER "SDL.texture.create.d3d11.texture_u" -#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER "SDL.texture.create.d3d11.texture_v" -#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER "SDL.texture.create.d3d12.texture" -#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER "SDL.texture.create.d3d12.texture_u" -#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER "SDL.texture.create.d3d12.texture_v" -#define SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER "SDL.texture.create.metal.pixelbuffer" -#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER "SDL.texture.create.opengl.texture" -#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.create.opengl.texture_uv" -#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.create.opengl.texture_u" -#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.create.opengl.texture_v" -#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.create.opengles2.texture" -#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.create.opengles2.texture_uv" -#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.create.opengles2.texture_u" -#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.create.opengles2.texture_v" -#define SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER "SDL.texture.create.vulkan.texture" +#define SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER "SDL.texture.create.colorspace" +#define SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER "SDL.texture.create.format" +#define SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER "SDL.texture.create.access" +#define SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER "SDL.texture.create.width" +#define SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER "SDL.texture.create.height" +#define SDL_PROP_TEXTURE_CREATE_PALETTE_POINTER "SDL.texture.create.palette" +#define SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT "SDL.texture.create.SDR_white_point" +#define SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT "SDL.texture.create.HDR_headroom" +#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER "SDL.texture.create.d3d11.texture" +#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER "SDL.texture.create.d3d11.texture_u" +#define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER "SDL.texture.create.d3d11.texture_v" +#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER "SDL.texture.create.d3d12.texture" +#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER "SDL.texture.create.d3d12.texture_u" +#define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER "SDL.texture.create.d3d12.texture_v" +#define SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER "SDL.texture.create.metal.pixelbuffer" +#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER "SDL.texture.create.opengl.texture" +#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.create.opengl.texture_uv" +#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.create.opengl.texture_u" +#define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.create.opengl.texture_v" +#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.create.opengles2.texture" +#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.create.opengles2.texture_uv" +#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.create.opengles2.texture_u" +#define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.create.opengles2.texture_v" +#define SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER "SDL.texture.create.vulkan.texture" +#define SDL_PROP_TEXTURE_CREATE_VULKAN_LAYOUT_NUMBER "SDL.texture.create.vulkan.layout" +#define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_POINTER "SDL.texture.create.gpu.texture" +#define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_POINTER "SDL.texture.create.gpu.texture_uv" +#define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_U_POINTER "SDL.texture.create.gpu.texture_u" +#define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_V_POINTER "SDL.texture.create.gpu.texture_v" /** * Get the properties associated with a texture. @@ -797,6 +913,17 @@ extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureWithProperties(SDL_Re * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER`: the GLenum for the * texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_EXTERNAL_OES`, etc) * + * With the gpu renderer: + * + * - `SDL_PROP_TEXTURE_GPU_TEXTURE_POINTER`: the SDL_GPUTexture associated + * with the texture + * - `SDL_PROP_TEXTURE_GPU_TEXTURE_UV_POINTER`: the SDL_GPUTexture associated + * with the UV plane of an NV12 texture + * - `SDL_PROP_TEXTURE_GPU_TEXTURE_U_POINTER`: the SDL_GPUTexture associated + * with the U plane of a YUV texture + * - `SDL_PROP_TEXTURE_GPU_TEXTURE_V_POINTER`: the SDL_GPUTexture associated + * with the V plane of a YUV texture + * * \param texture the texture to query. * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. @@ -833,6 +960,10 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetTextureProperties(SDL_Textur #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.opengles2.texture_v" #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER "SDL.texture.opengles2.target" #define SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER "SDL.texture.vulkan.texture" +#define SDL_PROP_TEXTURE_GPU_TEXTURE_POINTER "SDL.texture.gpu.texture" +#define SDL_PROP_TEXTURE_GPU_TEXTURE_UV_POINTER "SDL.texture.gpu.texture_uv" +#define SDL_PROP_TEXTURE_GPU_TEXTURE_U_POINTER "SDL.texture.gpu.texture_u" +#define SDL_PROP_TEXTURE_GPU_TEXTURE_V_POINTER "SDL.texture.gpu.texture_v" /** * Get the renderer that created an SDL_Texture. @@ -864,6 +995,43 @@ extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_GetRendererFromTexture(SDL_Textur */ extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureSize(SDL_Texture *texture, float *w, float *h); +/** + * Set the palette used by a texture. + * + * Setting the palette keeps an internal reference to the palette, which can + * be safely destroyed afterwards. + * + * A single palette can be shared with many textures. + * + * \param texture the texture to update. + * \param palette the SDL_Palette structure to use. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_CreatePalette + * \sa SDL_GetTexturePalette + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetTexturePalette(SDL_Texture *texture, SDL_Palette *palette); + +/** + * Get the palette used by a texture. + * + * \param texture the texture to query. + * \returns a pointer to the palette used by the texture, or NULL if there is + * no palette used. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_SetTexturePalette + */ +extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_GetTexturePalette(SDL_Texture *texture); + /** * Set an additional color value multiplied into render copy operations. * @@ -1386,14 +1554,6 @@ extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *rend * specific dimensions but to make fonts look sharp, the app turns off logical * presentation while drawing text, for example. * - * For the renderer's window, letterboxing is drawn into the framebuffer if - * logical presentation is enabled during SDL_RenderPresent; be sure to - * reenable it before presenting if you were toggling it, otherwise the - * letterbox areas might have artifacts from previous frames (or artifacts - * from external overlays, etc). Letterboxing is never drawn into texture - * render targets; be sure to call SDL_RenderClear() before drawing into the - * texture so the letterboxing areas are cleared, if appropriate. - * * You can convert coordinates in an event into rendering coordinates using * SDL_ConvertEventToRenderCoordinates(). * @@ -1418,15 +1578,16 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderLogicalPresentation(SDL_Renderer * * Get device independent resolution and presentation mode for rendering. * * This function gets the width and height of the logical rendering output, or - * the output size in pixels if a logical resolution is not enabled. + * 0 if a logical resolution is not enabled. * * Each render target has its own logical presentation state. This function * gets the state for the current render target. * * \param renderer the rendering context. - * \param w an int to be filled with the width. - * \param h an int to be filled with the height. - * \param mode the presentation mode used. + * \param w an int filled with the logical presentation width. + * \param h an int filled with the logical presentation height. + * \param mode a variable filled with the logical presentation mode being + * used. * \returns true on success or false on failure; call SDL_GetError() for more * information. * @@ -1545,8 +1706,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesToWindow(SDL_Renderer *ren * * \param renderer the rendering context. * \param event the event to modify. - * \returns true on success or false on failure; call SDL_GetError() for more - * information. + * \returns true if the event is converted or doesn't need conversion, or + * false on failure; call SDL_GetError() for more information. * * \threadsafety This function should only be called on the main thread. * @@ -2231,9 +2392,48 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureTiled(SDL_Renderer *renderer, * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderTexture + * \sa SDL_RenderTexture9GridTiled */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture9Grid(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, const SDL_FRect *dstrect); +/** + * Perform a scaled copy using the 9-grid algorithm to the current rendering + * target at subpixel precision. + * + * The pixels in the texture are split into a 3x3 grid, using the different + * corner sizes for each corner, and the sides and center making up the + * remaining pixels. The corners are then scaled using `scale` and fit into + * the corners of the destination rectangle. The sides and center are then + * tiled into place to cover the remaining destination rectangle. + * + * \param renderer the renderer which should copy parts of a texture. + * \param texture the source texture. + * \param srcrect the SDL_Rect structure representing the rectangle to be used + * for the 9-grid, or NULL to use the entire texture. + * \param left_width the width, in pixels, of the left corners in `srcrect`. + * \param right_width the width, in pixels, of the right corners in `srcrect`. + * \param top_height the height, in pixels, of the top corners in `srcrect`. + * \param bottom_height the height, in pixels, of the bottom corners in + * `srcrect`. + * \param scale the scale used to transform the corner of `srcrect` into the + * corner of `dstrect`, or 0.0f for an unscaled copy. + * \param dstrect a pointer to the destination rectangle, or NULL for the + * entire rendering target. + * \param tileScale the scale used to transform the borders and center of + * `srcrect` into the borders and middle of `dstrect`, or + * 1.0f for an unscaled copy. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_RenderTexture + * \sa SDL_RenderTexture9Grid + */ +extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture9GridTiled(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, const SDL_FRect *dstrect, float tileScale); + /** * Render a list of triangles, optionally using a texture and indices into the * vertex array Color and alpha modulation is done per vertex @@ -2255,6 +2455,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture9Grid(SDL_Renderer *renderer, * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderGeometryRaw + * \sa SDL_SetRenderTextureAddressMode */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer, SDL_Texture *texture, @@ -2287,6 +2488,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer, * \since This function is available since SDL 3.2.0. * * \sa SDL_RenderGeometry + * \sa SDL_SetRenderTextureAddressMode */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer, SDL_Texture *texture, @@ -2296,6 +2498,44 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer, int num_vertices, const void *indices, int num_indices, int size_indices); +/** + * Set the texture addressing mode used in SDL_RenderGeometry(). + * + * \param renderer the rendering context. + * \param u_mode the SDL_TextureAddressMode to use for horizontal texture + * coordinates in SDL_RenderGeometry(). + * \param v_mode the SDL_TextureAddressMode to use for vertical texture + * coordinates in SDL_RenderGeometry(). + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_RenderGeometry + * \sa SDL_RenderGeometryRaw + * \sa SDL_GetRenderTextureAddressMode + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderTextureAddressMode(SDL_Renderer *renderer, SDL_TextureAddressMode u_mode, SDL_TextureAddressMode v_mode); + +/** + * Get the texture addressing mode used in SDL_RenderGeometry(). + * + * \param renderer the rendering context. + * \param u_mode a pointer filled in with the SDL_TextureAddressMode to use + * for horizontal texture coordinates in SDL_RenderGeometry(), + * may be NULL. + * \param v_mode a pointer filled in with the SDL_TextureAddressMode to use + * for vertical texture coordinates in SDL_RenderGeometry(), may + * be NULL. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_SetRenderTextureAddressMode + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderTextureAddressMode(SDL_Renderer *renderer, SDL_TextureAddressMode *u_mode, SDL_TextureAddressMode *v_mode); + /** * Read pixels from the current rendering target. * @@ -2347,8 +2587,7 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_RenderReadPixels(SDL_Renderer *ren * should not be done; you are only required to change back the rendering * target to default via `SDL_SetRenderTarget(renderer, NULL)` afterwards, as * textures by themselves do not have a concept of backbuffers. Calling - * SDL_RenderPresent while rendering to a texture will still update the screen - * with any current drawing that has been done _to the window itself_. + * SDL_RenderPresent while rendering to a texture will fail. * * \param renderer the rendering context. * \returns true on success or false on failure; call SDL_GetError() for more @@ -2577,8 +2816,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderVSync(SDL_Renderer *renderer, int * Among these limitations: * * - It accepts UTF-8 strings, but will only renders ASCII characters. - * - It has a single, tiny size (8x8 pixels). One can use logical presentation - * or scaling to adjust it, but it will be blurry. + * - It has a single, tiny size (8x8 pixels). You can use logical presentation + * or SDL_SetRenderScale() to adjust it. * - It uses a simple, hardcoded bitmap font. It does not allow different font * selections and it does not support truetype, for proper scaling. * - It does no word-wrapping and does not treat newline characters as a line @@ -2612,7 +2851,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenderDebugText(SDL_Renderer *renderer, flo * Draw debug text to an SDL_Renderer. * * This function will render a printf()-style format string to a renderer. - * Note that this is a convinence function for debugging, with severe + * Note that this is a convenience function for debugging, with severe * limitations, and is not intended to be used for production apps and games. * * For the full list of limitations and other useful information, see @@ -2636,6 +2875,148 @@ extern SDL_DECLSPEC bool SDLCALL SDL_RenderDebugText(SDL_Renderer *renderer, flo */ extern SDL_DECLSPEC bool SDLCALL SDL_RenderDebugTextFormat(SDL_Renderer *renderer, float x, float y, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(4); +/** + * Set default scale mode for new textures for given renderer. + * + * When a renderer is created, scale_mode defaults to SDL_SCALEMODE_LINEAR. + * + * \param renderer the renderer to update. + * \param scale_mode the scale mode to change to for new textures. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_GetDefaultTextureScaleMode + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetDefaultTextureScaleMode(SDL_Renderer *renderer, SDL_ScaleMode scale_mode); + +/** + * Get default texture scale mode of the given renderer. + * + * \param renderer the renderer to get data from. + * \param scale_mode a SDL_ScaleMode filled with current default scale mode. + * See SDL_SetDefaultTextureScaleMode() for the meaning of + * the value. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_SetDefaultTextureScaleMode + */ +extern SDL_DECLSPEC bool SDLCALL SDL_GetDefaultTextureScaleMode(SDL_Renderer *renderer, SDL_ScaleMode *scale_mode); + +/** + * A structure specifying the parameters of a GPU render state. + * + * \since This struct is available since SDL 3.4.0. + * + * \sa SDL_CreateGPURenderState + */ +typedef struct SDL_GPURenderStateCreateInfo +{ + SDL_GPUShader *fragment_shader; /**< The fragment shader to use when this render state is active */ + + Sint32 num_sampler_bindings; /**< The number of additional fragment samplers to bind when this render state is active */ + const SDL_GPUTextureSamplerBinding *sampler_bindings; /**< Additional fragment samplers to bind when this render state is active */ + + Sint32 num_storage_textures; /**< The number of storage textures to bind when this render state is active */ + SDL_GPUTexture *const *storage_textures; /**< Storage textures to bind when this render state is active */ + + Sint32 num_storage_buffers; /**< The number of storage buffers to bind when this render state is active */ + SDL_GPUBuffer *const *storage_buffers; /**< Storage buffers to bind when this render state is active */ + + SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ +} SDL_GPURenderStateCreateInfo; + +/** + * A custom GPU render state. + * + * \since This struct is available since SDL 3.4.0. + * + * \sa SDL_CreateGPURenderState + * \sa SDL_SetGPURenderStateFragmentUniforms + * \sa SDL_SetGPURenderState + * \sa SDL_DestroyGPURenderState + */ +typedef struct SDL_GPURenderState SDL_GPURenderState; + +/** + * Create custom GPU render state. + * + * \param renderer the renderer to use. + * \param createinfo a struct describing the GPU render state to create. + * \returns a custom GPU render state or NULL on failure; call SDL_GetError() + * for more information. + * + * \threadsafety This function should be called on the thread that created the + * renderer. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_SetGPURenderStateFragmentUniforms + * \sa SDL_SetGPURenderState + * \sa SDL_DestroyGPURenderState + */ +extern SDL_DECLSPEC SDL_GPURenderState * SDLCALL SDL_CreateGPURenderState(SDL_Renderer *renderer, SDL_GPURenderStateCreateInfo *createinfo); + +/** + * Set fragment shader uniform variables in a custom GPU render state. + * + * The data is copied and will be pushed using + * SDL_PushGPUFragmentUniformData() during draw call execution. + * + * \param state the state to modify. + * \param slot_index the fragment uniform slot to push data to. + * \param data client data to write. + * \param length the length of the data to write. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should be called on the thread that created the + * renderer. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetGPURenderStateFragmentUniforms(SDL_GPURenderState *state, Uint32 slot_index, const void *data, Uint32 length); + +/** + * Set custom GPU render state. + * + * This function sets custom GPU render state for subsequent draw calls. This + * allows using custom shaders with the GPU renderer. + * + * \param renderer the renderer to use. + * \param state the state to to use, or NULL to clear custom GPU render state. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should be called on the thread that created the + * renderer. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetGPURenderState(SDL_Renderer *renderer, SDL_GPURenderState *state); + +/** + * Destroy custom GPU render state. + * + * \param state the state to destroy. + * + * \threadsafety This function should be called on the thread that created the + * renderer. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_CreateGPURenderState + */ +extern SDL_DECLSPEC void SDLCALL SDL_DestroyGPURenderState(SDL_GPURenderState *state); + /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/vendor/sdl3/include/SDL_revision.h b/vendor/sdl3/include/SDL_revision.h index 9fb9937d9..d4e850ece 100644 --- a/vendor/sdl3/include/SDL_revision.h +++ b/vendor/sdl3/include/SDL_revision.h @@ -1,22 +1,22 @@ /* - Simple DirectMedia Layer - Copyright (C) 1997-2025 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /* WIKI CATEGORY: Version */ @@ -44,13 +44,16 @@ * clue in debugging forensics and not something the app will parse in any * way. * - * \since This macro is available since SDL 3.0.0. + * SDL_revision.h must be included in your program explicitly if you want + * access to the SDL_REVISION constant. + * + * \since This macro is available since SDL 3.2.0. */ #define SDL_REVISION "Some arbitrary string decided at SDL build time" #elif defined(SDL_VENDOR_INFO) -#define SDL_REVISION "release-3.2.16-0-gc9a6709bd (" SDL_VENDOR_INFO ")" +#define SDL_REVISION SDL_VENDOR_INFO #else -#define SDL_REVISION "release-3.2.16-0-gc9a6709bd" +#define SDL_REVISION "" #endif #endif /* SDL_revision_h_ */ diff --git a/vendor/sdl3/include/SDL_scancode.h b/vendor/sdl3/include/SDL_scancode.h index 9650a6cfe..6e9be47e6 100644 --- a/vendor/sdl3/include/SDL_scancode.h +++ b/vendor/sdl3/include/SDL_scancode.h @@ -208,7 +208,7 @@ typedef enum SDL_Scancode SDL_SCANCODE_NONUSBACKSLASH = 100, /**< This is the additional key that ISO * keyboards have over ANSI ones, - * located between left shift and Y. + * located between left shift and Z. * Produces GRAVE ACCENT and TILDE in a * US or UK Mac layout, REVERSE SOLIDUS * (backslash) and VERTICAL LINE in a diff --git a/vendor/sdl3/include/SDL_sensor.h b/vendor/sdl3/include/SDL_sensor.h index b220f0538..43366f135 100644 --- a/vendor/sdl3/include/SDL_sensor.h +++ b/vendor/sdl3/include/SDL_sensor.h @@ -138,7 +138,8 @@ typedef enum SDL_SensorType SDL_SENSOR_ACCEL_L, /**< Accelerometer for left Joy-Con controller and Wii nunchuk */ SDL_SENSOR_GYRO_L, /**< Gyroscope for left Joy-Con controller */ SDL_SENSOR_ACCEL_R, /**< Accelerometer for right Joy-Con controller */ - SDL_SENSOR_GYRO_R /**< Gyroscope for right Joy-Con controller */ + SDL_SENSOR_GYRO_R, /**< Gyroscope for right Joy-Con controller */ + SDL_SENSOR_COUNT } SDL_SensorType; diff --git a/vendor/sdl3/include/SDL_stdinc.h b/vendor/sdl3/include/SDL_stdinc.h index 7df253fec..f15ab727b 100644 --- a/vendor/sdl3/include/SDL_stdinc.h +++ b/vendor/sdl3/include/SDL_stdinc.h @@ -49,10 +49,37 @@ #include #include -#include #include #include +/* Most everything except Visual Studio 2008 and earlier has stdint.h now */ +#if defined(_MSC_VER) && (_MSC_VER < 1600) +typedef signed __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef signed __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef signed __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; +#ifndef _INTPTR_T_DEFINED +#ifdef _WIN64 +typedef __int64 intptr_t; +#else +typedef int intptr_t; +#endif +#endif +#ifndef _UINTPTR_T_DEFINED +#ifdef _WIN64 +typedef unsigned __int64 uintptr_t; +#else +typedef unsigned int uintptr_t; +#endif +#endif +#else +#include +#endif + #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ defined(SDL_INCLUDE_INTTYPES_H) #include @@ -492,7 +519,7 @@ typedef uint64_t Uint64; * and SDL_SECONDS_TO_NS(), and between Windows FILETIME values with * SDL_TimeToWindows() and SDL_TimeFromWindows(). * - * \since This macro is available since SDL 3.2.0. + * \since This datatype is available since SDL 3.2.0. * * \sa SDL_MAX_SINT64 * \sa SDL_MIN_SINT64 @@ -1164,7 +1191,7 @@ typedef struct SDL_alignment_test void *b; } SDL_alignment_test; SDL_COMPILE_TIME_ASSERT(struct_alignment, sizeof(SDL_alignment_test) == (2 * sizeof(void *))); -SDL_COMPILE_TIME_ASSERT(two_s_complement, (int)~(int)0 == (int)(-1)); +SDL_COMPILE_TIME_ASSERT(two_s_complement, SDL_static_cast(int, ~SDL_static_cast(int, 0)) == SDL_static_cast(int, -1)); #endif /* DOXYGEN_SHOULD_IGNORE_THIS */ /** \endcond */ @@ -2119,7 +2146,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_abs(int x); * * \param x the first value to compare. * \param y the second value to compare. - * \returns the lesser of `x` and `y`. + * \returns the greater of `x` and `y`. * * \threadsafety It is safe to call this macro from any thread. * @@ -2640,7 +2667,7 @@ extern SDL_DECLSPEC void * SDLCALL SDL_memset4(void *dst, Uint32 val, size_t dwo * \since This macro is available since SDL 3.2.0. * * \sa SDL_zero - * \sa SDL_zeroa + * \sa SDL_zerop */ #define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x))) @@ -3426,7 +3453,7 @@ extern SDL_DECLSPEC size_t SDLCALL SDL_utf8strnlen(const char *str, size_t bytes * Convert an integer into a string. * * This requires a radix to specified for string format. Specifying 10 - * produces a decimal number, 16 hexidecimal, etc. Must be in the range of 2 + * produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 * to 36. * * Note that this function will overflow a buffer if `str` is not large enough @@ -3454,7 +3481,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_itoa(int value, char *str, int radix); * Convert an unsigned integer into a string. * * This requires a radix to specified for string format. Specifying 10 - * produces a decimal number, 16 hexidecimal, etc. Must be in the range of 2 + * produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 * to 36. * * Note that this function will overflow a buffer if `str` is not large enough @@ -3482,7 +3509,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_uitoa(unsigned int value, char *str, int * Convert a long integer into a string. * * This requires a radix to specified for string format. Specifying 10 - * produces a decimal number, 16 hexidecimal, etc. Must be in the range of 2 + * produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 * to 36. * * Note that this function will overflow a buffer if `str` is not large enough @@ -3510,7 +3537,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_ltoa(long value, char *str, int radix); * Convert an unsigned long integer into a string. * * This requires a radix to specified for string format. Specifying 10 - * produces a decimal number, 16 hexidecimal, etc. Must be in the range of 2 + * produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 * to 36. * * Note that this function will overflow a buffer if `str` is not large enough @@ -3540,7 +3567,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *str, int * Convert a long long integer into a string. * * This requires a radix to specified for string format. Specifying 10 - * produces a decimal number, 16 hexidecimal, etc. Must be in the range of 2 + * produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 * to 36. * * Note that this function will overflow a buffer if `str` is not large enough @@ -3568,7 +3595,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_lltoa(long long value, char *str, int rad * Convert an unsigned long long integer into a string. * * This requires a radix to specified for string format. Specifying 10 - * produces a decimal number, 16 hexidecimal, etc. Must be in the range of 2 + * produces a decimal number, 16 hexadecimal, etc. Must be in the range of 2 * to 36. * * Note that this function will overflow a buffer if `str` is not large enough @@ -3923,7 +3950,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str extern SDL_DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen); /** - * Searches a string for the first occurence of any character contained in a + * Searches a string for the first occurrence of any character contained in a * breakset, and returns a pointer from the string to that character. * * \param str The null-terminated string to be searched. Must not be NULL, and @@ -3931,7 +3958,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *st * \param breakset A null-terminated string containing the list of characters * to look for. Must not be NULL, and must not overlap with * `str`. - * \returns A pointer to the location, in str, of the first occurence of a + * \returns A pointer to the location, in str, of the first occurrence of a * character present in the breakset, or NULL if none is found. * * \threadsafety It is safe to call this function from any thread. @@ -4722,7 +4749,7 @@ extern SDL_DECLSPEC float SDLCALL SDL_atan2f(float y, float x); /** * Compute the ceiling of `x`. * - * The ceiling of `x` is the smallest integer `y` such that `y > x`, i.e `x` + * The ceiling of `x` is the smallest integer `y` such that `y >= x`, i.e `x` * rounded up to the nearest integer. * * Domain: `-INF <= x <= INF` @@ -4750,7 +4777,7 @@ extern SDL_DECLSPEC double SDLCALL SDL_ceil(double x); /** * Compute the ceiling of `x`. * - * The ceiling of `x` is the smallest integer `y` such that `y > x`, i.e `x` + * The ceiling of `x` is the smallest integer `y` such that `y >= x`, i.e `x` * rounded up to the nearest integer. * * Domain: `-INF <= x <= INF` @@ -4992,7 +5019,7 @@ extern SDL_DECLSPEC float SDLCALL SDL_fabsf(float x); /** * Compute the floor of `x`. * - * The floor of `x` is the largest integer `y` such that `y > x`, i.e `x` + * The floor of `x` is the largest integer `y` such that `y <= x`, i.e `x` * rounded down to the nearest integer. * * Domain: `-INF <= x <= INF` @@ -5020,7 +5047,7 @@ extern SDL_DECLSPEC double SDLCALL SDL_floor(double x); /** * Compute the floor of `x`. * - * The floor of `x` is the largest integer `y` such that `y > x`, i.e `x` + * The floor of `x` is the largest integer `y` such that `y <= x`, i.e `x` * rounded down to the nearest integer. * * Domain: `-INF <= x <= INF` @@ -5821,7 +5848,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd); * This function converts text between encodings, reading from and writing to * a buffer. * - * It returns the number of succesful conversions on success. On error, + * It returns the number of successful conversions on success. On error, * SDL_ICONV_E2BIG is returned when the output buffer is too small, or * SDL_ICONV_EILSEQ is returned when an invalid input sequence is encountered, * or SDL_ICONV_EINVAL is returned when an incomplete input sequence is @@ -5921,7 +5948,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, * * \since This macro is available since SDL 3.2.0. */ -#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs2(S) SDL_reinterpret_cast(Uint16 *, SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)) /** * Convert a UTF-8 string to UCS-4. @@ -5935,7 +5962,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, * * \since This macro is available since SDL 3.2.0. */ -#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs4(S) SDL_reinterpret_cast(Uint32 *, SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)) /** * Convert a wchar_t string to UTF-8. @@ -5949,7 +5976,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, * * \since This macro is available since SDL 3.2.0. */ -#define SDL_iconv_wchar_utf8(S) SDL_iconv_string("UTF-8", "WCHAR_T", (char *)S, (SDL_wcslen(S)+1)*sizeof(wchar_t)) +#define SDL_iconv_wchar_utf8(S) SDL_iconv_string("UTF-8", "WCHAR_T", SDL_reinterpret_cast(const char *, S), (SDL_wcslen(S)+1)*sizeof(wchar_t)) /* force builds using Clang's static analysis tools to use literal C runtime @@ -5974,6 +6001,10 @@ size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t size); size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t size); #endif +#if !defined(HAVE_STRTOK_R) && !defined(strtok_r) +char *strtok_r(char *str, const char *delim, char **saveptr); +#endif + #ifndef _WIN32 /* strdup is not ANSI but POSIX, and its prototype might be hidden... */ /* not for windows: might conflict with string.h where strdup may have diff --git a/vendor/sdl3/include/SDL_storage.h b/vendor/sdl3/include/SDL_storage.h index 6837ebaac..1b20b34ad 100644 --- a/vendor/sdl3/include/SDL_storage.h +++ b/vendor/sdl3/include/SDL_storage.h @@ -334,6 +334,10 @@ typedef struct SDL_Storage SDL_Storage; /** * Opens up a read-only container for the application's filesystem. * + * By default, SDL_OpenTitleStorage uses the generic storage implementation. + * When the path override is not provided, the generic implementation will use + * the output of SDL_GetBasePath as the base path. + * * \param override a path to override the backend's default title root. * \param props a property list that may contain backend-specific information. * \returns a title storage container on success or NULL on failure; call diff --git a/vendor/sdl3/include/SDL_surface.h b/vendor/sdl3/include/SDL_surface.h index 15fce042f..717aeb89a 100644 --- a/vendor/sdl3/include/SDL_surface.h +++ b/vendor/sdl3/include/SDL_surface.h @@ -29,12 +29,16 @@ * provides a reasonable toolbox for transforming the data, including copying * between surfaces, filling rectangles in the image data, etc. * - * There is also a simple .bmp loader, SDL_LoadBMP(). SDL itself does not - * provide loaders for various other file formats, but there are several - * excellent external libraries that do, including its own satellite library, - * SDL_image: + * There is also a simple .bmp loader, SDL_LoadBMP(), and a simple .png + * loader, SDL_LoadPNG(). SDL itself does not provide loaders for other file + * formats, but there are several excellent external libraries that do, + * including its own satellite library, + * [SDL_image](https://wiki.libsdl.org/SDL3_image) + * . * - * https://github.com/libsdl-org/SDL_image + * In general these functions are thread-safe in that they can be called on + * different threads with different surfaces. You should not try to modify any + * surface from two threads simultaneously. */ #ifndef SDL_surface_h_ @@ -83,8 +87,9 @@ typedef Uint32 SDL_SurfaceFlags; typedef enum SDL_ScaleMode { SDL_SCALEMODE_INVALID = -1, - SDL_SCALEMODE_NEAREST, /**< nearest pixel sampling */ - SDL_SCALEMODE_LINEAR /**< linear filtering */ + SDL_SCALEMODE_NEAREST, /**< nearest pixel sampling */ + SDL_SCALEMODE_LINEAR, /**< linear filtering */ + SDL_SCALEMODE_PIXELART /**< nearest pixel sampling with improved scaling for pixel art, available since SDL 3.4.0 */ } SDL_ScaleMode; /** @@ -94,9 +99,10 @@ typedef enum SDL_ScaleMode */ typedef enum SDL_FlipMode { - SDL_FLIP_NONE, /**< Do not flip */ - SDL_FLIP_HORIZONTAL, /**< flip horizontally */ - SDL_FLIP_VERTICAL /**< flip vertically */ + SDL_FLIP_NONE, /**< Do not flip */ + SDL_FLIP_HORIZONTAL, /**< flip horizontally */ + SDL_FLIP_VERTICAL, /**< flip vertically */ + SDL_FLIP_HORIZONTAL_AND_VERTICAL = (SDL_FLIP_HORIZONTAL | SDL_FLIP_VERTICAL) /**< flip horizontally and vertically (not a diagonal flip) */ } SDL_FlipMode; #ifndef SDL_INTERNAL @@ -235,6 +241,12 @@ extern SDL_DECLSPEC void SDLCALL SDL_DestroySurface(SDL_Surface *surface); * left edge of the image, if this surface is being used as a cursor. * - `SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER`: the hotspot pixel offset from the * top edge of the image, if this surface is being used as a cursor. + * - `SDL_PROP_SURFACE_ROTATION_FLOAT`: the number of degrees a surface's data + * is meant to be rotated clockwise to make the image right-side up. Default + * 0. This is used by the camera API, if a mobile device is oriented + * differently than what its camera provides (i.e. - the camera always + * provides portrait images but the phone is being held in landscape + * orientation). Since SDL 3.4.0. * * \param surface the SDL_Surface structure to query. * \returns a valid property ID on success or 0 on failure; call @@ -251,6 +263,7 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetSurfaceProperties(SDL_Surfac #define SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING "SDL.surface.tonemap" #define SDL_PROP_SURFACE_HOTSPOT_X_NUMBER "SDL.surface.hotspot.x" #define SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER "SDL.surface.hotspot.y" +#define SDL_PROP_SURFACE_ROTATION_FLOAT "SDL.surface.rotation" /** * Set the colorspace used by a surface. @@ -264,7 +277,8 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetSurfaceProperties(SDL_Surfac * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -283,7 +297,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceColorspace(SDL_Surface *surface, * \returns the colorspace used by the surface, or SDL_COLORSPACE_UNKNOWN if * the surface is NULL. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -313,7 +328,8 @@ extern SDL_DECLSPEC SDL_Colorspace SDLCALL SDL_GetSurfaceColorspace(SDL_Surface * the surface didn't have an index format); call SDL_GetError() for * more information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -324,6 +340,9 @@ extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_CreateSurfacePalette(SDL_Surface * /** * Set the palette used by a surface. * + * Setting the palette keeps an internal reference to the palette, which can + * be safely destroyed afterwards. + * * A single palette can be shared with many surfaces. * * \param surface the SDL_Surface structure to update. @@ -331,7 +350,8 @@ extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_CreateSurfacePalette(SDL_Surface * * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -372,7 +392,8 @@ extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_GetSurfacePalette(SDL_Surface *sur * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -415,7 +436,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SurfaceHasAlternateImages(SDL_Surface *surf * failure; call SDL_GetError() for more information. This should be * freed with SDL_free() when it is no longer needed. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -433,7 +455,8 @@ extern SDL_DECLSPEC SDL_Surface ** SDLCALL SDL_GetSurfaceImages(SDL_Surface *sur * * \param surface the SDL_Surface structure to update. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -459,9 +482,10 @@ extern SDL_DECLSPEC void SDLCALL SDL_RemoveSurfaceAlternateImages(SDL_Surface *s * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. The locking referred to by - * this function is making the pixels available for direct - * access, not thread-safe locking. + * \threadsafety This function can be called on different threads with + * different surfaces. The locking referred to by this function + * is making the pixels available for direct access, not + * thread-safe locking. * * \since This function is available since SDL 3.2.0. * @@ -485,6 +509,46 @@ extern SDL_DECLSPEC bool SDLCALL SDL_LockSurface(SDL_Surface *surface); */ extern SDL_DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface); +/** + * Load a BMP or PNG image from a seekable SDL data stream. + * + * The new surface should be freed with SDL_DestroySurface(). Not doing so + * will result in a memory leak. + * + * \param src the data stream for the surface. + * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even + * in the case of an error. + * \returns a pointer to a new SDL_Surface structure or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_DestroySurface + * \sa SDL_LoadSurface + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadSurface_IO(SDL_IOStream *src, bool closeio); + +/** + * Load a BMP or PNG image from a file. + * + * The new surface should be freed with SDL_DestroySurface(). Not doing so + * will result in a memory leak. + * + * \param file the file to load. + * \returns a pointer to a new SDL_Surface structure or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_DestroySurface + * \sa SDL_LoadSurface_IO + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadSurface(const char *file); + /** * Load a BMP image from a seekable SDL data stream. * @@ -543,7 +607,8 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP(const char *file); * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -553,7 +618,7 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP(const char *file); extern SDL_DECLSPEC bool SDLCALL SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio); /** - * Save a surface to a file. + * Save a surface to a file in BMP format. * * Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the * BMP directly. Other RGB formats with 8-bit or higher get converted to a @@ -566,7 +631,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStre * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -575,6 +641,94 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStre */ extern SDL_DECLSPEC bool SDLCALL SDL_SaveBMP(SDL_Surface *surface, const char *file); +/** + * Load a PNG image from a seekable SDL data stream. + * + * This is intended as a convenience function for loading images from trusted + * sources. If you want to load arbitrary images you should use libpng or + * another image loading library designed with security in mind. + * + * The new surface should be freed with SDL_DestroySurface(). Not doing so + * will result in a memory leak. + * + * \param src the data stream for the surface. + * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even + * in the case of an error. + * \returns a pointer to a new SDL_Surface structure or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_DestroySurface + * \sa SDL_LoadPNG + * \sa SDL_SavePNG_IO + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadPNG_IO(SDL_IOStream *src, bool closeio); + +/** + * Load a PNG image from a file. + * + * This is intended as a convenience function for loading images from trusted + * sources. If you want to load arbitrary images you should use libpng or + * another image loading library designed with security in mind. + * + * The new surface should be freed with SDL_DestroySurface(). Not doing so + * will result in a memory leak. + * + * \param file the PNG file to load. + * \returns a pointer to a new SDL_Surface structure or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_DestroySurface + * \sa SDL_LoadPNG_IO + * \sa SDL_SavePNG + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadPNG(const char *file); + +/** + * Save a surface to a seekable SDL data stream in PNG format. + * + * \param surface the SDL_Surface structure containing the image to be saved. + * \param dst a data stream to save to. + * \param closeio if true, calls SDL_CloseIO() on `dst` before returning, even + * in the case of an error. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_LoadPNG_IO + * \sa SDL_SavePNG + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SavePNG_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio); + +/** + * Save a surface to a file in PNG format. + * + * \param surface the SDL_Surface structure containing the image to be saved. + * \param file a file to save to. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_LoadPNG + * \sa SDL_SavePNG_IO + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SavePNG(SDL_Surface *surface, const char *file); + /** * Set the RLE acceleration hint for a surface. * @@ -586,7 +740,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SaveBMP(SDL_Surface *surface, const char *f * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -628,7 +783,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SurfaceHasRLE(SDL_Surface *surface); * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -693,7 +849,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceColorKey(SDL_Surface *surface, Ui * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -713,7 +870,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface, Ui * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -735,7 +893,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface, Ui * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -773,7 +932,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Ui * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -812,7 +972,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface *surface, S * \returns true if the rectangle intersects the surface, otherwise false and * blits will be completely clipped. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -833,7 +994,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceClipRect(SDL_Surface *surface, co * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -849,12 +1011,42 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceClipRect(SDL_Surface *surface, SD * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. */ extern SDL_DECLSPEC bool SDLCALL SDL_FlipSurface(SDL_Surface *surface, SDL_FlipMode flip); +/** + * Return a copy of a surface rotated clockwise a number of degrees. + * + * The angle of rotation can be negative for counter-clockwise rotation. + * + * When the rotation isn't a multiple of 90 degrees, the resulting surface is + * larger than the original, with the background filled in with the colorkey, + * if available, or RGBA 255/255/255/0 if not. + * + * If `surface` has the SDL_PROP_SURFACE_ROTATION_FLOAT property set on it, + * the new copy will have the adjusted value set: if the rotation property is + * 90 and `angle` was 30, the new surface will have a property value of 60 + * (that is: to be upright vs gravity, this surface needs to rotate 60 more + * degrees). However, note that further rotations on the new surface in this + * example will produce unexpected results, since the image will have resized + * and padded to accommodate the not-90 degree angle. + * + * \param surface the surface to rotate. + * \param angle the rotation angle, in degrees. + * \returns a rotated copy of the surface or NULL on failure; call + * SDL_GetError() for more information. + * + * \threadsafety This function can be called on different threads with + * different surfaces. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_RotateSurface(SDL_Surface *surface, float angle); + /** * Creates a new surface identical to the existing surface. * @@ -867,7 +1059,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_FlipSurface(SDL_Surface *surface, SDL_FlipM * \returns a copy of the surface or NULL on failure; call SDL_GetError() for * more information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -888,7 +1081,8 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_DuplicateSurface(SDL_Surface *surf * \returns a copy of the surface or NULL on failure; call SDL_GetError() for * more information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -915,7 +1109,8 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ScaleSurface(SDL_Surface *surface, * \returns the new SDL_Surface structure that is created or NULL on failure; * call SDL_GetError() for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -943,7 +1138,8 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface(SDL_Surface *surfac * \returns the new SDL_Surface structure that is created or NULL on failure; * call SDL_GetError() for more information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -1046,7 +1242,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_PremultiplyAlpha(int width, int height, SDL * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. */ @@ -1058,7 +1255,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_PremultiplySurfaceAlpha(SDL_Surface *surfac * This function handles all surface formats, and ignores any clip rectangle. * * If the surface is YUV, the color is assumed to be in the sRGB colorspace, - * otherwise the color is assumed to be in the colorspace of the suface. + * otherwise the color is assumed to be in the colorspace of the surface. * * \param surface the SDL_Surface to clear. * \param r the red component of the pixel, normally in the range 0-1. @@ -1068,7 +1265,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_PremultiplySurfaceAlpha(SDL_Surface *surfac * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. */ @@ -1093,7 +1291,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ClearSurface(SDL_Surface *surface, float r, * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -1120,7 +1319,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_FillSurfaceRect(SDL_Surface *dst, const SDL * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -1411,7 +1611,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurface9Grid(SDL_Surface *src, const SD * \param b the blue component of the pixel in the range 0-255. * \returns a pixel value. * - * \threadsafety It is safe to call this function from any thread. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -1444,7 +1645,8 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapSurfaceRGB(SDL_Surface *surface, Uint8 * \param a the alpha component of the pixel in the range 0-255. * \returns a pixel value. * - * \threadsafety It is safe to call this function from any thread. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. * @@ -1475,7 +1677,8 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapSurfaceRGBA(SDL_Surface *surface, Uint * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. */ @@ -1501,7 +1704,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadSurfacePixel(SDL_Surface *surface, int * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. */ @@ -1526,7 +1730,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadSurfacePixelFloat(SDL_Surface *surface, * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. */ @@ -1548,7 +1753,8 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteSurfacePixel(SDL_Surface *surface, int * \returns true on success or false on failure; call SDL_GetError() for more * information. * - * \threadsafety This function is not thread safe. + * \threadsafety This function can be called on different threads with + * different surfaces. * * \since This function is available since SDL 3.2.0. */ diff --git a/vendor/sdl3/include/SDL_system.h b/vendor/sdl3/include/SDL_system.h index 294089ff4..625db182e 100644 --- a/vendor/sdl3/include/SDL_system.h +++ b/vendor/sdl3/include/SDL_system.h @@ -247,14 +247,14 @@ typedef void (SDLCALL *SDL_iOSAnimationCallback)(void *userdata); * * For more information see: * - * https://wiki.libsdl.org/SDL3/README/ios + * https://wiki.libsdl.org/SDL3/README-ios * * Note that if you use the "main callbacks" instead of a standard C `main` * function, you don't have to use this API, as SDL will manage this for you. * * Details on main callbacks are here: * - * https://wiki.libsdl.org/SDL3/README/main-functions + * https://wiki.libsdl.org/SDL3/README-main-functions * * \param window the window for which the animation callback should be set. * \param interval the number of frames after which **callback** will be diff --git a/vendor/sdl3/include/SDL_test_common.h b/vendor/sdl3/include/SDL_test_common.h index 91efe8ac3..81cea7788 100644 --- a/vendor/sdl3/include/SDL_test_common.h +++ b/vendor/sdl3/include/SDL_test_common.h @@ -153,6 +153,10 @@ typedef struct SDL_Rect confine; bool hide_cursor; + /* Misc. */ + int quit_after_ms_interval; + SDL_TimerID quit_after_ms_timer; + /* Options info */ SDLTest_ArgumentParser common_argparser; SDLTest_ArgumentParser video_argparser; diff --git a/vendor/sdl3/include/SDL_test_compare.h b/vendor/sdl3/include/SDL_test_compare.h index 7ff247793..1903549c5 100644 --- a/vendor/sdl3/include/SDL_test_compare.h +++ b/vendor/sdl3/include/SDL_test_compare.h @@ -52,6 +52,7 @@ extern "C" { * \returns 0 if comparison succeeded, >0 (=number of pixels for which the comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ. */ int SDLCALL SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error); +int SDLCALL SDLTest_CompareSurfacesIgnoreTransparentPixels(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error); /** * Compares 2 memory blocks for equality diff --git a/vendor/sdl3/include/SDL_test_log.h b/vendor/sdl3/include/SDL_test_log.h index 0d48044a0..718baa5b7 100644 --- a/vendor/sdl3/include/SDL_test_log.h +++ b/vendor/sdl3/include/SDL_test_log.h @@ -42,6 +42,14 @@ extern "C" { #endif +/** + * Prints given message with a timestamp in the TEST category and given priority. + * + * \param priority Priority of the message + * \param fmt Message to be logged + */ +void SDLCALL SDLTest_LogMessage(SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...); + /** * Prints given message with a timestamp in the TEST category and INFO priority. * diff --git a/vendor/sdl3/include/SDL_thread.h b/vendor/sdl3/include/SDL_thread.h index e981b5429..bde1bbcd7 100644 --- a/vendor/sdl3/include/SDL_thread.h +++ b/vendor/sdl3/include/SDL_thread.h @@ -37,7 +37,8 @@ * will report failure without doing anything. * * If you're going to work with threads, you almost certainly need to have a - * good understanding of [CategoryMutex](CategoryMutex) as well. + * good understanding of thread safety measures: locking and synchronization + * mechanisms are handled by the functions in SDL_mutex.h. */ #include diff --git a/vendor/sdl3/include/SDL_timer.h b/vendor/sdl3/include/SDL_timer.h index cf94881d5..490d13562 100644 --- a/vendor/sdl3/include/SDL_timer.h +++ b/vendor/sdl3/include/SDL_timer.h @@ -34,7 +34,7 @@ * This category covers measuring time elapsed (SDL_GetTicks(), * SDL_GetPerformanceCounter()), putting a thread to sleep for a certain * amount of time (SDL_Delay(), SDL_DelayNS(), SDL_DelayPrecise()), and firing - * a callback function after a certain amount of time has elasped + * a callback function after a certain amount of time has elapsed * (SDL_AddTimer(), etc). * * There are also useful macros to convert between time units, like @@ -185,14 +185,18 @@ extern "C" { #define SDL_NS_TO_US(NS) ((NS) / SDL_NS_PER_US) /** - * Get the number of milliseconds since SDL library initialization. + * Get the number of milliseconds that have elapsed since the SDL library + * initialization. * - * \returns an unsigned 64-bit value representing the number of milliseconds - * since the SDL library initialized. + * \returns an unsigned 64‑bit integer that represents the number of + * milliseconds that have elapsed since the SDL library was + * initialized (typically via a call to SDL_Init). * * \threadsafety It is safe to call this function from any thread. * * \since This function is available since SDL 3.2.0. + * + * \sa SDL_GetTicksNS */ extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetTicks(void); diff --git a/vendor/sdl3/include/SDL_version.h b/vendor/sdl3/include/SDL_version.h index 435b3f95f..3aa1605b6 100644 --- a/vendor/sdl3/include/SDL_version.h +++ b/vendor/sdl3/include/SDL_version.h @@ -53,7 +53,7 @@ extern "C" { * * \since This macro is available since SDL 3.2.0. */ -#define SDL_MINOR_VERSION 2 +#define SDL_MINOR_VERSION 4 /** * The current micro (or patchlevel) version of the SDL headers. @@ -62,7 +62,7 @@ extern "C" { * * \since This macro is available since SDL 3.2.0. */ -#define SDL_MICRO_VERSION 16 +#define SDL_MICRO_VERSION 0 /** * This macro turns the version numbers into a numeric value. @@ -148,13 +148,14 @@ extern "C" { extern SDL_DECLSPEC int SDLCALL SDL_GetVersion(void); /** - * Get the code revision of SDL that is linked against your program. + * Get the code revision of the SDL library that is linked against your + * program. * - * This value is the revision of the code you are linked with and may be + * This value is the revision of the code you are linking against and may be * different from the code you are compiling with, which is found in the - * constant SDL_REVISION. + * constant SDL_REVISION if you explicitly include SDL_revision.h * - * The revision is arbitrary string (a hash value) uniquely identifying the + * The revision is an arbitrary string (a hash value) uniquely identifying the * exact revision of the SDL library in use, and is only useful in comparing * against other revisions. It is NOT an incrementing number. * diff --git a/vendor/sdl3/include/SDL_video.h b/vendor/sdl3/include/SDL_video.h index 877b9adde..31dac5f7a 100644 --- a/vendor/sdl3/include/SDL_video.h +++ b/vendor/sdl3/include/SDL_video.h @@ -97,6 +97,8 @@ typedef Uint32 SDL_WindowID; * uninitialized will either return the user provided value, if one was set * prior to initialization, or NULL. See docs/README-wayland.md for more * information. + * + * \since This macro is available since SDL 3.2.0. */ #define SDL_PROP_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER "SDL.video.wayland.wl_display" @@ -180,6 +182,12 @@ typedef struct SDL_Window SDL_Window; * changed on existing windows by the app, and some of it might be altered by * the user or system outside of the app's control. * + * When creating windows with `SDL_WINDOW_RESIZABLE`, SDL will constrain + * resizable windows to the dimensions recommended by the compositor to fit it + * within the usable desktop space, although some compositors will do this + * automatically without intervention as well. Use `SDL_SetWindowResizable` + * after creation instead if you wish to create a window with a specific size. + * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_GetWindowFlags @@ -207,6 +215,7 @@ typedef Uint64 SDL_WindowFlags; #define SDL_WINDOW_TOOLTIP SDL_UINT64_C(0x0000000000040000) /**< window should be treated as a tooltip and does not get mouse or keyboard focus, requires a parent window */ #define SDL_WINDOW_POPUP_MENU SDL_UINT64_C(0x0000000000080000) /**< window should be treated as a popup menu, requires a parent window */ #define SDL_WINDOW_KEYBOARD_GRABBED SDL_UINT64_C(0x0000000000100000) /**< window has grabbed keyboard input */ +#define SDL_WINDOW_FILL_DOCUMENT SDL_UINT64_C(0x0000000000200000) /**< window is in fill-document mode (Emscripten only), since SDL 3.4.0 */ #define SDL_WINDOW_VULKAN SDL_UINT64_C(0x0000000010000000) /**< window usable for Vulkan surface */ #define SDL_WINDOW_METAL SDL_UINT64_C(0x0000000020000000) /**< window usable for Metal view */ #define SDL_WINDOW_TRANSPARENT SDL_UINT64_C(0x0000000040000000) /**< window with transparent buffer */ @@ -220,6 +229,8 @@ typedef Uint64 SDL_WindowFlags; * SDL_WINDOWPOS_UNDEFINED or SDL_WINDOWPOS_UNDEFINED_DISPLAY. * * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SetWindowPosition */ #define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u @@ -232,6 +243,8 @@ typedef Uint64 SDL_WindowFlags; * \param X the SDL_DisplayID of the display to use. * * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SetWindowPosition */ #define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X)) @@ -241,6 +254,8 @@ typedef Uint64 SDL_WindowFlags; * This always uses the primary display. * * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SetWindowPosition */ #define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0) @@ -250,6 +265,8 @@ typedef Uint64 SDL_WindowFlags; * \param X the window position value. * * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SetWindowPosition */ #define SDL_WINDOWPOS_ISUNDEFINED(X) (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK) @@ -260,6 +277,8 @@ typedef Uint64 SDL_WindowFlags; * SDL_WINDOWPOS_CENTERED or SDL_WINDOWPOS_CENTERED_DISPLAY. * * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SetWindowPosition */ #define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000u @@ -272,6 +291,8 @@ typedef Uint64 SDL_WindowFlags; * \param X the SDL_DisplayID of the display to use. * * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SetWindowPosition */ #define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X)) @@ -281,6 +302,8 @@ typedef Uint64 SDL_WindowFlags; * This always uses the primary display. * * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_SetWindowPosition */ #define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0) @@ -290,6 +313,8 @@ typedef Uint64 SDL_WindowFlags; * \param X the window position value. * * \since This macro is available since SDL 3.2.0. + * + * \sa SDL_GetWindowPosition */ #define SDL_WINDOWPOS_ISCENTERED(X) \ (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK) @@ -307,12 +332,30 @@ typedef enum SDL_FlashOperation SDL_FLASH_UNTIL_FOCUSED /**< Flash the window until it gets focus */ } SDL_FlashOperation; +/** + * Window progress state + * + * \since This enum is available since SDL 3.2.8. + */ +typedef enum SDL_ProgressState +{ + SDL_PROGRESS_STATE_INVALID = -1, /**< An invalid progress state indicating an error; check SDL_GetError() */ + SDL_PROGRESS_STATE_NONE, /**< No progress bar is shown */ + SDL_PROGRESS_STATE_INDETERMINATE, /**< The progress bar is shown in a indeterminate state */ + SDL_PROGRESS_STATE_NORMAL, /**< The progress bar is shown in a normal state */ + SDL_PROGRESS_STATE_PAUSED, /**< The progress bar is shown in a paused state */ + SDL_PROGRESS_STATE_ERROR /**< The progress bar is shown in a state indicating the application had an error */ +} SDL_ProgressState; + /** * An opaque handle to an OpenGL context. * * \since This datatype is available since SDL 3.2.0. * * \sa SDL_GL_CreateContext + * \sa SDL_GL_SetAttribute + * \sa SDL_GL_MakeCurrent + * \sa SDL_GL_DestroyContext */ typedef struct SDL_GLContextState *SDL_GLContext; @@ -448,7 +491,7 @@ typedef enum SDL_GLAttr SDL_GL_CONTEXT_FLAGS, /**< some combination of 0 or more of elements of the SDL_GLContextFlag enumeration; defaults to 0. */ SDL_GL_CONTEXT_PROFILE_MASK, /**< type of GL context (Core, Compatibility, ES). See SDL_GLProfile; default value depends on platform. */ SDL_GL_SHARE_WITH_CURRENT_CONTEXT, /**< OpenGL context sharing; defaults to 0. */ - SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, /**< requests sRGB capable visual; defaults to 0. */ + SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, /**< requests sRGB-capable visual if 1. Defaults to -1 ("don't care"). This is a request; GL drivers might not comply! */ SDL_GL_CONTEXT_RELEASE_BEHAVIOR, /**< sets context the release behavior. See SDL_GLContextReleaseFlag; defaults to FLUSH. */ SDL_GL_CONTEXT_RESET_NOTIFICATION, /**< set context reset notification. See SDL_GLContextResetNotification; defaults to NO_NOTIFICATION. */ SDL_GL_CONTEXT_NO_ERROR, @@ -530,7 +573,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void); * to be proper names. * * \param index the index of a video driver. - * \returns the name of the video driver with the given **index**. + * \returns the name of the video driver with the given **index**, or NULL if + * index is out of bounds. * * \threadsafety This function should only be called on the main thread. * @@ -617,6 +661,16 @@ extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetPrimaryDisplay(void); * responsible for any coordinate transformations needed to conform to the * requested display orientation. * + * On Wayland: + * + * - `SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER`: the wl_output associated + * with the display + * + * On Windows: + * + * - `SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER`: the monitor handle + * (HMONITOR) associated with the display + * * \param displayID the instance ID of the display to query. * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. @@ -629,6 +683,8 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetDisplayProperties(SDL_Displa #define SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN "SDL.display.HDR_enabled" #define SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER "SDL.display.KMSDRM.panel_orientation" +#define SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER "SDL.display.wayland.wl_output" +#define SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER "SDL.display.windows.hmonitor" /** * Get the name of a display in UTF-8 encoding. @@ -1049,8 +1105,6 @@ extern SDL_DECLSPEC SDL_Window ** SDLCALL SDL_GetWindows(int *count); * * - `SDL_WINDOW_FULLSCREEN`: fullscreen window at desktop resolution * - `SDL_WINDOW_OPENGL`: window usable with an OpenGL context - * - `SDL_WINDOW_OCCLUDED`: window partially or completely obscured by another - * window * - `SDL_WINDOW_HIDDEN`: window is not visible * - `SDL_WINDOW_BORDERLESS`: no window decoration * - `SDL_WINDOW_RESIZABLE`: window can be resized @@ -1078,7 +1132,8 @@ extern SDL_DECLSPEC SDL_Window ** SDLCALL SDL_GetWindows(int *count); * - `SDL_WINDOW_TRANSPARENT`: window with transparent buffer * - `SDL_WINDOW_NOT_FOCUSABLE`: window should not be focusable * - * The SDL_Window is implicitly shown if SDL_WINDOW_HIDDEN is not set. + * The SDL_Window will be shown if SDL_WINDOW_HIDDEN is not set. If hidden at + * creation time, SDL_ShowWindow() can be used to show it later. * * On Apple's macOS, you **must** set the NSHighResolutionCapable Info.plist * property to YES, otherwise you will not receive a High-DPI OpenGL canvas. @@ -1167,6 +1222,16 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title, int * Popup windows implicitly do not have a border/decorations and do not appear * on the taskbar/dock or in lists of windows such as alt-tab menus. * + * By default, popup window positions will automatically be constrained to + * keep the entire window within display bounds. This can be overridden with + * the `SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN` property. + * + * By default, popup menus will automatically grab keyboard focus from the + * parent when shown. This behavior can be overridden by setting the + * `SDL_WINDOW_NOT_FOCUSABLE` flag, setting the + * `SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN` property to false, or toggling + * it after creation via the `SDL_SetWindowFocusable()` function. + * * If a parent window is hidden or destroyed, any child popup windows will be * recursively hidden or destroyed as well. Child popup windows not explicitly * hidden will be restored when the parent is shown. @@ -1207,6 +1272,10 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreatePopupWindow(SDL_Window *paren * be always on top * - `SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN`: true if the window has no * window decoration + * - `SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN`: true if the "tooltip" + * and "menu" window types should be automatically constrained to be + * entirely within display bounds (default), false if no constraints on the + * position are desired. * - `SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN`: true if the * window will be used with an externally managed graphics context. * - `SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN`: true if the window should @@ -1263,12 +1332,18 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreatePopupWindow(SDL_Window *paren * - `SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTER`: the `(__unsafe_unretained)` * NSView associated with the window, defaults to `[window contentView]` * + * These are additional supported properties on iOS, tvOS, and visionOS: + * + * - `SDL_PROP_WINDOW_CREATE_WINDOWSCENE_POINTER`: the `(__unsafe_unretained)` + * UIWindowScene associated with the window, defaults to the active window + * scene. + * * These are additional supported properties on Wayland: * * - `SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN` - true if * the application wants to use the Wayland surface for a custom role and * does not want it attached to an XDG toplevel window. See - * [README/wayland](README/wayland) for more information on using custom + * [README-wayland](README-wayland) for more information on using custom * surfaces. * - `SDL_PROP_WINDOW_CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN` - true if the * application wants an associated `wl_egl_window` object to be created and @@ -1276,7 +1351,7 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreatePopupWindow(SDL_Window *paren * property or `SDL_WINDOW_OPENGL` flag set. * - `SDL_PROP_WINDOW_CREATE_WAYLAND_WL_SURFACE_POINTER` - the wl_surface * associated with the window, if you want to wrap an existing window. See - * [README/wayland](README/wayland) for more information. + * [README-wayland](README-wayland) for more information. * * These are additional supported properties on Windows: * @@ -1292,8 +1367,22 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreatePopupWindow(SDL_Window *paren * * The window is implicitly shown if the "hidden" property is not set. * - * Windows with the "tooltip" and "menu" properties are popup windows and have - * the behaviors and guidelines outlined in SDL_CreatePopupWindow(). + * These are additional supported properties with Emscripten: + * + * - `SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_CANVAS_ID_STRING`: the id given to the + * canvas element. This should start with a '#' sign + * - `SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING`: override the + * binding element for keyboard inputs for this canvas. The variable can be + * one of: + * - "#window": the javascript window object (default) + * - "#document": the javascript document object + * - "#screen": the javascript window.screen object + * - "#canvas": the WebGL canvas element + * - "#none": Don't bind anything at all + * - any other string without a leading # sign applies to the element on the + * page with that ID. Windows with the "tooltip" and "menu" properties are + * popup windows and have the behaviors and guidelines outlined in + * SDL_CreatePopupWindow(). * * If this window is being created to be used with an SDL_Renderer, you should * not add a graphics API specific property @@ -1321,6 +1410,7 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowWithProperties(SDL_Prop #define SDL_PROP_WINDOW_CREATE_ALWAYS_ON_TOP_BOOLEAN "SDL.window.create.always_on_top" #define SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN "SDL.window.create.borderless" +#define SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN "SDL.window.create.constrain_popup" #define SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN "SDL.window.create.focusable" #define SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN "SDL.window.create.external_graphics_context" #define SDL_PROP_WINDOW_CREATE_FLAGS_NUMBER "SDL.window.create.flags" @@ -1347,12 +1437,15 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowWithProperties(SDL_Prop #define SDL_PROP_WINDOW_CREATE_Y_NUMBER "SDL.window.create.y" #define SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER "SDL.window.create.cocoa.window" #define SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTER "SDL.window.create.cocoa.view" +#define SDL_PROP_WINDOW_CREATE_WINDOWSCENE_POINTER "SDL.window.create.uikit.windowscene" #define SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN "SDL.window.create.wayland.surface_role_custom" #define SDL_PROP_WINDOW_CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN "SDL.window.create.wayland.create_egl_window" #define SDL_PROP_WINDOW_CREATE_WAYLAND_WL_SURFACE_POINTER "SDL.window.create.wayland.wl_surface" #define SDL_PROP_WINDOW_CREATE_WIN32_HWND_POINTER "SDL.window.create.win32.hwnd" #define SDL_PROP_WINDOW_CREATE_WIN32_PIXEL_FORMAT_HWND_POINTER "SDL.window.create.win32.pixel_format_hwnd" #define SDL_PROP_WINDOW_CREATE_X11_WINDOW_NUMBER "SDL.window.create.x11.window" +#define SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_CANVAS_ID_STRING "SDL.window.create.emscripten.canvas_id" +#define SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING "SDL.window.create.emscripten.keyboard_element" /** * Get the numeric ID of a window. @@ -1460,12 +1553,12 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowParent(SDL_Window *window) * - `SDL_PROP_WINDOW_COCOA_WINDOW_POINTER`: the `(__unsafe_unretained)` * NSWindow associated with the window * - `SDL_PROP_WINDOW_COCOA_METAL_VIEW_TAG_NUMBER`: the NSInteger tag - * assocated with metal views on the window + * associated with metal views on the window * * On OpenVR: * - * - `SDL_PROP_WINDOW_OPENVR_OVERLAY_ID`: the OpenVR Overlay Handle ID for the - * associated overlay window. + * - `SDL_PROP_WINDOW_OPENVR_OVERLAY_ID_NUMBER`: the OpenVR Overlay Handle ID + * for the associated overlay window. * * On Vivante: * @@ -1517,6 +1610,13 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowParent(SDL_Window *window) * - `SDL_PROP_WINDOW_X11_WINDOW_NUMBER`: the X11 Window associated with the * window * + * On Emscripten: + * + * - `SDL_PROP_WINDOW_EMSCRIPTEN_CANVAS_ID_STRING`: the id the canvas element + * will have + * - `SDL_PROP_WINDOW_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING`: the keyboard + * element that associates keyboard events to this window + * * \param window the window to query. * \returns a valid property ID on success or 0 on failure; call * SDL_GetError() for more information. @@ -1543,7 +1643,7 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetWindowProperties(SDL_Window #define SDL_PROP_WINDOW_KMSDRM_GBM_DEVICE_POINTER "SDL.window.kmsdrm.gbm_dev" #define SDL_PROP_WINDOW_COCOA_WINDOW_POINTER "SDL.window.cocoa.window" #define SDL_PROP_WINDOW_COCOA_METAL_VIEW_TAG_NUMBER "SDL.window.cocoa.metal_view_tag" -#define SDL_PROP_WINDOW_OPENVR_OVERLAY_ID "SDL.window.openvr.overlay_id" +#define SDL_PROP_WINDOW_OPENVR_OVERLAY_ID_NUMBER "SDL.window.openvr.overlay_id" #define SDL_PROP_WINDOW_VIVANTE_DISPLAY_POINTER "SDL.window.vivante.display" #define SDL_PROP_WINDOW_VIVANTE_WINDOW_POINTER "SDL.window.vivante.window" #define SDL_PROP_WINDOW_VIVANTE_SURFACE_POINTER "SDL.window.vivante.surface" @@ -1562,6 +1662,8 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetWindowProperties(SDL_Window #define SDL_PROP_WINDOW_X11_DISPLAY_POINTER "SDL.window.x11.display" #define SDL_PROP_WINDOW_X11_SCREEN_NUMBER "SDL.window.x11.screen" #define SDL_PROP_WINDOW_X11_WINDOW_NUMBER "SDL.window.x11.window" +#define SDL_PROP_WINDOW_EMSCRIPTEN_CANVAS_ID_STRING "SDL.window.emscripten.canvas_id" +#define SDL_PROP_WINDOW_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING "SDL.window.emscripten.keyboard_element" /** * Get the window flags. @@ -1579,6 +1681,7 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetWindowProperties(SDL_Window * \sa SDL_MinimizeWindow * \sa SDL_SetWindowFullscreen * \sa SDL_SetWindowMouseGrab + * \sa SDL_SetWindowFillDocument * \sa SDL_ShowWindow */ extern SDL_DECLSPEC SDL_WindowFlags SDLCALL SDL_GetWindowFlags(SDL_Window *window); @@ -1619,15 +1722,16 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetWindowTitle(SDL_Window *window); /** * Set the icon for a window. * - * If this function is passed a surface with alternate representations, the - * surface will be interpreted as the content to be used for 100% display - * scale, and the alternate representations will be used for high DPI - * situations. For example, if the original surface is 32x32, then on a 2x - * macOS display or 200% display scale on Windows, a 64x64 version of the - * image will be used, if available. If a matching version of the image isn't - * available, the closest larger size image will be downscaled to the - * appropriate size and be used instead, if available. Otherwise, the closest - * smaller image will be upscaled and be used instead. + * If this function is passed a surface with alternate representations added + * using SDL_AddSurfaceAlternateImage(), the surface will be interpreted as + * the content to be used for 100% display scale, and the alternate + * representations will be used for high DPI situations. For example, if the + * original surface is 32x32, then on a 2x macOS display or 200% display scale + * on Windows, a 64x64 version of the image will be used, if available. If a + * matching version of the image isn't available, the closest larger size + * image will be downscaled to the appropriate size and be used instead, if + * available. Otherwise, the closest smaller image will be upscaled and be + * used instead. * * \param window the window to change. * \param icon an SDL_Surface structure containing the icon for the window. @@ -1637,6 +1741,8 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetWindowTitle(SDL_Window *window); * \threadsafety This function should only be called on the main thread. * * \since This function is available since SDL 3.2.0. + * + * \sa SDL_AddSurfaceAlternateImage */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon); @@ -1763,6 +1869,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, in * \sa SDL_GetRenderOutputSize * \sa SDL_GetWindowSizeInPixels * \sa SDL_SetWindowSize + * \sa SDL_EVENT_WINDOW_RESIZED */ extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h); @@ -1774,7 +1881,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, i * notches, TV overscan, etc. This function provides the area of the window * which is safe to have interactable content. You should continue rendering * into the rest of the window, but it should not contain visually important - * or interactible content. + * or interactable content. * * \param window the window to query. * \param rect a pointer filled in with the client area that is safe for @@ -1830,7 +1937,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowSafeArea(SDL_Window *window, SDL_R extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowAspectRatio(SDL_Window *window, float min_aspect, float max_aspect); /** - * Get the size of a window's client area. + * Get the aspect ratio of a window's client area. * * \param window the window to query the width and height from. * \param min_aspect a pointer filled in with the minimum aspect ratio of the @@ -2044,6 +2151,37 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowResizable(SDL_Window *window, bool */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window *window, bool on_top); +/** + * Set the window to fill the current document space (Emscripten only). + * + * This will add or remove the window's `SDL_WINDOW_FILL_DOCUMENT` flag. + * + * Currently this flag only applies to the Emscripten target. + * + * When enabled, the canvas element fills the entire document. Resize events + * will be generated as the browser window is resized, as that will adjust the + * canvas size as well. The canvas will cover anything else on the page, + * including any controls provided by Emscripten in its generated HTML file + * (in fact, any elements on the page that aren't the canvas will be moved + * into a hidden `div` element). + * + * Often times this is desirable for a browser-based game, but it means + * several things that we expect of an SDL window on other platforms might not + * work as expected, such as minimum window sizes and aspect ratios. + * + * \param window the window of which to change the fill-document state. + * \param fill true to set the window to fill the document, false to disable. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + * + * \sa SDL_GetWindowFlags + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowFillDocument(SDL_Window *window, bool fill); + /** * Show a window. * @@ -2457,7 +2595,6 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, b * * \sa SDL_GetWindowMouseRect * \sa SDL_SetWindowMouseRect - * \sa SDL_SetWindowMouseGrab * \sa SDL_SetWindowKeyboardGrab */ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowMouseGrab(SDL_Window *window, bool grabbed); @@ -2802,6 +2939,62 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowShape(SDL_Window *window, SDL_Surf */ extern SDL_DECLSPEC bool SDLCALL SDL_FlashWindow(SDL_Window *window, SDL_FlashOperation operation); +/** + * Sets the state of the progress bar for the given window’s taskbar icon. + * + * \param window the window whose progress state is to be modified. + * \param state the progress state. `SDL_PROGRESS_STATE_NONE` stops displaying + * the progress bar. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowProgressState(SDL_Window *window, SDL_ProgressState state); + +/** + * Get the state of the progress bar for the given window’s taskbar icon. + * + * \param window the window to get the current progress state from. + * \returns the progress state, or `SDL_PROGRESS_STATE_INVALID` on failure; + * call SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC SDL_ProgressState SDLCALL SDL_GetWindowProgressState(SDL_Window *window); + +/** + * Sets the value of the progress bar for the given window’s taskbar icon. + * + * \param window the window whose progress value is to be modified. + * \param value the progress value in the range of [0.0f - 1.0f]. If the value + * is outside the valid range, it gets clamped. + * \returns true on success or false on failure; call SDL_GetError() for more + * information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowProgressValue(SDL_Window *window, float value); + +/** + * Get the value of the progress bar for the given window’s taskbar icon. + * + * \param window the window to get the current progress value from. + * \returns the progress value in the range of [0.0f - 1.0f], or -1.0f on + * failure; call SDL_GetError() for more information. + * + * \threadsafety This function should only be called on the main thread. + * + * \since This function is available since SDL 3.4.0. + */ +extern SDL_DECLSPEC float SDLCALL SDL_GetWindowProgressValue(SDL_Window *window); + /** * Destroy a window. * @@ -3037,8 +3230,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void); * SDL_GL_GetAttribute() to check the values after creating the OpenGL * context, since the values obtained can differ from the requested ones. * - * \param attr an SDL_GLAttr enum value specifying the OpenGL attribute to - * set. + * \param attr an enum value specifying the OpenGL attribute to set. * \param value the desired value for the attribute. * \returns true on success or false on failure; call SDL_GetError() for more * information. @@ -3047,6 +3239,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void); * * \since This function is available since SDL 3.2.0. * + * \sa SDL_GL_CreateContext * \sa SDL_GL_GetAttribute * \sa SDL_GL_ResetAttributes */ @@ -3073,6 +3266,12 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GL_GetAttribute(SDL_GLAttr attr, int *value /** * Create an OpenGL context for an OpenGL window, and make it current. * + * The OpenGL context will be created with the current states set through + * SDL_GL_SetAttribute(). + * + * The SDL_Window specified must have been created with the SDL_WINDOW_OPENGL + * flag, or context creation will fail. + * * Windows users new to OpenGL should note that, for historical reasons, GL * functions added after OpenGL version 1.1 are not available by default. * Those functions must be loaded at run-time, either with an OpenGL diff --git a/vendor/sdl3/include/SDL_vulkan.h b/vendor/sdl3/include/SDL_vulkan.h index 710afbe63..e91e14842 100644 --- a/vendor/sdl3/include/SDL_vulkan.h +++ b/vendor/sdl3/include/SDL_vulkan.h @@ -51,14 +51,14 @@ extern "C" { #endif -/* Avoid including vulkan.h, don't define VkInstance if it's already included */ -#ifdef VULKAN_H_ +/* Avoid including vulkan_core.h, don't define VkInstance if it's already included */ +#ifdef VULKAN_CORE_H_ #define NO_SDL_VULKAN_TYPEDEFS #endif #ifndef NO_SDL_VULKAN_TYPEDEFS #define VK_DEFINE_HANDLE(object) typedef struct object##_T* object; -#if defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) +#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) || (defined(__riscv) && __riscv_xlen == 64) #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object; #else #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object; diff --git a/vendor/sdl3/sdl3_atomic.odin b/vendor/sdl3/sdl3_atomic.odin index 178a44a5b..fefe8c861 100644 --- a/vendor/sdl3/sdl3_atomic.odin +++ b/vendor/sdl3/sdl3_atomic.odin @@ -36,7 +36,8 @@ foreign lib { CompareAndSwapAtomicU32 :: proc(a: ^AtomicU32, oldval, newval: Uint32) -> bool --- SetAtomicU32 :: proc(a: ^AtomicU32, v: Uint32) -> Uint32 --- GetAtomicU32 :: proc(a: ^AtomicU32) -> Uint32 --- + AddAtomicU32 :: proc(a: ^AtomicU32) -> Uint32 --- CompareAndSwapAtomicPointer :: proc(a: ^rawptr, oldval, newval: rawptr) -> bool --- SetAtomicPointer :: proc(a: ^rawptr, v: rawptr) -> rawptr --- GetAtomicPointer :: proc(a: ^rawptr) -> rawptr --- -} \ No newline at end of file +} diff --git a/vendor/sdl3/sdl3_audio.odin b/vendor/sdl3/sdl3_audio.odin index 045f4780e..277aefde7 100644 --- a/vendor/sdl3/sdl3_audio.odin +++ b/vendor/sdl3/sdl3_audio.odin @@ -67,8 +67,11 @@ AUDIO_FRAMESIZE :: proc "c" (x: AudioSpec) -> c.int { AudioStream :: struct {} -AudioStreamCallback :: #type proc "c" (userdata: rawptr, stream: ^AudioStream, additional_amount, total_amount: c.int) -AudioPostmixCallback :: #type proc "c" (userdata: rawptr, spec: ^AudioSpec, buffer: [^]f32, buflen: c.int) +AudioStreamCallback :: #type proc "c" (userdata: rawptr, stream: ^AudioStream, additional_amount, total_amount: c.int) +AudioStreamDataCompleteCallback :: #type proc "c" (userdata: rawptr, buf: rawptr, buflen: c.int) +AudioPostmixCallback :: #type proc "c" (userdata: rawptr, spec: ^AudioSpec, buffer: [^]f32, buflen: c.int) + +AUDIOSTREAM_AUTO_CLEANUP_BOOLEAN :: "SDL.audiostream.auto_cleanup" @(default_calling_convention="c", link_prefix="SDL_") foreign lib { @@ -107,6 +110,8 @@ foreign lib { SetAudioStreamInputChannelMap :: proc(stream: ^AudioStream, chmap: [^]c.int, count: c.int) -> bool --- SetAudioStreamOutputChannelMap :: proc(stream: ^AudioStream, chmap: [^]c.int, count: c.int) -> bool --- PutAudioStreamData :: proc(stream: ^AudioStream, buf: rawptr, len: c.int) -> bool --- + PutAudioStreamDataNoCopy :: proc(stream: ^AudioStream, buf: rawptr, len: c.int, callback: AudioStreamDataCompleteCallback, userdata: rawptr) -> bool --- + PutAudioStreamPlanarData :: proc(stream: ^AudioStream, channel_buffers: [^]rawptr, num_channels, num_samples: c.int) -> bool --- GetAudioStreamData :: proc(stream: ^AudioStream, buf: rawptr, len: c.int) -> c.int --- GetAudioStreamAvailable :: proc(stream: ^AudioStream) -> c.int --- GetAudioStreamQueued :: proc(stream: ^AudioStream) -> c.int --- @@ -128,4 +133,4 @@ foreign lib { ConvertAudioSamples :: proc(src_spec: ^AudioSpec, src_data: [^]Uint8, src_len: c.int, dst_spec: ^AudioSpec, dst_data: ^[^]Uint8, dst_len: ^c.int) -> bool --- GetAudioFormatName :: proc(format: AudioFormat) -> cstring --- GetSilenceValueForFormat :: proc(format: AudioFormat) -> c.int --- -} \ No newline at end of file +} diff --git a/vendor/sdl3/sdl3_camera.odin b/vendor/sdl3/sdl3_camera.odin index 7d46bd2bd..a6a895245 100644 --- a/vendor/sdl3/sdl3_camera.odin +++ b/vendor/sdl3/sdl3_camera.odin @@ -21,6 +21,12 @@ CameraPosition :: enum c.int { BACK_FACING, } +CameraPermissionState :: enum c.int { + DENIED = -1, + PENDING, + APPROVED, +} + @(default_calling_convention="c", link_prefix="SDL_") foreign lib { GetNumCameraDrivers :: proc() -> c.int --- @@ -31,11 +37,11 @@ foreign lib { GetCameraName :: proc(instance_id: CameraID) -> cstring --- GetCameraPosition :: proc(instance_id: CameraID) -> CameraPosition --- OpenCamera :: proc(instance_id: CameraID, spec: ^CameraSpec) -> ^Camera --- - GetCameraPermissionState :: proc(camera: ^Camera) -> c.int --- + GetCameraPermissionState :: proc(camera: ^Camera) -> CameraPermissionState --- GetCameraID :: proc(camera: ^Camera) -> CameraID --- GetCameraProperties :: proc(camera: ^Camera) -> PropertiesID --- GetCameraFormat :: proc(camera: ^Camera, spec: ^CameraSpec) -> bool --- AcquireCameraFrame :: proc(camera: ^Camera, timestampNS: ^Uint64) -> ^Surface --- ReleaseCameraFrame :: proc(camera: ^Camera, frame: ^Surface) --- CloseCamera :: proc(camera: ^Camera) --- -} \ No newline at end of file +} diff --git a/vendor/sdl3/sdl3_cpuinfo.odin b/vendor/sdl3/sdl3_cpuinfo.odin index 959286c71..a97a5a324 100644 --- a/vendor/sdl3/sdl3_cpuinfo.odin +++ b/vendor/sdl3/sdl3_cpuinfo.odin @@ -24,4 +24,5 @@ foreign lib { HasLASX :: proc() -> bool --- GetSystemRAM :: proc() -> c.int --- GetSIMDAlignment :: proc() -> uint --- -} \ No newline at end of file + GetSystemPageSize :: proc() -> c.int --- +} diff --git a/vendor/sdl3/sdl3_events.odin b/vendor/sdl3/sdl3_events.odin index 999fe58b7..7e871156e 100644 --- a/vendor/sdl3/sdl3_events.odin +++ b/vendor/sdl3/sdl3_events.odin @@ -46,9 +46,10 @@ EventType :: enum Uint32 { DISPLAY_MOVED, /**< Display has changed position */ DISPLAY_DESKTOP_MODE_CHANGED, /**< Display has changed desktop mode */ DISPLAY_CURRENT_MODE_CHANGED, /**< Display has changed current mode */ - DISPLAY_CONTENT_SCALE_CHANGED, /**< Display has changed content scale */ + DISPLAY_CONTENT_SCALE_CHANGED, /**< Display has changed usable bounds */ + DISPLAY_USABLE_BOUNDS_CHANGED, DISPLAY_FIRST = DISPLAY_ORIENTATION, - DISPLAY_LAST = DISPLAY_CONTENT_SCALE_CHANGED, + DISPLAY_LAST = DISPLAY_USABLE_BOUNDS_CHANGED, /* Window events */ /* 0x200 was SDL_WINDOWEVENT, reserve the number for sdl2-compat */ @@ -94,6 +95,8 @@ EventType :: enum Uint32 { KEYBOARD_ADDED, /**< A new keyboard has been inserted into the system */ KEYBOARD_REMOVED, /**< A keyboard has been removed */ TEXT_EDITING_CANDIDATES, /**< Keyboard text editing candidates */ + SCREEN_KEYBOARD_SHOWN, /**< The on-screen keyboard has been shown */ + SCREEN_KEYBOARD_HIDDEN, /**< The on-screen keyboard has been hidden */ /* Mouse events */ MOUSE_MOTION = 0x400, /**< Mouse moved */ @@ -134,10 +137,15 @@ EventType :: enum Uint32 { FINGER_MOTION, FINGER_CANCELED, + /* Pinch events */ + PINCH_BEGIN = 0x710, /**< Pinch gesture started */ + PINCH_UPDATE, /**< Pinch gesture updated */ + PINCH_END, /**< Pinch gesture ended */ + /* 0x800, 0x801, and 0x802 were the Gesture events from SDL2. Do not reuse these values! sdl2-compat needs them! */ /* Clipboard events */ - CLIPBOARD_UPDATE = 0x900, /**< The clipboard or primary selection changed */ + CLIPBOARD_UPDATE = 0x900, /**< The clipboard changed */ /* Drag and drop events */ DROP_FILE = 0x1000, /**< The system requests a file open */ @@ -431,6 +439,12 @@ TouchFingerEvent :: struct { windowID: WindowID, /**< The window underneath the finger, if any */ } +PinchFingerEvent :: struct { + using commonEvent: CommonEvent, + scale: f32, /**< The scale change since the last SDL_EVENT_PINCH_UPDATE. Scale < 1 is "zoom out". Scale > 1 is "zoom in". */ + windowID: WindowID, /**< The window underneath the finger, if any */ +} + PenProximityEvent :: struct { using commonEvent: CommonEvent, /**< SDL_EVENT_PEN_PROXIMITY_IN or SDL_EVENT_PEN_PROXIMITY_OUT */ windowID: WindowID, /**< The window with pen focus, if any */ @@ -508,7 +522,7 @@ QuitEvent :: struct { } UserEvent :: struct { - using commonEvent: CommonEvent, /**< SDL_EVENT_USER through SDL_EVENT_LAST-1, Uint32 because these are not in the SDL_EventType enumeration */ + using commonEvent: CommonEvent, /**< SDL_EVENT_USER through SDL_EVENT_LAST, Uint32 because these are not in the SDL_EventType enumeration */ windowID: WindowID, /**< The associated window if any */ code: Sint32, /**< User defined event code */ data1: rawptr, /**< User defined data pointer */ @@ -579,6 +593,8 @@ Event :: struct #raw_union { user: UserEvent `raw_union_tag:"type=USER"`, /**< Touch finger event data */ tfinger: TouchFingerEvent `raw_union_tag:"type=FINGER_DOWN,FINGER_UP,FINGER_MOTION,FINGER_CANCELED"`, + /**< Pinch event data */ + pinch: PinchFingerEvent `raw_union_tag:"type=PINCH_BEGIN,PINCH_UPDATE,PINCH_END"`, /**< Pen proximity event data */ pproximity: PenProximityEvent `raw_union_tag:"type=PEN_PROXIMITY_IN,PEN_PROXIMITY_OUT"`, /**< Pen tip touching event data */ @@ -626,23 +642,24 @@ EventFilter :: proc "c" (userdata: rawptr, event: ^Event) -> bool @(default_calling_convention="c", link_prefix="SDL_", require_results) foreign lib { - PumpEvents :: proc() --- - PeepEvents :: proc(events: [^]Event, numevents: c.int, action: EventAction, minType, maxType: EventType) -> int --- - HasEvent :: proc(type: EventType) -> bool --- - HasEvents :: proc(minType, maxType: EventType) -> bool --- - FlushEvent :: proc(type: EventType) --- - FlushEvents :: proc(minType, maxType: EventType) --- - PollEvent :: proc(event: ^Event) -> bool --- - WaitEvent :: proc(event: ^Event) -> bool --- - WaitEventTimeout :: proc(event: ^Event, timeoutMS: Sint32) -> bool --- - PushEvent :: proc(event: ^Event) -> bool --- - SetEventFilter :: proc(filter: EventFilter, userdata: rawptr) --- - GetEventFilter :: proc(filter: ^EventFilter, userdata: ^rawptr) -> bool --- - AddEventWatch :: proc(filter: EventFilter, userdata: rawptr) -> bool --- - RemoveEventWatch :: proc(filter: EventFilter, userdata: rawptr) --- - FilterEvents :: proc(filter: EventFilter, userdata: rawptr) --- - SetEventEnabled :: proc(type: EventType, enabled: bool) --- - EventEnabled :: proc(type: EventType) -> bool --- - RegisterEvents :: proc(numevents: c.int) -> Uint32 --- - GetWindowFromEvent :: proc(#by_ptr event: Event) -> ^Window --- -} \ No newline at end of file + PumpEvents :: proc() --- + PeepEvents :: proc(events: [^]Event, numevents: c.int, action: EventAction, minType, maxType: EventType) -> int --- + HasEvent :: proc(type: EventType) -> bool --- + HasEvents :: proc(minType, maxType: EventType) -> bool --- + FlushEvent :: proc(type: EventType) --- + FlushEvents :: proc(minType, maxType: EventType) --- + PollEvent :: proc(event: ^Event) -> bool --- + WaitEvent :: proc(event: ^Event) -> bool --- + WaitEventTimeout :: proc(event: ^Event, timeoutMS: Sint32) -> bool --- + PushEvent :: proc(event: ^Event) -> bool --- + SetEventFilter :: proc(filter: EventFilter, userdata: rawptr) --- + GetEventFilter :: proc(filter: ^EventFilter, userdata: ^rawptr) -> bool --- + AddEventWatch :: proc(filter: EventFilter, userdata: rawptr) -> bool --- + RemoveEventWatch :: proc(filter: EventFilter, userdata: rawptr) --- + FilterEvents :: proc(filter: EventFilter, userdata: rawptr) --- + SetEventEnabled :: proc(type: EventType, enabled: bool) --- + EventEnabled :: proc(type: EventType) -> bool --- + RegisterEvents :: proc(numevents: c.int) -> Uint32 --- + GetWindowFromEvent :: proc(#by_ptr event: Event) -> ^Window --- + GetEventDescription :: proc(#by_ptr event: Event, buf: [^]u8, buflen: c.int) -> c.int --- +} diff --git a/vendor/sdl3/sdl3_gpu.odin b/vendor/sdl3/sdl3_gpu.odin index def222739..551b23947 100644 --- a/vendor/sdl3/sdl3_gpu.odin +++ b/vendor/sdl3/sdl3_gpu.odin @@ -624,10 +624,10 @@ GPURasterizerState :: struct { GPUMultisampleState :: struct { - sample_count: GPUSampleCount, /**< The number of samples to be used in rasterization. */ - sample_mask: Uint32, /**< Reserved for future use. Must be set to 0. */ - enable_mask: bool, /**< Reserved for future use. Must be set to false. */ - _: Uint8, + sample_count: GPUSampleCount, /**< The number of samples to be used in rasterization. */ + sample_mask: Uint32, /**< Reserved for future use. Must be set to 0. */ + enable_mask: bool, /**< Reserved for future use. Must be set to false. */ + enable_alpha_to_coverage: bool, /**< true enables the alpha-to-coverage feature. */ _: Uint8, _: Uint8, } @@ -718,8 +718,8 @@ GPUDepthStencilTargetInfo :: struct { stencil_store_op: GPUStoreOp, /**< What is done with the stencil results of the render pass. */ cycle: bool, /**< true cycles the texture if the texture is bound and any load ops are not LOAD */ clear_stencil: Uint8, /**< The value to clear the stencil component to at the beginning of the render pass. Ignored if GPU_LOADOP_CLEAR is not used. */ - _: Uint8, - _: Uint8, + mip_level: Uint8, /**< The mip level to use as the depth stencil target. */ + layer: Uint8, /**< The layer index to use as the depth stencil target. */ } @@ -765,16 +765,34 @@ GPUStorageTextureReadWriteBinding :: struct { } -PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOLEAN :: "SDL.gpu.device.create.debugmode" -PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEAN :: "SDL.gpu.device.create.preferlowpower" -PROP_GPU_DEVICE_CREATE_NAME_STRING :: "SDL.gpu.device.create.name" -PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOLEAN :: "SDL.gpu.device.create.shaders.private" -PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOLEAN :: "SDL.gpu.device.create.shaders.spirv" -PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOLEAN :: "SDL.gpu.device.create.shaders.dxbc" -PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOLEAN :: "SDL.gpu.device.create.shaders.dxil" -PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOLEAN :: "SDL.gpu.device.create.shaders.msl" -PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN :: "SDL.gpu.device.create.shaders.metallib" -PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING :: "SDL.gpu.device.create.d3d12.semantic" +PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOLEAN :: "SDL.gpu.device.create.debugmode" +PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEAN :: "SDL.gpu.device.create.preferlowpower" +PROP_GPU_DEVICE_CREATE_VERBOSE_BOOLEAN :: "SDL.gpu.device.create.verbose" +PROP_GPU_DEVICE_CREATE_NAME_STRING :: "SDL.gpu.device.create.name" +PROP_GPU_DEVICE_CREATE_FEATURE_CLIP_DISTANCE_BOOLEAN :: "SDL.gpu.device.create.feature.clip_distance" +PROP_GPU_DEVICE_CREATE_FEATURE_DEPTH_CLAMPING_BOOLEAN :: "SDL.gpu.device.create.feature.depth_clamping" +PROP_GPU_DEVICE_CREATE_FEATURE_INDIRECT_DRAW_FIRST_INSTANCE_BOOLEAN :: "SDL.gpu.device.create.feature.indirect_draw_first_instance" +PROP_GPU_DEVICE_CREATE_FEATURE_ANISOTROPY_BOOLEAN :: "SDL.gpu.device.create.feature.anisotropy" +PROP_GPU_DEVICE_CREATE_SHADERS_PRIVATE_BOOLEAN :: "SDL.gpu.device.create.shaders.private" +PROP_GPU_DEVICE_CREATE_SHADERS_SPIRV_BOOLEAN :: "SDL.gpu.device.create.shaders.spirv" +PROP_GPU_DEVICE_CREATE_SHADERS_DXBC_BOOLEAN :: "SDL.gpu.device.create.shaders.dxbc" +PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOLEAN :: "SDL.gpu.device.create.shaders.dxil" +PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOLEAN :: "SDL.gpu.device.create.shaders.msl" +PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN :: "SDL.gpu.device.create.shaders.metallib" +PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN :: "SDL.gpu.device.create.d3d12.allowtier1resourcebinding" +PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING :: "SDL.gpu.device.create.d3d12.semantic" +PROP_GPU_DEVICE_CREATE_VULKAN_REQUIRE_HARDWARE_ACCELERATION_BOOLEAN :: "SDL.gpu.device.create.vulkan.requirehardwareacceleration" +PROP_GPU_DEVICE_CREATE_VULKAN_OPTIONS_POINTER :: "SDL.gpu.device.create.vulkan.options" + +GPUVulkanOptions :: struct { + vulkan_api_version: Uint32, /**< The Vulkan API version to request for the instance. Use Vulkan's VK_MAKE_VERSION or VK_MAKE_API_VERSION. */ + feature_list: rawptr, /**< Pointer to the first element of a chain of Vulkan feature structs. (Requires API version 1.1 or higher.)*/ + vulkan_10_physical_device_features: rawptr, /**< Pointer to a VkPhysicalDeviceFeatures struct to enable additional Vulkan 1.0 features. */ + device_extension_count: Uint32, /**< Number of additional device extensions to require. */ + device_extension_names: [^]cstring, /**< Pointer to a list of additional device extensions to require. */ + instance_extension_count: Uint32, /**< Number of additional instance extensions to require. */ + instance_extension_names: [^]cstring, /**< Pointer to a list of additional instance extensions to require. */ +} PROP_GPU_COMPUTEPIPELINE_CREATE_NAME_STRING :: "SDL.gpu.computepipeline.create.name" PROP_GPU_GRAPHICSPIPELINE_CREATE_NAME_STRING :: "SDL.gpu.graphicspipeline.create.name" @@ -790,6 +808,11 @@ PROP_GPU_TEXTURE_CREATE_NAME_STRING :: "SDL.gpu.texture.create.na PROP_GPU_BUFFER_CREATE_NAME_STRING :: "SDL.gpu.buffer.create.name" PROP_GPU_TRANSFERBUFFER_CREATE_NAME_STRING :: "SDL.gpu.transferbuffer.create.name" +PROP_GPU_DEVICE_NAME_STRING :: "SDL.gpu.device.name" +PROP_GPU_DEVICE_DRIVER_NAME_STRING :: "SDL.gpu.device.driver_name" +PROP_GPU_DEVICE_DRIVER_VERSION_STRING :: "SDL.gpu.device.driver_version" +PROP_GPU_DEVICE_DRIVER_INFO_STRING :: "SDL.gpu.device.driver_info" + @(default_calling_convention="c", link_prefix="SDL_", require_results) foreign lib { GPUSupportsShaderFormats :: proc(format_flags: GPUShaderFormat, name: cstring) -> bool --- @@ -801,6 +824,7 @@ foreign lib { GetGPUDriver :: proc(index: c.int) -> cstring --- GetGPUDeviceDriver :: proc(device: ^GPUDevice) -> cstring --- GetGPUShaderFormats :: proc(device: ^GPUDevice) -> GPUShaderFormat --- + GetGPUDeviceProperties :: proc(device: ^GPUDevice) -> PropertiesID --- CreateGPUComputePipeline :: proc(device: ^GPUDevice, #by_ptr createinfo: GPUComputePipelineCreateInfo) -> ^GPUComputePipeline --- CreateGPUGraphicsPipeline :: proc(device: ^GPUDevice, #by_ptr createinfo: GPUGraphicsPipelineCreateInfo) -> ^GPUGraphicsPipeline --- CreateGPUSampler :: proc(device: ^GPUDevice, #by_ptr createinfo: GPUSamplerCreateInfo) -> ^GPUSampler --- @@ -884,6 +908,8 @@ foreign lib { GPUTextureSupportsFormat :: proc(device: ^GPUDevice, format: GPUTextureFormat, type: GPUTextureType, usage: GPUTextureUsageFlags) -> bool --- GPUTextureSupportsSampleCount :: proc(device: ^GPUDevice, format: GPUTextureFormat, sample_count: GPUSampleCount) -> bool --- CalculateGPUTextureFormatSize :: proc(format: GPUTextureFormat, width, height: Uint32, depth_or_layer_count: Uint32) -> Uint32 --- + GetPixelFormatFromGPUTextureFormat :: proc(format: GPUTextureFormat) -> PixelFormat --- + GetGPUTextureFormatFromPixelFormat :: proc(format: PixelFormat) -> GPUTextureFormat --- } diff --git a/vendor/sdl3/sdl3_haptic.odin b/vendor/sdl3/sdl3_haptic.odin index d5efadcf3..adf055ee6 100644 --- a/vendor/sdl3/sdl3_haptic.odin +++ b/vendor/sdl3/sdl3_haptic.odin @@ -5,6 +5,7 @@ import "core:c" Haptic :: struct {} HapticType :: Uint16 +HapticEffectId :: c.int HAPTIC_CONSTANT :: 1<<0 HAPTIC_SINE :: 1<<1 @@ -215,12 +216,12 @@ foreign lib { GetHapticFeatures :: proc(haptic: ^Haptic) -> Uint32 --- GetNumHapticAxes :: proc(haptic: ^Haptic) -> c.int --- HapticEffectSupported :: proc(haptic: ^Haptic, #by_ptr effect: HapticEffect) -> bool --- - CreateHapticEffect :: proc(haptic: ^Haptic, #by_ptr effect: HapticEffect) -> c.int --- - UpdateHapticEffect :: proc(haptic: ^Haptic, effect: c.int, #by_ptr data: HapticEffect) -> bool --- - RunHapticEffect :: proc(haptic: ^Haptic, effect: c.int, iterations: Uint32) -> bool --- - StopHapticEffect :: proc(haptic: ^Haptic, effect: c.int) -> bool --- - DestroyHapticEffect :: proc(haptic: ^Haptic, effect: c.int) --- - GetHapticEffectStatus :: proc(haptic: ^Haptic, effect: c.int) -> bool --- + CreateHapticEffect :: proc(haptic: ^Haptic, #by_ptr effect: HapticEffect) -> HapticEffectId --- + UpdateHapticEffect :: proc(haptic: ^Haptic, effect: HapticEffectId, #by_ptr data: HapticEffect) -> bool --- + RunHapticEffect :: proc(haptic: ^Haptic, effect: HapticEffectId, iterations: Uint32) -> bool --- + StopHapticEffect :: proc(haptic: ^Haptic, effect: HapticEffectId) -> bool --- + DestroyHapticEffect :: proc(haptic: ^Haptic, effect: HapticEffectId) --- + GetHapticEffectStatus :: proc(haptic: ^Haptic, effect: HapticEffectId) -> bool --- SetHapticGain :: proc(haptic: ^Haptic, gain: c.int) -> bool --- SetHapticAutocenter :: proc(haptic: ^Haptic, autocenter: c.int) -> bool --- PauseHaptic :: proc(haptic: ^Haptic) -> bool --- @@ -230,4 +231,4 @@ foreign lib { InitHapticRumble :: proc(haptic: ^Haptic) -> bool --- PlayHapticRumble :: proc(haptic: ^Haptic, strength: f32, length: Uint32) -> bool --- StopHapticRumble :: proc(haptic: ^Haptic) -> bool --- -} \ No newline at end of file +} diff --git a/vendor/sdl3/sdl3_hidapi.odin b/vendor/sdl3/sdl3_hidapi.odin index 6817bffa2..71286cb3d 100644 --- a/vendor/sdl3/sdl3_hidapi.odin +++ b/vendor/sdl3/sdl3_hidapi.odin @@ -75,6 +75,7 @@ hid_device_info :: struct { next: ^hid_device_info, } +PROP_HIDAPI_LIBUSB_DEVICE_HANDLE_POINTER :: "SDL.hidapi.libusb.device.handle" @(default_calling_convention="c", link_prefix="SDL_", require_results) foreign lib { @@ -85,6 +86,7 @@ foreign lib { hid_free_enumeration :: proc(devs: ^hid_device_info) --- hid_open :: proc(vendor_id, product_id: c.ushort, serial_number: [^]c.wchar_t) -> ^hid_device --- hid_open_path :: proc(path: cstring) -> ^hid_device --- + hid_get_properties :: proc(dev: ^hid_device) -> PropertiesID --- hid_write :: proc(dev: ^hid_device, data: [^]byte, length: uint) -> c.int --- hid_read_timeout :: proc(dev: ^hid_device, data: [^]byte, length: uint, milliseconds: c.int) -> c.int --- hid_read :: proc(dev: ^hid_device, data: [^]byte, length: uint) -> c.int --- @@ -100,4 +102,4 @@ foreign lib { hid_get_device_info :: proc(dev: ^hid_device) -> ^hid_device_info --- hid_get_report_descriptor :: proc(dev: ^hid_device, buf: [^]byte, buf_size: uint) -> c.int --- hid_ble_scan :: proc(active: bool) --- -} \ No newline at end of file +} diff --git a/vendor/sdl3/sdl3_hints.odin b/vendor/sdl3/sdl3_hints.odin index 987010c57..8ef09295e 100644 --- a/vendor/sdl3/sdl3_hints.odin +++ b/vendor/sdl3/sdl3_hints.odin @@ -95,9 +95,15 @@ HINT_JOYSTICK_HIDAPI_STEAM :: "SDL_JOYSTICK_HIDAPI_STEAM" HINT_JOYSTICK_HIDAPI_STEAM_HOME_LED :: "SDL_JOYSTICK_HIDAPI_STEAM_HOME_LED" HINT_JOYSTICK_HIDAPI_STEAMDECK :: "SDL_JOYSTICK_HIDAPI_STEAMDECK" HINT_JOYSTICK_HIDAPI_STEAM_HORI :: "SDL_JOYSTICK_HIDAPI_STEAM_HORI" +HINT_JOYSTICK_HIDAPI_LG4FF :: "SDL_JOYSTICK_HIDAPI_LG4FF" +HINT_JOYSTICK_HIDAPI_8BITDO :: "SDL_JOYSTICK_HIDAPI_8BITDO" +HINT_JOYSTICK_HIDAPI_SINPUT :: "SDL_JOYSTICK_HIDAPI_SINPUT" +HINT_JOYSTICK_HIDAPI_ZUIKI :: "SDL_JOYSTICK_HIDAPI_ZUIKI" +HINT_JOYSTICK_HIDAPI_FLYDIGI :: "SDL_JOYSTICK_HIDAPI_FLYDIGI" HINT_JOYSTICK_HIDAPI_SWITCH :: "SDL_JOYSTICK_HIDAPI_SWITCH" HINT_JOYSTICK_HIDAPI_SWITCH_HOME_LED :: "SDL_JOYSTICK_HIDAPI_SWITCH_HOME_LED" HINT_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED :: "SDL_JOYSTICK_HIDAPI_SWITCH_PLAYER_LED" +HINT_JOYSTICK_HIDAPI_SWITCH2 :: "SDL_JOYSTICK_HIDAPI_SWITCH2" HINT_JOYSTICK_HIDAPI_VERTICAL_JOY_CONS :: "SDL_JOYSTICK_HIDAPI_VERTICAL_JOY_CONS" HINT_JOYSTICK_HIDAPI_WII :: "SDL_JOYSTICK_HIDAPI_WII" HINT_JOYSTICK_HIDAPI_WII_PLAYER_LED :: "SDL_JOYSTICK_HIDAPI_WII_PLAYER_LED" @@ -107,6 +113,8 @@ HINT_JOYSTICK_HIDAPI_XBOX_360_PLAYER_LED :: "SDL_JOYSTICK_HIDAPI_XBOX_360_PL HINT_JOYSTICK_HIDAPI_XBOX_360_WIRELESS :: "SDL_JOYSTICK_HIDAPI_XBOX_360_WIRELESS" HINT_JOYSTICK_HIDAPI_XBOX_ONE :: "SDL_JOYSTICK_HIDAPI_XBOX_ONE" HINT_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED :: "SDL_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED" +HINT_JOYSTICK_HIDAPI_GIP :: "SDL_JOYSTICK_HIDAPI_GIP" +HINT_JOYSTICK_HIDAPI_GIP_RESET_FOR_METADATA :: "SDL_JOYSTICK_HIDAPI_GIP_RESET_FOR_METADATA" HINT_JOYSTICK_IOKIT :: "SDL_JOYSTICK_IOKIT" HINT_JOYSTICK_LINUX_CLASSIC :: "SDL_JOYSTICK_LINUX_CLASSIC" HINT_JOYSTICK_LINUX_DEADZONES :: "SDL_JOYSTICK_LINUX_DEADZONES" @@ -127,17 +135,20 @@ HINT_JOYSTICK_HAPTIC_AXES :: "SDL_JOYSTICK_HAPTIC_AXES" HINT_KEYCODE_OPTIONS :: "SDL_KEYCODE_OPTIONS" HINT_KMSDRM_DEVICE_INDEX :: "SDL_KMSDRM_DEVICE_INDEX" HINT_KMSDRM_REQUIRE_DRM_MASTER :: "SDL_KMSDRM_REQUIRE_DRM_MASTER" +HINT_KMSDRM_ATOMIC :: "SDL_KMSDRM_ATOMIC" HINT_LOGGING :: "SDL_LOGGING" HINT_MAC_BACKGROUND_APP :: "SDL_MAC_BACKGROUND_APP" HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK :: "SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK" HINT_MAC_OPENGL_ASYNC_DISPATCH :: "SDL_MAC_OPENGL_ASYNC_DISPATCH" HINT_MAC_OPTION_AS_ALT :: "SDL_MAC_OPTION_AS_ALT" HINT_MAC_SCROLL_MOMENTUM :: "SDL_MAC_SCROLL_MOMENTUM" +HINT_MAC_PRESS_AND_HOLD :: "SDL_MAC_PRESS_AND_HOLD" HINT_MAIN_CALLBACK_RATE :: "SDL_MAIN_CALLBACK_RATE" HINT_MOUSE_AUTO_CAPTURE :: "SDL_MOUSE_AUTO_CAPTURE" HINT_MOUSE_DOUBLE_CLICK_RADIUS :: "SDL_MOUSE_DOUBLE_CLICK_RADIUS" HINT_MOUSE_DOUBLE_CLICK_TIME :: "SDL_MOUSE_DOUBLE_CLICK_TIME" HINT_MOUSE_DEFAULT_SYSTEM_CURSOR :: "SDL_MOUSE_DEFAULT_SYSTEM_CURSOR" +HINT_MOUSE_DPI_SCALE_CURSORS :: "SDL_MOUSE_DPI_SCALE_CURSORS" HINT_MOUSE_EMULATE_WARP_WITH_RELATIVE :: "SDL_MOUSE_EMULATE_WARP_WITH_RELATIVE" HINT_MOUSE_FOCUS_CLICKTHROUGH :: "SDL_MOUSE_FOCUS_CLICKTHROUGH" HINT_MOUSE_NORMAL_SPEED_SCALE :: "SDL_MOUSE_NORMAL_SPEED_SCALE" @@ -159,6 +170,7 @@ HINT_PREFERRED_LOCALES :: "SDL_PREFERRED_LOCALES" HINT_QUIT_ON_LAST_WINDOW_CLOSE :: "SDL_QUIT_ON_LAST_WINDOW_CLOSE" HINT_RENDER_DIRECT3D_THREADSAFE :: "SDL_RENDER_DIRECT3D_THREADSAFE" HINT_RENDER_DIRECT3D11_DEBUG :: "SDL_RENDER_DIRECT3D11_DEBUG" +HINT_RENDER_DIRECT3D11_WARP :: "SDL_RENDER_DIRECT3D11_WARP" HINT_RENDER_VULKAN_DEBUG :: "SDL_RENDER_VULKAN_DEBUG" HINT_RENDER_GPU_DEBUG :: "SDL_RENDER_GPU_DEBUG" HINT_RENDER_GPU_LOW_POWER :: "SDL_RENDER_GPU_LOW_POWER" @@ -169,6 +181,10 @@ HINT_RENDER_VSYNC :: "SDL_RENDER_VSYNC" HINT_RETURN_KEY_HIDES_IME :: "SDL_RETURN_KEY_HIDES_IME" HINT_ROG_GAMEPAD_MICE :: "SDL_ROG_GAMEPAD_MICE" HINT_ROG_GAMEPAD_MICE_EXCLUDED :: "SDL_ROG_GAMEPAD_MICE_EXCLUDED" +HINT_PS2_GS_WIDTH :: "SDL_PS2_GS_WIDTH" +HINT_PS2_GS_HEIGHT :: "SDL_PS2_GS_HEIGHT" +HINT_PS2_GS_PROGRESSIVE :: "SDL_PS2_GS_PROGRESSIVE" +HINT_PS2_GS_MODE :: "SDL_PS2_GS_MODE" HINT_RPI_VIDEO_LAYER :: "SDL_RPI_VIDEO_LAYER" HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME :: "SDL_SCREENSAVER_INHIBIT_ACTIVITY_NAME" HINT_SHUTDOWN_DBUS_ON_QUIT :: "SDL_SHUTDOWN_DBUS_ON_QUIT" @@ -189,6 +205,8 @@ HINT_VIDEO_EGL_ALLOW_GETDISPLAY_FALLBACK :: "SDL_VIDEO_EGL_ALLOW_GETDISPLAY_ HINT_VIDEO_FORCE_EGL :: "SDL_VIDEO_FORCE_EGL" HINT_VIDEO_MAC_FULLSCREEN_SPACES :: "SDL_VIDEO_MAC_FULLSCREEN_SPACES" HINT_VIDEO_MAC_FULLSCREEN_MENU_VISIBILITY :: "SDL_VIDEO_MAC_FULLSCREEN_MENU_VISIBILITY" +HINT_VIDEO_METAL_AUTO_RESIZE_DRAWABLE :: "SDL_VIDEO_METAL_AUTO_RESIZE_DRAWABLE" +HINT_VIDEO_MATCH_EXCLUSIVE_MODE_ON_MOVE :: "SDL_VIDEO_MATCH_EXCLUSIVE_MODE_ON_MOVE" HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS :: "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS" HINT_VIDEO_OFFSCREEN_SAVE_FRAMES :: "SDL_VIDEO_OFFSCREEN_SAVE_FRAMES" HINT_VIDEO_SYNC_WINDOW_OPERATIONS :: "SDL_VIDEO_SYNC_WINDOW_OPERATIONS" @@ -263,4 +281,4 @@ foreign lib { ResetHints :: proc() --- AddHintCallback :: proc(name: cstring, callback: HintCallback, userdata: rawptr) -> bool --- RemoveHintCallback :: proc(name: cstring, callback: HintCallback, userdata: rawptr) --- -} \ No newline at end of file +} diff --git a/vendor/sdl3/sdl3_iostream.odin b/vendor/sdl3/sdl3_iostream.odin index 2f89c2ba6..f57dc947d 100644 --- a/vendor/sdl3/sdl3_iostream.odin +++ b/vendor/sdl3/sdl3_iostream.odin @@ -44,6 +44,7 @@ PROP_IOSTREAM_FILE_DESCRIPTOR_NUMBER :: "SDL.iostream.file_descriptor" PROP_IOSTREAM_ANDROID_AASSET_POINTER :: "SDL.iostream.android.aasset" PROP_IOSTREAM_MEMORY_POINTER :: "SDL.iostream.memory.base" PROP_IOSTREAM_MEMORY_SIZE_NUMBER :: "SDL.iostream.memory.size" +PROP_IOSTREAM_MEMORY_FREE_FUNC_POINTER :: "SDL.iostream.memory.free" PROP_IOSTREAM_DYNAMIC_MEMORY_POINTER :: "SDL.iostream.dynamic.memory" PROP_IOSTREAM_DYNAMIC_CHUNKSIZE_NUMBER :: "SDL.iostream.dynamic.chunksize" diff --git a/vendor/sdl3/sdl3_mouse.odin b/vendor/sdl3/sdl3_mouse.odin index 3bc3aa57f..2a087a34c 100644 --- a/vendor/sdl3/sdl3_mouse.odin +++ b/vendor/sdl3/sdl3_mouse.odin @@ -34,6 +34,11 @@ MouseWheelDirection :: enum c.int { FLIPPED, /**< The scroll direction is flipped / natural */ } +CursorFrameInfo :: struct { + surface: ^Surface, + duration: Uint32, +} + MouseButtonFlags :: distinct bit_set[MouseButtonFlag; Uint32] MouseButtonFlag :: enum Uint32 { LEFT = 1 - 1, @@ -55,6 +60,8 @@ BUTTON_RMASK :: MouseButtonFlags{.RIGHT} BUTTON_X1MASK :: MouseButtonFlags{.X1} BUTTON_X2MASK :: MouseButtonFlags{.X2} +MouseMotionTransformCallback :: #type proc "c" (userdata: rawptr, timestamp: Uint64, window: ^Window, mouseID: MouseID, x, y: ^f32) + @(default_calling_convention="c", link_prefix="SDL_", require_results) foreign lib { HasMouse :: proc() -> bool --- @@ -66,11 +73,13 @@ foreign lib { GetRelativeMouseState :: proc(x, y: ^f32) -> MouseButtonFlags --- WarpMouseInWindow :: proc(window: ^Window, x, y: f32) --- WarpMouseGlobal :: proc(x, y: f32) -> bool --- + SetRelativeMouseTransform :: proc(callback: MouseMotionTransformCallback, userdata: rawptr) -> bool --- SetWindowRelativeMouseMode :: proc(window: ^Window, enabled: bool) -> bool --- GetWindowRelativeMouseMode :: proc(window: ^Window) -> bool --- CaptureMouse :: proc(enabled: bool) -> bool --- CreateCursor :: proc(data: [^]byte, mask: [^]Uint8, w, h, hot_x, hot_y: c.int) -> ^Cursor --- CreateColorCursor :: proc(surface: ^Surface, hot_x, hot_y: c.int) -> ^Cursor --- + CreateAnimatedCursor :: proc(frames: [^]CursorFrameInfo, frame_count, hot_x, hot_y: c.int) -> ^Cursor --- CreateSystemCursor :: proc(id: SystemCursor) -> ^Cursor --- SetCursor :: proc(cursor: ^Cursor) -> bool --- GetCursor :: proc() -> ^Cursor --- @@ -79,4 +88,4 @@ foreign lib { ShowCursor :: proc() -> bool --- HideCursor :: proc() -> bool --- CursorVisible :: proc() -> bool --- -} \ No newline at end of file +} diff --git a/vendor/sdl3/sdl3_pen.odin b/vendor/sdl3/sdl3_pen.odin index 81e820e6b..d96848fed 100644 --- a/vendor/sdl3/sdl3_pen.odin +++ b/vendor/sdl3/sdl3_pen.odin @@ -10,13 +10,14 @@ PEN_TOUCHID :: TouchID(1<<64 - 2) PenInputFlags :: distinct bit_set[PenInputFlag; Uint32] PenInputFlag :: enum Uint32 { - DOWN = 0, /**< pen is pressed down */ - BUTTON_1 = 1, /**< button 1 is pressed */ - BUTTON_2 = 2, /**< button 2 is pressed */ - BUTTON_3 = 3, /**< button 3 is pressed */ - BUTTON_4 = 4, /**< button 4 is pressed */ - BUTTON_5 = 5, /**< button 5 is pressed */ - ERASER_TIP = 30, /**< eraser tip is used */ + DOWN = 0, /**< pen is pressed down */ + BUTTON_1 = 1, /**< button 1 is pressed */ + BUTTON_2 = 2, /**< button 2 is pressed */ + BUTTON_3 = 3, /**< button 3 is pressed */ + BUTTON_4 = 4, /**< button 4 is pressed */ + BUTTON_5 = 5, /**< button 5 is pressed */ + ERASER_TIP = 30, /**< eraser tip is used */ + IN_PROXIMITY = 31, /**< pen is in proximity (since SDL 3.4.0) */ } PenAxis :: enum c.int { @@ -27,4 +28,16 @@ PenAxis :: enum c.int { ROTATION, /**< Pen barrel rotation. Bidirectional: -180 to 179.9 (clockwise, 0 is facing up, -180.0 is facing down). */ SLIDER, /**< Pen finger wheel or slider (e.g., Airbrush Pen). Unidirectional: 0 to 1.0 */ TANGENTIAL_PRESSURE, /**< Pressure from squeezing the pen ("barrel pressure"). */ -} \ No newline at end of file +} + +PenDeviceType :: enum c.int { + INVALID = -1, /**< Not a valid pen device. */ + UNKNOWN, /**< Don't know specifics of this pen. */ + DIRECT, /**< Pen touches display. */ + INDIRECT, /**< Pen touches something that isn't the display. */ +} + +@(default_calling_convention="c", link_prefix="SDL_", require_results) +foreign lib { + GetPenDeviceType :: proc(instance_id: PenID) --- +} diff --git a/vendor/sdl3/sdl3_pixels.odin b/vendor/sdl3/sdl3_pixels.odin index a636d13ff..e3a1c1537 100644 --- a/vendor/sdl3/sdl3_pixels.odin +++ b/vendor/sdl3/sdl3_pixels.odin @@ -518,7 +518,7 @@ Colorspace :: enum c.int { SDL_CHROMA_LOCATION_LEFT), */ RGB_DEFAULT = SRGB, /**< The default colorspace for RGB surfaces if no colorspace is specified */ - YUV_DEFAULT = JPEG, /**< The default colorspace for YUV surfaces if no colorspace is specified */ + YUV_DEFAULT = BT601_LIMITED, /**< The default colorspace for YUV surfaces if no colorspace is specified */ } Color :: distinct [4]Uint8 @@ -561,6 +561,6 @@ foreign lib { DestroyPalette :: proc(palette: ^Palette) --- MapRGB :: proc(format: ^PixelFormatDetails, palette: ^Palette, r, g, b: Uint8) -> Uint32 --- MapRGBA :: proc(format: ^PixelFormatDetails, palette: ^Palette, r, g, b, a: Uint8) -> Uint32 --- - GetRGB :: proc(pixel: Uint32, format: ^PixelFormatDetails, palette: ^Palette, r, g, b: ^Uint8) --- - GetRGBA :: proc(pixel: Uint32, format: ^PixelFormatDetails, palette: ^Palette, r, g, b, a: ^Uint8) --- + GetRGB :: proc(pixelvalue: Uint32, format: ^PixelFormatDetails, palette: ^Palette, r, g, b: ^Uint8) --- + GetRGBA :: proc(pixelvalue: Uint32, format: ^PixelFormatDetails, palette: ^Palette, r, g, b, a: ^Uint8) --- } diff --git a/vendor/sdl3/sdl3_process.odin b/vendor/sdl3/sdl3_process.odin index d3ba6f2ba..71686a444 100644 --- a/vendor/sdl3/sdl3_process.odin +++ b/vendor/sdl3/sdl3_process.odin @@ -13,6 +13,7 @@ ProcessIO :: enum c.int { PROP_PROCESS_CREATE_ARGS_POINTER :: "SDL.process.create.args" PROP_PROCESS_CREATE_ENVIRONMENT_POINTER :: "SDL.process.create.environment" +PROP_PROCESS_CREATE_WORKING_DIRECTORY_STRING :: "SDL.process.create.working_directory" PROP_PROCESS_CREATE_STDIN_NUMBER :: "SDL.process.create.stdin_option" PROP_PROCESS_CREATE_STDIN_POINTER :: "SDL.process.create.stdin_source" PROP_PROCESS_CREATE_STDOUT_NUMBER :: "SDL.process.create.stdout_option" @@ -21,6 +22,7 @@ PROP_PROCESS_CREATE_STDERR_NUMBER :: "SDL.process.create.stderr_op PROP_PROCESS_CREATE_STDERR_POINTER :: "SDL.process.create.stderr_source" PROP_PROCESS_CREATE_STDERR_TO_STDOUT_BOOLEAN :: "SDL.process.create.stderr_to_stdout" PROP_PROCESS_CREATE_BACKGROUND_BOOLEAN :: "SDL.process.create.background" +PROP_PROCESS_CREATE_CMDLINE_STRING :: "SDL.process.create.cmdline" PROP_PROCESS_PID_NUMBER :: "SDL.process.pid" PROP_PROCESS_STDIN_POINTER :: "SDL.process.stdin" @@ -39,4 +41,4 @@ foreign lib { KillProcess :: proc(process: ^Process, force: bool) -> bool --- WaitProcess :: proc(process: ^Process, block: bool, exitcode: ^c.int) -> bool --- DestroyProcess :: proc(process: ^Process) --- -} \ No newline at end of file +} diff --git a/vendor/sdl3/sdl3_properties.odin b/vendor/sdl3/sdl3_properties.odin index 73372c290..01bdff59b 100644 --- a/vendor/sdl3/sdl3_properties.odin +++ b/vendor/sdl3/sdl3_properties.odin @@ -4,6 +4,8 @@ import "core:c" PropertiesID :: distinct Uint32 +PROP_NAME_STRING :: "SDL.name" + PropertyType :: enum c.int { INVALID, POINTER, @@ -41,4 +43,4 @@ foreign lib { ClearProperty :: proc(props: PropertiesID, name: cstring) -> bool --- EnumerateProperties :: proc(props: PropertiesID, callback: EnumeratePropertiesCallback, userdata: rawptr) -> bool --- DestroyProperties :: proc(props: PropertiesID) --- -} \ No newline at end of file +} diff --git a/vendor/sdl3/sdl3_render.odin b/vendor/sdl3/sdl3_render.odin index 5af4bb055..51abbf777 100644 --- a/vendor/sdl3/sdl3_render.odin +++ b/vendor/sdl3/sdl3_render.odin @@ -4,6 +4,7 @@ import "core:c" SOFTWARE_RENDERER :: "software" +GPU_RENDER :: "gpu" Vertex :: struct { position: FPoint, /**< Vertex position, in SDL_Renderer coordinates */ @@ -17,6 +18,13 @@ TextureAccess :: enum c.int { TARGET, /**< Texture can be used as a render target */ } +TextureAddressMode :: enum c.int { + INVALID = -1, + AUTO, /**< Wrapping is enabled if texture coordinates are outside [0, 1], this is the default */ + CLAMP, /**< Texture coordinates are clamped to the [0, 1] range */ + WRAP, /**< The texture is repeated (tiled) */ +} + RendererLogicalPresentation :: enum c.int { DISABLED, /**< There is no logical size in effect */ STRETCH, /**< The rendered content is stretched to the output resolution */ @@ -40,6 +48,10 @@ PROP_RENDERER_CREATE_WINDOW_POINTER :: "SDL.renderer PROP_RENDERER_CREATE_SURFACE_POINTER :: "SDL.renderer.create.surface" PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER :: "SDL.renderer.create.output_colorspace" PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER :: "SDL.renderer.create.present_vsync" +PROP_RENDERER_CREATE_GPU_DEVICE_POINTER :: "SDL.renderer.create.gpu.device" +PROP_RENDERER_CREATE_GPU_SHADERS_SPIRV_BOOLEAN :: "SDL.renderer.create.gpu.shaders_spirv" +PROP_RENDERER_CREATE_GPU_SHADERS_DXIL_BOOLEAN :: "SDL.renderer.create.gpu.shaders_dxil" +PROP_RENDERER_CREATE_GPU_SHADERS_MSL_BOOLEAN :: "SDL.renderer.create.gpu.shaders_msl" PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER :: "SDL.renderer.create.vulkan.instance" PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER :: "SDL.renderer.create.vulkan.surface" PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER :: "SDL.renderer.create.vulkan.physical_device" @@ -53,6 +65,7 @@ PROP_RENDERER_SURFACE_POINTER :: "SDL.renderer.surface PROP_RENDERER_VSYNC_NUMBER :: "SDL.renderer.vsync" PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER :: "SDL.renderer.max_texture_size" PROP_RENDERER_TEXTURE_FORMATS_POINTER :: "SDL.renderer.texture_formats" +PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN :: "SDL.renderer.texture_wrapping" PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER :: "SDL.renderer.output_colorspace" PROP_RENDERER_HDR_ENABLED_BOOLEAN :: "SDL.renderer.HDR_enabled" PROP_RENDERER_SDR_WHITE_POINT_FLOAT :: "SDL.renderer.SDR_white_point" @@ -72,29 +85,35 @@ PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER :: "SDL.renderer.vulkan. PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER :: "SDL.renderer.vulkan.swapchain_image_count" PROP_RENDERER_GPU_DEVICE_POINTER :: "SDL.renderer.gpu.device" -PROP_TEXTURE_CREATE_COLORSPACE_NUMBER :: "SDL.texture.create.colorspace" -PROP_TEXTURE_CREATE_FORMAT_NUMBER :: "SDL.texture.create.format" -PROP_TEXTURE_CREATE_ACCESS_NUMBER :: "SDL.texture.create.access" -PROP_TEXTURE_CREATE_WIDTH_NUMBER :: "SDL.texture.create.width" -PROP_TEXTURE_CREATE_HEIGHT_NUMBER :: "SDL.texture.create.height" -PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT :: "SDL.texture.create.SDR_white_point" -PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT :: "SDL.texture.create.HDR_headroom" -PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER :: "SDL.texture.create.d3d11.texture" -PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER :: "SDL.texture.create.d3d11.texture_u" -PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER :: "SDL.texture.create.d3d11.texture_v" -PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER :: "SDL.texture.create.d3d12.texture" -PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER :: "SDL.texture.create.d3d12.texture_u" -PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER :: "SDL.texture.create.d3d12.texture_v" -PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER :: "SDL.texture.create.metal.pixelbuffer" -PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER :: "SDL.texture.create.opengl.texture" -PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER :: "SDL.texture.create.opengl.texture_uv" -PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER :: "SDL.texture.create.opengl.texture_u" -PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER :: "SDL.texture.create.opengl.texture_v" -PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER :: "SDL.texture.create.opengles2.texture" -PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER :: "SDL.texture.create.opengles2.texture_uv" -PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER :: "SDL.texture.create.opengles2.texture_u" -PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER :: "SDL.texture.create.opengles2.texture_v" -PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER :: "SDL.texture.create.vulkan.texture" +PROP_TEXTURE_CREATE_COLORSPACE_NUMBER :: "SDL.texture.create.colorspace" +PROP_TEXTURE_CREATE_FORMAT_NUMBER :: "SDL.texture.create.format" +PROP_TEXTURE_CREATE_ACCESS_NUMBER :: "SDL.texture.create.access" +PROP_TEXTURE_CREATE_WIDTH_NUMBER :: "SDL.texture.create.width" +PROP_TEXTURE_CREATE_HEIGHT_NUMBER :: "SDL.texture.create.height" +PROP_TEXTURE_CREATE_PALETTE_POINTER :: "SDL.texture.create.palette" +PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT :: "SDL.texture.create.SDR_white_point" +PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT :: "SDL.texture.create.HDR_headroom" +PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER :: "SDL.texture.create.d3d11.texture" +PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER :: "SDL.texture.create.d3d11.texture_u" +PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER :: "SDL.texture.create.d3d11.texture_v" +PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER :: "SDL.texture.create.d3d12.texture" +PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER :: "SDL.texture.create.d3d12.texture_u" +PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER :: "SDL.texture.create.d3d12.texture_v" +PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER :: "SDL.texture.create.metal.pixelbuffer" +PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER :: "SDL.texture.create.opengl.texture" +PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER :: "SDL.texture.create.opengl.texture_uv" +PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER :: "SDL.texture.create.opengl.texture_u" +PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER :: "SDL.texture.create.opengl.texture_v" +PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER :: "SDL.texture.create.opengles2.texture" +PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER :: "SDL.texture.create.opengles2.texture_uv" +PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER :: "SDL.texture.create.opengles2.texture_u" +PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER :: "SDL.texture.create.opengles2.texture_v" +PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER :: "SDL.texture.create.vulkan.texture" +PROP_TEXTURE_CREATE_VULKAN_LAYOUT_NUMBER :: "SDL.texture.create.vulkan.layout" +PROP_TEXTURE_CREATE_GPU_TEXTURE_POINTER :: "SDL.texture.create.gpu.texture" +PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_POINTER :: "SDL.texture.create.gpu.texture_uv" +PROP_TEXTURE_CREATE_GPU_TEXTURE_U_POINTER :: "SDL.texture.create.gpu.texture_u" +PROP_TEXTURE_CREATE_GPU_TEXTURE_V_POINTER :: "SDL.texture.create.gpu.texture_v" PROP_TEXTURE_COLORSPACE_NUMBER :: "SDL.texture.colorspace" PROP_TEXTURE_FORMAT_NUMBER :: "SDL.texture.format" @@ -122,6 +141,10 @@ PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER :: "SDL.texture.opengles2.textur PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER :: "SDL.texture.opengles2.texture_v" PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER :: "SDL.texture.opengles2.target" PROP_TEXTURE_VULKAN_TEXTURE_NUMBER :: "SDL.texture.vulkan.texture" +PROP_TEXTURE_GPU_TEXTURE_POINTER :: "SDL.texture.gpu.texture" +PROP_TEXTURE_GPU_TEXTURE_UV_POINTER :: "SDL.texture.gpu.texture_uv" +PROP_TEXTURE_GPU_TEXTURE_U_POINTER :: "SDL.texture.gpu.texture_u" +PROP_TEXTURE_GPU_TEXTURE_V_POINTER :: "SDL.texture.gpu.texture_v" RENDERER_VSYNC_DISABLED :: 0 RENDERER_VSYNC_ADAPTIVE :: -1 @@ -134,6 +157,8 @@ foreign lib { GetRenderDriver :: proc(index: c.int) -> cstring --- CreateRenderer :: proc(window: ^Window, name: cstring) -> ^Renderer --- CreateRendererWithProperties :: proc(props: PropertiesID) -> ^Renderer --- + CreateGPURenderer :: proc(device: ^GPUDevice, window: ^Window) -> ^Renderer --- + GetGPURendererDevice :: proc(device: ^Renderer) -> ^GPUDevice --- CreateSoftwareRenderer :: proc(surface: ^Surface) -> ^Renderer --- GetRenderer :: proc(window: ^Window) -> ^Renderer --- GetRenderWindow :: proc(renderer: ^Renderer) -> ^Window --- @@ -158,6 +183,8 @@ foreign lib { GetRenderOutputSize :: proc(renderer: ^Renderer, w, h: ^c.int) -> bool --- GetCurrentRenderOutputSize :: proc(renderer: ^Renderer, w, h: ^c.int) -> bool --- GetTextureSize :: proc(texture: ^Texture, w, h: ^f32) -> bool --- + SetTexturePalette :: proc(texture: ^Texture, palette: ^Palette) -> bool --- + GetTexturePalette :: proc(texture: ^Texture) -> ^Palette --- SetTextureColorMod :: proc(texture: ^Texture, r, g, b: Uint8) -> bool --- SetTextureColorModFloat :: proc(texture: ^Texture, r, g, b: f32) -> bool --- GetTextureColorMod :: proc(texture: ^Texture, r, g, b: ^Uint8) -> bool --- @@ -208,12 +235,15 @@ foreign lib { RenderFillRect :: proc(renderer: ^Renderer, rect: Maybe(^FRect)) -> bool --- RenderFillRects :: proc(renderer: ^Renderer, rects: [^]FRect, count: c.int) -> bool --- RenderTexture :: proc(renderer: ^Renderer, texture: ^Texture, srcrect, dstrect: Maybe(^FRect)) -> bool --- - RenderTextureRotated :: proc(renderer: ^Renderer, texture: ^Texture, srcrect, dstrect: Maybe(^FRect), angle: f64, #by_ptr center: FPoint, flip: FlipMode) -> bool --- + RenderTextureRotated :: proc(renderer: ^Renderer, texture: ^Texture, srcrect, dstrect: Maybe(^FRect), angle: f64, center: Maybe(^FPoint), flip: FlipMode) -> bool --- RenderTextureAffine :: proc(renderer: ^Renderer, texture: ^Texture, srcrect: Maybe(^FRect), origin, right, down: Maybe(^FPoint)) -> bool --- RenderTextureTiled :: proc(renderer: ^Renderer, texture: ^Texture, srcrect: Maybe(^FRect), scale: f32, dstrect: Maybe(^FRect)) -> bool --- RenderTexture9Grid :: proc(renderer: ^Renderer, texture: ^Texture, srcrect: Maybe(^FRect), left_width, right_width, top_height, bottom_height: f32, scale: f32, dstrect: Maybe(^FRect)) -> bool --- + RenderTexture9GridTiled :: proc(renderer: ^Renderer, texture: ^Texture, srcrect: Maybe(^FRect), left_width, right_width, top_height, bottom_height: f32, scale: f32, dstrect: Maybe(^FRect), tileScale: f32) -> bool --- RenderGeometry :: proc(renderer: ^Renderer, texture: ^Texture, vertices: [^]Vertex, num_vertices: c.int, indices: [^]c.int, num_indices: c.int) -> bool --- RenderGeometryRaw :: proc(renderer: ^Renderer, texture: ^Texture, xy: [^]f32, xy_stride: c.int, color: [^]FColor, color_stride: c.int, uv: [^]f32, uv_stride: c.int, num_vertices: c.int, indices: rawptr, num_indices: c.int, size_indices: c.int) -> bool --- + SetRenderTextureAddressMode :: proc(renderer: ^Renderer, u_mode, v_mode: TextureAddressMode) -> bool --- + GetRenderTextureAddressMode :: proc(renderer: ^Renderer, u_mode, v_mode: ^TextureAddressMode) -> bool --- RenderPresent :: proc(renderer: ^Renderer) -> bool --- DestroyTexture :: proc(texture: ^Texture) --- DestroyRenderer :: proc(renderer: ^Renderer) --- @@ -223,4 +253,28 @@ foreign lib { GetRenderVSync :: proc(renderer: ^Renderer, vsync: ^c.int) -> bool --- RenderDebugText :: proc(renderer: ^Renderer, x, y: f32, str: cstring) -> bool --- RenderDebugTextFormat :: proc(renderer: ^Renderer, x, y: f32, fmt: cstring, #c_vararg args: ..any) -> bool --- -} \ No newline at end of file + SetDefaultTextureAddressMode :: proc(renderer: ^Renderer, scale_mode: ScaleMode) -> bool --- + GetDefaultTextureAddressMode :: proc(renderer: ^Renderer, scale_mode: ^ScaleMode) -> bool --- +} + + +GPURenderStateCreateInfo :: struct { + fragment_shader: ^GPUShader, /**< The fragment shader to use when this render state is active */ + num_sampler_bindings: Sint32, /**< The number of additional fragment samplers to bind when this render state is active */ + sampler_bindings: [^]GPUTextureSamplerBinding, /**< Additional fragment samplers to bind when this render state is active */ + num_storage_textures: Sint32, /**< The number of storage textures to bind when this render state is active */ + storage_textures: [^]^GPUTexture, /**< Storage textures to bind when this render state is active */ + num_storage_buffers: Sint32, /**< The number of storage buffers to bind when this render state is active */ + storage_buffers: [^]^GPUBuffer, /**< Storage buffers to bind when this render state is active */ + props: PropertiesID, /**< A properties ID for extensions. Should be 0 if no extensions are needed. */ +} + +GPURenderState :: struct {} + +@(default_calling_convention="c", link_prefix="SDL_", require_results) +foreign lib { + CreateGPURenderState :: proc(renderer: ^Renderer, createinfo: ^GPURenderStateCreateInfo) -> ^GPURenderState --- + SetGPURenderStateFragmentUniforms :: proc(state: ^GPURenderState, slot_index: Uint32, data: rawptr, length: Uint32) -> bool --- + SetGPURenderState :: proc(renderer: ^Renderer, state: ^GPURenderState) -> bool --- + DestroyGPURenderState :: proc(renderer: ^Renderer) --- +} diff --git a/vendor/sdl3/sdl3_surface.odin b/vendor/sdl3/sdl3_surface.odin index 526940147..9aaf54cec 100644 --- a/vendor/sdl3/sdl3_surface.odin +++ b/vendor/sdl3/sdl3_surface.odin @@ -23,14 +23,16 @@ MUSTLOCK :: proc "c" (S: ^Surface) -> bool { ScaleMode :: enum c.int { INVALID = -1, - NEAREST, /**< nearest pixel sampling */ - LINEAR, /**< linear filtering */ + NEAREST, /**< nearest pixel sampling */ + LINEAR, /**< linear filtering */ + PIXELART, /**< nearest pixel sampling with improved scaling for pixel art, available since SDL 3.4.0 */ } FlipMode :: enum c.int { - NONE, /**< Do not flip */ - HORIZONTAL, /**< flip horizontally */ - VERTICAL, /**< flip vertically */ + NONE, /**< Do not flip */ + HORIZONTAL, /**< flip horizontally */ + VERTICAL, /**< flip vertically */ + HORIZONTAL_AND_VERTICAL = HORIZONTAL | VERTICAL, /**< flip horizontally and vertically (not a diagonal flip) */ } Surface :: struct { @@ -51,6 +53,7 @@ PROP_SURFACE_HDR_HEADROOM_FLOAT :: "SDL.surface.HDR_headroom" PROP_SURFACE_TONEMAP_OPERATOR_STRING :: "SDL.surface.tonemap" PROP_SURFACE_HOTSPOT_X_NUMBER :: "SDL.surface.hotspot.x" PROP_SURFACE_HOTSPOT_Y_NUMBER :: "SDL.surface.hotspot.y" +PROP_SURFACE_ROTATION_FLOAT :: "SDL.surface.rotation" @(default_calling_convention="c", link_prefix="SDL_") foreign lib { @@ -69,10 +72,16 @@ foreign lib { RemoveSurfaceAlternateImages :: proc(surface: ^Surface) --- LockSurface :: proc(surface: ^Surface) -> bool --- UnlockSurface :: proc(surface: ^Surface) --- + LoadSurface_IO :: proc(src: ^IOStream, closeio: bool) -> ^Surface --- + LoadSurface :: proc(file: cstring) -> ^Surface --- LoadBMP_IO :: proc(src: ^IOStream, closeio: bool) -> ^Surface --- LoadBMP :: proc(file: cstring) -> ^Surface --- SaveBMP_IO :: proc(surface: ^Surface, dst: ^IOStream, closeio: bool) -> bool --- SaveBMP :: proc(surface: ^Surface, file: cstring) -> bool --- + LoadPNG_IO :: proc(src: ^IOStream, closeio: bool) -> ^Surface --- + LoadPNG :: proc(file: cstring) -> ^Surface --- + SavePNG_IO :: proc(surface: ^Surface, dst: ^IOStream, closeio: bool) -> bool --- + SavePNG :: proc(surface: ^Surface, file: cstring) -> bool --- SetSurfaceRLE :: proc(surface: ^Surface, enabled: bool) -> bool --- SurfaceHasRLE :: proc(surface: ^Surface) -> bool --- SetSurfaceColorKey :: proc(surface: ^Surface, enabled: bool, key: Uint32) -> bool --- @@ -87,6 +96,7 @@ foreign lib { SetSurfaceClipRect :: proc(surface: ^Surface, rect: Maybe(^Rect)) -> bool --- GetSurfaceClipRect :: proc(surface: ^Surface, rect: ^Rect) -> bool --- FlipSurface :: proc(surface: ^Surface, flip: FlipMode) -> bool --- + RotateSurface :: proc(surface: ^Surface, angle: f32) -> ^Surface --- DuplicateSurface :: proc(surface: ^Surface) -> ^Surface --- ScaleSurface :: proc(surface: ^Surface, width, height: c.int, scaleMode: ScaleMode) -> ^Surface --- ConvertSurface :: proc(surface: ^Surface, format: PixelFormat) -> ^Surface --- @@ -112,4 +122,4 @@ foreign lib { ReadSurfacePixelFloat :: proc(surface: ^Surface, x, y: c.int, r, g, b, a: ^f32) -> bool --- WriteSurfacePixel :: proc(surface: ^Surface, x, y: c.int, r, g, b, a: Uint8) -> bool --- WriteSurfacePixelFloat :: proc(surface: ^Surface, x, y: c.int, r, g, b, a: f32) -> bool --- -} \ No newline at end of file +} diff --git a/vendor/sdl3/sdl3_video.odin b/vendor/sdl3/sdl3_video.odin index 6761bee56..e4547d991 100644 --- a/vendor/sdl3/sdl3_video.odin +++ b/vendor/sdl3/sdl3_video.odin @@ -61,6 +61,7 @@ WindowFlag :: enum Uint64 { TOOLTIP = 18, POPUP_MENU = 19, KEYBOARD_GRABBED = 20, + FILL_DOCUMENT = 21, VULKAN = 28, METAL = 29, @@ -133,6 +134,15 @@ FlashOperation :: enum c.int { UNTIL_FOCUSED, /**< Flash the window until it gets focus */ } +ProgressState :: enum c.int { + INVALID = -1, /**< An invalid progress state indicating an error; check SDL_GetError() */ + NONE, /**< No progress bar is shown */ + INDETERMINATE, /**< The progress bar is shown in a indeterminate state */ + NORMAL, /**< The progress bar is shown in a normal state */ + PAUSED, /**< The progress bar is shown in a paused state */ + ERROR, /**< The progress bar is shown in a state indicating the application had an error */ +} + GLContextState :: struct {} GLContext :: ^GLContextState EGLDisplay :: distinct rawptr @@ -167,7 +177,7 @@ GLAttr :: enum c.int { CONTEXT_FLAGS, /**< some combination of 0 or more of elements of the SDL_GLContextFlag enumeration; defaults to 0. */ CONTEXT_PROFILE_MASK, /**< type of GL context (Core, Compatibility, ES). See SDL_GLProfile; default value depends on platform. */ SHARE_WITH_CURRENT_CONTEXT, /**< OpenGL context sharing; defaults to 0. */ - FRAMEBUFFER_SRGB_CAPABLE, /**< requests sRGB capable visual; defaults to 0. */ + FRAMEBUFFER_SRGB_CAPABLE, /**< requests sRGB-capable visual if 1. Defaults to -1 ("don't care"). This is a request; GL drivers might not comply! */ CONTEXT_RELEASE_BEHAVIOR, /**< sets context the release behavior. See SDL_GLContextReleaseFlag; defaults to FLUSH. */ CONTEXT_RESET_NOTIFICATION, /**< set context reset notification. See SDL_GLContextResetNotification; defaults to NO_NOTIFICATION. */ CONTEXT_NO_ERROR, @@ -275,12 +285,15 @@ PROP_WINDOW_CREATE_X_NUMBER :: "SDL.window.create.x" PROP_WINDOW_CREATE_Y_NUMBER :: "SDL.window.create.y" PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER :: "SDL.window.create.cocoa.window" PROP_WINDOW_CREATE_COCOA_VIEW_POINTER :: "SDL.window.create.cocoa.view" +PROP_WINDOW_CREATE_WINDOWSCENE_POINTER :: "SDL.window.create.uikit.windowscene" PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN :: "SDL.window.create.wayland.surface_role_custom" PROP_WINDOW_CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN :: "SDL.window.create.wayland.create_egl_window" PROP_WINDOW_CREATE_WAYLAND_WL_SURFACE_POINTER :: "SDL.window.create.wayland.wl_surface" PROP_WINDOW_CREATE_WIN32_HWND_POINTER :: "SDL.window.create.win32.hwnd" PROP_WINDOW_CREATE_WIN32_PIXEL_FORMAT_HWND_POINTER :: "SDL.window.create.win32.pixel_format_hwnd" PROP_WINDOW_CREATE_X11_WINDOW_NUMBER :: "SDL.window.create.x11.window" +PROP_WINDOW_CREATE_EMSCRIPTEN_CANVAS_ID_STRING :: "SDL.window.create.emscripten.canvas_id" +PROP_WINDOW_CREATE_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING :: "SDL.window.create.emscripten.keyboard_element" PROP_WINDOW_SHAPE_POINTER :: "SDL.window.shape" PROP_WINDOW_HDR_ENABLED_BOOLEAN :: "SDL.window.HDR_enabled" @@ -298,7 +311,7 @@ PROP_WINDOW_KMSDRM_DRM_FD_NUMBER :: "SDL.window.kmsdrm.drm_ PROP_WINDOW_KMSDRM_GBM_DEVICE_POINTER :: "SDL.window.kmsdrm.gbm_dev" PROP_WINDOW_COCOA_WINDOW_POINTER :: "SDL.window.cocoa.window" PROP_WINDOW_COCOA_METAL_VIEW_TAG_NUMBER :: "SDL.window.cocoa.metal_view_tag" -PROP_WINDOW_OPENVR_OVERLAY_ID :: "SDL.window.openvr.overlay_id" +PROP_WINDOW_OPENVR_OVERLAY_ID_NUMBER :: "SDL.window.openvr.overlay_id" PROP_WINDOW_VIVANTE_DISPLAY_POINTER :: "SDL.window.vivante.display" PROP_WINDOW_VIVANTE_WINDOW_POINTER :: "SDL.window.vivante.window" PROP_WINDOW_VIVANTE_SURFACE_POINTER :: "SDL.window.vivante.surface" @@ -317,6 +330,8 @@ PROP_WINDOW_WAYLAND_XDG_POSITIONER_POINTER :: "SDL.window.wayland.xdg PROP_WINDOW_X11_DISPLAY_POINTER :: "SDL.window.x11.display" PROP_WINDOW_X11_SCREEN_NUMBER :: "SDL.window.x11.screen" PROP_WINDOW_X11_WINDOW_NUMBER :: "SDL.window.x11.window" +PROP_WINDOW_EMSCRIPTEN_CANVAS_ID_STRING :: "SDL.window.emscripten.canvas_id" +PROP_WINDOW_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING :: "SDL.window.emscripten.keyboard_element" WINDOW_SURFACE_VSYNC_DISABLED :: 0 WINDOW_SURFACE_VSYNC_ADAPTIVE :: -1 @@ -377,6 +392,7 @@ foreign lib { SetWindowBordered :: proc(window: ^Window, bordered: bool) -> bool --- SetWindowResizable :: proc(window: ^Window, resizable: bool) -> bool --- SetWindowAlwaysOnTop :: proc(window: ^Window, on_top: bool) -> bool --- + SetWindowFillDocument :: proc(window: ^Window, fill: bool) -> bool --- ShowWindow :: proc(window: ^Window) -> bool --- HideWindow :: proc(window: ^Window) -> bool --- RaiseWindow :: proc(window: ^Window) -> bool --- @@ -427,6 +443,10 @@ foreign lib { SetWindowHitTest :: proc(window: ^Window, callback: HitTest, callback_data: rawptr) -> bool --- SetWindowShape :: proc(window: ^Window, shape: ^Surface) -> bool --- FlashWindow :: proc(window: ^Window, operation: FlashOperation) -> bool --- + SetWindowProgressState :: proc(window: ^Window, state: ProgressState) -> bool --- + GetWindowProgressState :: proc(window: ^Window) -> ProgressState --- + SetWindowProgressValue :: proc(window: ^Window, value: f32) -> bool --- + GetWindowProgressValue :: proc(window: ^Window) -> f32 --- DestroyWindow :: proc(window: ^Window) --- ScreenSaverEnabled :: proc() -> bool --- EnableScreenSaver :: proc() -> bool --- @@ -461,4 +481,4 @@ foreign lib { // Used by vendor:OpenGL gl_set_proc_address :: proc(p: rawptr, name: cstring) { (^FunctionPointer)(p)^ = GL_GetProcAddress(name) -} \ No newline at end of file +} diff --git a/vendor/stb/image/stb_image_wasm.odin b/vendor/stb/image/stb_image_wasm.odin index f43012383..cfad4725a 100644 --- a/vendor/stb/image/stb_image_wasm.odin +++ b/vendor/stb/image/stb_image_wasm.odin @@ -1,4 +1,4 @@ #+build wasm32, wasm64p32 package stb_image -@(require) import _ "vendor:libc" +@(require) import _ "vendor:libc-shim" diff --git a/vendor/stb/rect_pack/stb_rect_pack_wasm.odin b/vendor/stb/rect_pack/stb_rect_pack_wasm.odin index c4e2e5160..c9b6f3de8 100644 --- a/vendor/stb/rect_pack/stb_rect_pack_wasm.odin +++ b/vendor/stb/rect_pack/stb_rect_pack_wasm.odin @@ -1,4 +1,4 @@ #+build wasm32, wasm64p32 package stb_rect_pack -@(require) import _ "vendor:libc" +@(require) import _ "vendor:libc-shim" diff --git a/vendor/stb/src/Makefile b/vendor/stb/src/Makefile index 194ea5e75..94ba4d5bf 100644 --- a/vendor/stb/src/Makefile +++ b/vendor/stb/src/Makefile @@ -8,12 +8,12 @@ endif wasm: mkdir -p ../lib - $(CC) -c -Os --target=wasm32 --sysroot=$(shell odin root)/vendor/libc stb_image.c -o ../lib/stb_image_wasm.o -DSTBI_NO_STDIO - $(CC) -c -Os --target=wasm32 --sysroot=$(shell odin root)/vendor/libc stb_image_write.c -o ../lib/stb_image_write_wasm.o -DSTBI_WRITE_NO_STDIO - $(CC) -c -Os --target=wasm32 --sysroot=$(shell odin root)/vendor/libc stb_image_resize.c -o ../lib/stb_image_resize_wasm.o - $(CC) -c -Os --target=wasm32 --sysroot=$(shell odin root)/vendor/libc stb_truetype.c -o ../lib/stb_truetype_wasm.o - # $(CC) -c -Os --target=wasm32 --sysroot=$(shell odin root)/vendor/libc stb_vorbis.c -o ../lib/stb_vorbis_wasm.o -DSTB_VORBIS_NO_STDIO - $(CC) -c -Os --target=wasm32 --sysroot=$(shell odin root)/vendor/libc stb_rect_pack.c -o ../lib/stb_rect_pack_wasm.o + $(CC) -c -Os --target=wasm32 --sysroot=$(shell odin root)/vendor/libc-shim stb_image.c -o ../lib/stb_image_wasm.o -DSTBI_NO_STDIO + $(CC) -c -Os --target=wasm32 --sysroot=$(shell odin root)/vendor/libc-shim stb_image_write.c -o ../lib/stb_image_write_wasm.o -DSTBI_WRITE_NO_STDIO + $(CC) -c -Os --target=wasm32 --sysroot=$(shell odin root)/vendor/libc-shim stb_image_resize.c -o ../lib/stb_image_resize_wasm.o + $(CC) -c -Os --target=wasm32 --sysroot=$(shell odin root)/vendor/libc-shim stb_truetype.c -o ../lib/stb_truetype_wasm.o + # $(CC) -c -Os --target=wasm32 --sysroot=$(shell odin root)/vendor/libc-shim stb_vorbis.c -o ../lib/stb_vorbis_wasm.o -DSTB_VORBIS_NO_STDIO + $(CC) -c -Os --target=wasm32 --sysroot=$(shell odin root)/vendor/libc-shim stb_rect_pack.c -o ../lib/stb_rect_pack_wasm.o $(CC) -c -Os --target=wasm32 stb_sprintf.c -o ../lib/stb_sprintf_wasm.o unix: diff --git a/vendor/stb/truetype/stb_truetype_wasm.odin b/vendor/stb/truetype/stb_truetype_wasm.odin index f36239086..727ba3ef0 100644 --- a/vendor/stb/truetype/stb_truetype_wasm.odin +++ b/vendor/stb/truetype/stb_truetype_wasm.odin @@ -1,4 +1,4 @@ #+build wasm32, wasm64p32 package stb_truetype -@(require) import _ "vendor:libc" +@(require) import _ "vendor:libc-shim" diff --git a/vendor/wasm/WebGL/webgl.odin b/vendor/wasm/WebGL/webgl.odin index 5616f3660..d607ec743 100644 --- a/vendor/wasm/WebGL/webgl.odin +++ b/vendor/wasm/WebGL/webgl.odin @@ -3,6 +3,7 @@ package webgl foreign import "webgl" import glm "core:math/linalg/glsl" +import "base:runtime" Enum :: distinct u32 @@ -25,6 +26,12 @@ ContextAttribute :: enum u32 { } ContextAttributes :: distinct bit_set[ContextAttribute; u32] +ActiveInfo :: struct { + size: int, + type: Enum, + name: string, +} + DEFAULT_CONTEXT_ATTRIBUTES :: ContextAttributes{} @(default_calling_convention="contextless") @@ -106,6 +113,7 @@ foreign webgl { Flush :: proc() --- FramebufferRenderbuffer :: proc(target, attachment, renderbufertarget: Enum, renderbuffer: Renderbuffer) --- FramebufferTexture2D :: proc(target, attachment, textarget: Enum, texture: Texture, level: i32) --- + CheckFramebufferStatus :: proc(target: Enum) -> Enum --- FrontFace :: proc(mode: Enum) --- GenerateMipmap :: proc(target: Enum) --- @@ -260,7 +268,6 @@ UniformMatrix4fv :: proc "contextless" (location: i32, m: glm.mat4) { value := transmute([4*4]f32)m _UniformMatrix4fv(location, &value[0]) } - GetShaderiv :: proc "contextless" (shader: Shader, pname: Enum) -> (p: i32) { foreign webgl { @(link_name="GetShaderiv") @@ -270,6 +277,79 @@ GetShaderiv :: proc "contextless" (shader: Shader, pname: Enum) -> (p: i32) { return } +GetActiveAttribBuf :: proc "contextless" (program: Program, index: u32, name_buf: []byte) -> (info: ActiveInfo) { + foreign webgl { + @(link_name="GetActiveAttrib") + _GetActiveAttrib :: proc "contextless" (shader: Program, index: u32, size: ^int, type: ^Enum, name_buf: []byte, name_len: ^int) --- + } + name_len: int + _GetActiveAttrib(program, index, &info.size, &info.type, name_buf, &name_len) + info.name = string(name_buf[:name_len]) + return +} + +GetActiveAttribAlloc :: proc(program: Program, index: u32, allocator: runtime.Allocator, loc := #caller_location) -> (info: ActiveInfo) { + foreign webgl { + @(link_name="GetActiveAttrib") + _GetActiveAttrib :: proc "contextless" (shader: Program, index: u32, size: ^int, type: ^Enum, name_buf: []byte, name_len: ^int) --- + } + + name_len: int + + // Passing {} to the buf but giving it a name_len ptr will write the needed len into that int + _GetActiveAttrib(program, index, &info.size, &info.type, {}, &name_len) + + if name_len > 0 { + name_buf := make([]byte, name_len, allocator, loc) + _GetActiveAttrib(program, index, &info.size, &info.type, name_buf, &name_len) + assert(name_len == len(name_buf)) + info.name = string(name_buf[:name_len]) + } + + return +} + +GetActiveAttrib :: proc { + GetActiveAttribBuf, + GetActiveAttribAlloc, +} + +GetActiveUniformBuf :: proc "contextless" (program: Program, index: u32, name_buf: []byte) -> (info: ActiveInfo) { + foreign webgl { + @(link_name="GetActiveUniform") + _GetActiveUniform :: proc "contextless" (shader: Program, index: u32, size: ^int, type: ^Enum, name_buf: []byte, name_len: ^int) --- + } + name_len: int + _GetActiveUniform(program, index, &info.size, &info.type, name_buf, &name_len) + info.name = string(name_buf[:name_len]) + return +} + +GetActiveUniformAlloc :: proc(program: Program, index: u32, allocator: runtime.Allocator, loc := #caller_location) -> (info: ActiveInfo) { + foreign webgl { + @(link_name="GetActiveUniform") + _GetActiveUniform :: proc "contextless" (shader: Program, index: u32, size: ^int, type: ^Enum, name_buf: []byte, name_len: ^int) --- + } + + name_len: int + + // Passing {} to the buf but giving it a name_len ptr will write the needed len into that int + _GetActiveUniform(program, index, &info.size, &info.type, {}, &name_len) + + if name_len > 0 { + name_buf := make([]byte, name_len, allocator, loc) + _GetActiveUniform(program, index, &info.size, &info.type, name_buf, &name_len) + assert(name_len == len(name_buf)) + info.name = string(name_buf[:name_len]) + } + + return +} + +GetActiveUniform :: proc { + GetActiveUniformBuf, + GetActiveUniformAlloc, +} GetProgramInfoLog :: proc "contextless" (program: Program, buf: []byte) -> string { foreign webgl { diff --git a/vendor/wasm/WebGL/webgl2.odin b/vendor/wasm/WebGL/webgl2.odin index 66a739303..1e36fd0fd 100644 --- a/vendor/wasm/WebGL/webgl2.odin +++ b/vendor/wasm/WebGL/webgl2.odin @@ -3,6 +3,7 @@ package webgl foreign import "webgl2" import "base:intrinsics" +import "base:runtime" import glm "core:math/linalg/glsl" Query :: distinct u32 @@ -103,14 +104,21 @@ foreign webgl2 { GetUniformBlockIndex :: proc(program: Program, uniformBlockName: string) -> i32 --- UniformBlockBinding :: proc(program: Program, uniformBlockIndex: i32, uniformBlockBinding: i32) --- + // if `pname` is `UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES` then an array will be written at + // `params`, in that case the length `params` need to have is given first querying using `pname` + // `UNIFORM_BLOCK_ACTIVE_UNIFORMS`. + GetActiveUniformBlockParameter :: proc(program: Program, uniformBlockIndex: i32, pname: Enum, params: [^]i32) --- + GetActiveUniforms :: proc(program: Program, uniformIndices: []u32, pname: Enum, res: [^]i32) --- + CreateVertexArray :: proc() -> VertexArrayObject --- DeleteVertexArray :: proc(vertexArray: VertexArrayObject) --- IsVertexArray :: proc(vertexArray: VertexArrayObject) -> bool --- BindVertexArray :: proc(vertexArray: VertexArrayObject) --- } -GetActiveUniformBlockName :: proc(program: Program, uniformBlockIndex: i32, buf: []byte) -> string { +GetActiveUniformBlockNameBuf :: proc(program: Program, uniformBlockIndex: i32, buf: []byte) -> string { foreign webgl2 { + @(link_name="GetActiveUniformBlockName") _GetActiveUniformBlockName :: proc "contextless" (program: Program, uniformBlockIndex: i32, buf: []byte, length: ^int) --- } n: int @@ -118,6 +126,28 @@ GetActiveUniformBlockName :: proc(program: Program, uniformBlockIndex: i32, buf: return string(buf[:n]) } +GetActiveUniformBlockNameAlloc :: proc(program: Program, uniformBlockIndex: i32, allocator: runtime.Allocator, loc := #caller_location) -> string { + foreign webgl2 { + @(link_name="GetActiveUniformBlockName") + _GetActiveUniformBlockName :: proc "contextless" (program: Program, uniformBlockIndex: i32, buf: []byte, length: ^int) --- + } + n: int + _GetActiveUniformBlockName(program, uniformBlockIndex, {}, &n) + + if n > 0 { + buf := make([]byte, n, allocator, loc) + _GetActiveUniformBlockName(program, uniformBlockIndex, buf, &n) + assert(n == len(buf)) + return string(buf[:n]) + } + + return "" +} + +GetActiveUniformBlockName :: proc { + GetActiveUniformBlockNameBuf, + GetActiveUniformBlockNameAlloc, +} Uniform1uiv :: proc "contextless" (location: i32, v: u32) { Uniform1ui(location, v) @@ -134,6 +164,7 @@ Uniform4uiv :: proc "contextless" (location: i32, v: glm.uvec4) { UniformMatrix3x2fv :: proc "contextless" (location: i32, m: glm.mat3x2) { foreign webgl2 { + @(link_name="UniformMatrix3x2fv") _UniformMatrix3x2fv :: proc "contextless" (location: i32, addr: [^]f32) --- } array := intrinsics.matrix_flatten(m) @@ -141,6 +172,7 @@ UniformMatrix3x2fv :: proc "contextless" (location: i32, m: glm.mat3x2) { } UniformMatrix4x2fv :: proc "contextless" (location: i32, m: glm.mat4x2) { foreign webgl2 { + @(link_name="UniformMatrix4x2fv") _UniformMatrix4x2fv :: proc "contextless" (location: i32, addr: [^]f32) --- } array := intrinsics.matrix_flatten(m) @@ -148,6 +180,7 @@ UniformMatrix4x2fv :: proc "contextless" (location: i32, m: glm.mat4x2) { } UniformMatrix2x3fv :: proc "contextless" (location: i32, m: glm.mat2x3) { foreign webgl2 { + @(link_name="UniformMatrix2x3fv") _UniformMatrix2x3fv :: proc "contextless" (location: i32, addr: [^]f32) --- } array := intrinsics.matrix_flatten(m) @@ -155,6 +188,7 @@ UniformMatrix2x3fv :: proc "contextless" (location: i32, m: glm.mat2x3) { } UniformMatrix4x3fv :: proc "contextless" (location: i32, m: glm.mat4x3) { foreign webgl2 { + @(link_name="UniformMatrix4x3fv") _UniformMatrix4x3fv :: proc "contextless" (location: i32, addr: [^]f32) --- } array := intrinsics.matrix_flatten(m) @@ -162,6 +196,7 @@ UniformMatrix4x3fv :: proc "contextless" (location: i32, m: glm.mat4x3) { } UniformMatrix2x4fv :: proc "contextless" (location: i32, m: glm.mat2x4) { foreign webgl2 { + @(link_name="UniformMatrix2x4fv") _UniformMatrix2x4fv :: proc "contextless" (location: i32, addr: [^]f32) --- } array := intrinsics.matrix_flatten(m) @@ -169,6 +204,7 @@ UniformMatrix2x4fv :: proc "contextless" (location: i32, m: glm.mat2x4) { } UniformMatrix3x4fv :: proc "contextless" (location: i32, m: glm.mat3x4) { foreign webgl2 { + @(link_name="UniformMatrix3x4fv") _UniformMatrix3x4fv :: proc "contextless" (location: i32, addr: [^]f32) --- } array := intrinsics.matrix_flatten(m) diff --git a/vendor/x11/xlib/xlib_keysym.odin b/vendor/x11/xlib/xlib_keysym.odin index 61284c723..267b77b1c 100644 --- a/vendor/x11/xlib/xlib_keysym.odin +++ b/vendor/x11/xlib/xlib_keysym.odin @@ -1,7 +1,7 @@ #+build linux, freebsd, openbsd package xlib -KeySym :: enum u32 { +KeySym :: enum uint { XK_BackSpace = 0xff08, /* Back space, back char */ XK_Tab = 0xff09, XK_Linefeed = 0xff0a, /* Linefeed, LF */ diff --git a/vendor/x11/xlib/xlib_procs.odin b/vendor/x11/xlib/xlib_procs.odin index c33c6d351..3886bbead 100644 --- a/vendor/x11/xlib/xlib_procs.odin +++ b/vendor/x11/xlib/xlib_procs.odin @@ -241,7 +241,7 @@ foreign xlib { window: Window, pixel: uint, ) --- - SetWindowBackgroundMap :: proc( + SetWindowBackgroundPixmap :: proc( display: ^Display, window: Window, pixmap: Pixmap, @@ -2068,7 +2068,7 @@ foreign xlib { Xutf8LookupString :: proc( ic: XIC, event: ^XKeyPressedEvent, - buffer_return: ^cstring, + buffer_return: cstring, bytes_buffer: i32, keysym_return: ^KeySym, status_return: ^LookupStringStatus,