Merge tag 'dev-2025-11'

This commit is contained in:
2025-11-05 22:27:46 -05:00
213 changed files with 4956 additions and 966 deletions
+14 -23
View File
@@ -1,26 +1,17 @@
Copyright (c) 2016-2024 Ginger Bill. All rights reserved.
Copyright (c) 2016-2025 Ginger Bill. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
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.
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
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:
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
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.
+5
View File
@@ -244,6 +244,11 @@ constant_utf16_cstring :: proc($literal: string) -> [^]u16 ---
constant_log2 :: proc($v: $T) -> T where type_is_integer(T) ---
constant_floor :: proc($v: $T) -> T where type_is_integer(T) || type_is_float(T) ---
constant_trunc :: proc($v: $T) -> T where type_is_integer(T) || type_is_float(T) ---
constant_ceil :: proc($v: $T) -> T where type_is_integer(T) || type_is_float(T) ---
constant_round :: proc($v: $T) -> T where type_is_integer(T) || type_is_float(T) ---
// SIMD related
simd_add :: proc(a, b: #simd[N]T) -> #simd[N]T ---
simd_sub :: proc(a, b: #simd[N]T) -> #simd[N]T ---
+1 -1
View File
@@ -15,7 +15,7 @@
//
// IMPORTANT NOTE(bill): `type_info_of` cannot be used within a
// #shared_global_scope due to the internals of the compiler.
// This could change at a later date if the all these data structures are
// This could change at a later date if all these data structures are
// implemented within the compiler rather than in this "preload" file
//
#+no-instrumentation
+115
View File
@@ -504,6 +504,121 @@ append_soa :: proc{
}
// `append_nothing_soa` appends an empty value to a dynamic SOA array. It returns `1, nil` if successful, and `0, err` when it was not possible,
// whatever `err` happens to be.
@builtin
append_nothing_soa :: proc(array: ^$T/#soa[dynamic]$E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error {
if array == nil {
return 0, nil
}
prev_len := len(array)
resize_soa(array, len(array)+1, loc) or_return
return len(array)-prev_len, nil
}
// `inject_at_elem_soa` injects an element in a dynamic SOA array at a specified index and moves the previous elements after that index "across"
@builtin
inject_at_elem_soa :: proc(array: ^$T/#soa[dynamic]$E, #any_int index: int, #no_broadcast arg: E, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error {
when !ODIN_NO_BOUNDS_CHECK {
ensure(index >= 0, "Index must be positive.", loc)
}
if array == nil {
return
}
n := max(len(array), index)
m :: 1
new_len := n + m
resize_soa(array, new_len, loc) or_return
when size_of(E) != 0 {
ti := type_info_base(type_info_of(typeid_of(T)))
si := &ti.variant.(Type_Info_Struct)
field_count := len(E) when intrinsics.type_is_array(E) else intrinsics.type_struct_field_count(E)
item_offset := 0
arg_copy := arg
arg_ptr := &arg_copy
for i in 0..<field_count {
data := (^uintptr)(uintptr(array) + uintptr(si.offsets[i]))^
type := si.types[i].variant.(Type_Info_Multi_Pointer).elem
item_offset = align_forward_int(item_offset, type.align)
src := data + uintptr(index * type.size)
dst := data + uintptr((index + m) * type.size)
mem_copy(rawptr(dst), rawptr(src), (n - index) * type.size)
mem_copy(rawptr(src), rawptr(uintptr(arg_ptr) + uintptr(item_offset)), type.size)
item_offset += type.size
}
}
ok = true
return
}
// `inject_at_elems_soa` injects multiple elements in a dynamic SOA array at a specified index and moves the previous elements after that index "across"
@builtin
inject_at_elems_soa :: proc(array: ^$T/#soa[dynamic]$E, #any_int index: int, #no_broadcast args: ..E, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error {
when !ODIN_NO_BOUNDS_CHECK {
ensure(index >= 0, "Index must be positive.", loc)
}
if array == nil {
return
}
if len(args) == 0 {
ok = true
return
}
n := max(len(array), index)
m := len(args)
new_len := n + m
resize_soa(array, new_len, loc) or_return
when size_of(E) != 0 {
ti := type_info_base(type_info_of(typeid_of(T)))
si := &ti.variant.(Type_Info_Struct)
field_count := len(E) when intrinsics.type_is_array(E) else intrinsics.type_struct_field_count(E)
item_offset := 0
args_ptr := &args[0]
for i in 0..<field_count {
data := (^uintptr)(uintptr(array) + uintptr(si.offsets[i]))^
type := si.types[i].variant.(Type_Info_Multi_Pointer).elem
item_offset = align_forward_int(item_offset, type.align)
src := data + uintptr(index * type.size)
dst := data + uintptr((index + m) * type.size)
mem_copy(rawptr(dst), rawptr(src), (n - index) * type.size)
for j in 0..<len(args) {
d := rawptr(src + uintptr(j*type.size))
s := rawptr(uintptr(args_ptr) + uintptr(item_offset) + uintptr(j*size_of(E)))
mem_copy(d, s, type.size)
}
item_offset += type.size
}
}
ok = true
return
}
// `inject_at_soa` injects something into a dynamic SOA array at a specified index and moves the previous elements after that index "across"
@builtin inject_at_soa :: proc{inject_at_elem_soa, inject_at_elems_soa}
delete_soa_slice :: proc(array: $T/#soa[]$E, allocator := context.allocator, loc := #caller_location) -> Allocator_Error {
field_count :: len(E) when intrinsics.type_is_array(E) else intrinsics.type_struct_field_count(E)
when field_count != 0 {
-2
View File
@@ -6,8 +6,6 @@ _ :: intrinsics
// High performance, cache-friendly, open-addressed Robin Hood hashing hash map
// data structure with various optimizations for Odin.
//
// Copyright 2022 (c) Dale Weiler
//
// The core of the hash map data structure is the Raw_Map struct which is a
// type-erased representation of the map. This type-erased representation is
// used in two ways: static and dynamic. When static type information is known,
+4
View File
@@ -5,3 +5,7 @@ _OS_Errno :: distinct int
stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
return _stderr_write(data)
}
exit :: proc "contextless" (code: int) -> ! {
_exit(code)
}
+8
View File
@@ -24,3 +24,11 @@ _stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
}
return int(ret), 0
}
_exit :: proc "contextless" (code: int) -> ! {
@(default_calling_convention="c")
foreign libc {
exit :: proc(status: i32) -> ! ---
}
exit(i32(code))
}
+10
View File
@@ -26,3 +26,13 @@ _stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
return 0, _OS_Errno(__error()^)
}
}
foreign import libc "system:System"
_exit :: proc "contextless" (code: int) -> ! {
@(default_calling_convention="c")
foreign libc {
exit :: proc(status: i32) -> ! ---
}
exit(i32(code))
}
@@ -6,3 +6,7 @@ package runtime
_stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
return 0, -1
}
_exit :: proc "contextless" (code: int) -> ! {
trap()
}
+6
View File
@@ -19,3 +19,9 @@ _stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
}
return int(ret), 0
}
_exit :: proc "contextless" (code: int) -> ! {
trap()
}
+5
View File
@@ -11,3 +11,8 @@ _stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
write(1, data)
return len(data), 0
}
_exit :: proc "contextless" (code: int) -> ! {
trap()
}
+14
View File
@@ -24,3 +24,17 @@ _stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
}
return ret, 0
}
_exit :: proc "contextless" (code: int) -> ! {
SYS_exit_group ::
231 when ODIN_ARCH == .amd64 else
248 when ODIN_ARCH == .arm32 else
94 when ODIN_ARCH == .arm64 else
252 when ODIN_ARCH == .i386 else
94 when ODIN_ARCH == .riscv64 else
0
intrinsics.syscall(uintptr(SYS_exit_group), uintptr(i32(code)))
unreachable()
}
+5
View File
@@ -41,3 +41,8 @@ _stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
return len(data), 0
}
_exit :: proc "contextless" (code: int) -> ! {
trap()
}
+8
View File
@@ -23,6 +23,9 @@ foreign wasi {
argv: [^]cstring,
argv_buf: [^]byte,
) -> u16 ---
@(private="file")
proc_exit :: proc(rval: u32) -> ! ---
}
_stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
@@ -53,3 +56,8 @@ _wasi_setup_args :: proc() {
delete(args_buf)
}
}
_exit :: proc "contextless" (code: int) -> ! {
proc_exit(u32(code))
}
+6
View File
@@ -14,6 +14,8 @@ foreign kernel32 {
SetHandleInformation :: proc(hObject: rawptr, dwMask: u32, dwFlags: u32) -> b32 ---
WriteFile :: proc(hFile: rawptr, lpBuffer: rawptr, nNumberOfBytesToWrite: u32, lpNumberOfBytesWritten: ^u32, lpOverlapped: rawptr) -> b32 ---
GetLastError :: proc() -> u32 ---
ExitProcess :: proc(code: u32) -> ! ---
}
_stderr_write :: proc "contextless" (data: []byte) -> (n: int, err: _OS_Errno) #no_bounds_check {
@@ -49,3 +51,7 @@ _stderr_write :: proc "contextless" (data: []byte) -> (n: int, err: _OS_Errno) #
n = int(total_write)
return
}
_exit :: proc "contextless" (code: int) -> ! {
ExitProcess(u32(code))
}
+7 -16
View File
@@ -28,7 +28,8 @@ error() {
# Brew advises people not to add llvm to their $PATH, so try and use brew to find it.
if [ -z "$LLVM_CONFIG" ] && [ -n "$(command -v brew)" ]; then
if [ -n "$(command -v $(brew --prefix llvm@20)/bin/llvm-config)" ]; then LLVM_CONFIG="$(brew --prefix llvm@20)/bin/llvm-config"
if [ -n "$(command -v $(brew --prefix llvm@21)/bin/llvm-config)" ]; then LLVM_CONFIG="$(brew --prefix llvm@21)/bin/llvm-config"
elif [ -n "$(command -v $(brew --prefix llvm@20)/bin/llvm-config)" ]; then LLVM_CONFIG="$(brew --prefix llvm@20)/bin/llvm-config"
elif [ -n "$(command -v $(brew --prefix llvm@19)/bin/llvm-config)" ]; then LLVM_CONFIG="$(brew --prefix llvm@19)/bin/llvm-config"
elif [ -n "$(command -v $(brew --prefix llvm@18)/bin/llvm-config)" ]; then LLVM_CONFIG="$(brew --prefix llvm@18)/bin/llvm-config"
elif [ -n "$(command -v $(brew --prefix llvm@17)/bin/llvm-config)" ]; then LLVM_CONFIG="$(brew --prefix llvm@17)/bin/llvm-config"
@@ -38,23 +39,19 @@ fi
if [ -z "$LLVM_CONFIG" ]; then
# darwin, linux, openbsd
if [ -n "$(command -v llvm-config-20)" ]; then LLVM_CONFIG="llvm-config-20"
if [ -n "$(command -v llvm-config-21)" ]; then LLVM_CONFIG="llvm-config-21"
elif [ -n "$(command -v llvm-config-20)" ]; then LLVM_CONFIG="llvm-config-20"
elif [ -n "$(command -v llvm-config-19)" ]; then LLVM_CONFIG="llvm-config-19"
elif [ -n "$(command -v llvm-config-18)" ]; then LLVM_CONFIG="llvm-config-18"
elif [ -n "$(command -v llvm-config-17)" ]; then LLVM_CONFIG="llvm-config-17"
elif [ -n "$(command -v llvm-config-14)" ]; then LLVM_CONFIG="llvm-config-14"
elif [ -n "$(command -v llvm-config-13)" ]; then LLVM_CONFIG="llvm-config-13"
elif [ -n "$(command -v llvm-config-12)" ]; then LLVM_CONFIG="llvm-config-12"
elif [ -n "$(command -v llvm-config-11)" ]; then LLVM_CONFIG="llvm-config-11"
# freebsd
elif [ -n "$(command -v llvm-config21)" ]; then LLVM_CONFIG="llvm-config21"
elif [ -n "$(command -v llvm-config20)" ]; then LLVM_CONFIG="llvm-config20"
elif [ -n "$(command -v llvm-config19)" ]; then LLVM_CONFIG="llvm-config19"
elif [ -n "$(command -v llvm-config18)" ]; then LLVM_CONFIG="llvm-config18"
elif [ -n "$(command -v llvm-config17)" ]; then LLVM_CONFIG="llvm-config17"
elif [ -n "$(command -v llvm-config14)" ]; then LLVM_CONFIG="llvm-config14"
elif [ -n "$(command -v llvm-config13)" ]; then LLVM_CONFIG="llvm-config13"
elif [ -n "$(command -v llvm-config12)" ]; then LLVM_CONFIG="llvm-config12"
elif [ -n "$(command -v llvm-config11)" ]; then LLVM_CONFIG="llvm-config11"
# fallback
elif [ -n "$(command -v llvm-config)" ]; then LLVM_CONFIG="llvm-config"
else
@@ -75,18 +72,12 @@ LLVM_VERSION_MAJOR="$(echo $LLVM_VERSION | awk -F. '{print $1}')"
LLVM_VERSION_MINOR="$(echo $LLVM_VERSION | awk -F. '{print $2}')"
LLVM_VERSION_PATCH="$(echo $LLVM_VERSION | awk -F. '{print $3}')"
if [ $LLVM_VERSION_MAJOR -lt 11 ] || ([ $LLVM_VERSION_MAJOR -gt 14 ] && [ $LLVM_VERSION_MAJOR -lt 17 ]) || [ $LLVM_VERSION_MAJOR -gt 20 ]; then
error "Invalid LLVM version $LLVM_VERSION: must be 11, 12, 13, 14, 17, 18, 19 or 20"
if [ $LLVM_VERSION_MAJOR -lt 14 ] || ([ $LLVM_VERSION_MAJOR -gt 14 ] && [ $LLVM_VERSION_MAJOR -lt 17 ]) || [ $LLVM_VERSION_MAJOR -gt 21 ]; then
error "Invalid LLVM version $LLVM_VERSION: must be 14, 17, 18, 19, 20, or 21"
fi
case "$OS_NAME" in
Darwin)
if [ "$OS_ARCH" = "arm64" ]; then
if [ $LLVM_VERSION_MAJOR -lt 13 ]; then
error "Invalid LLVM version $LLVM_VERSION: Darwin Arm64 requires LLVM 13, 14, 17, 18, 19 or 20"
fi
fi
darwin_sysroot=
if [ $(which xcrun) ]; then
darwin_sysroot="--sysroot $(xcrun --sdk macosx --show-sdk-path)"
+10 -1
View File
@@ -49,7 +49,7 @@ int_least64_t :: builtin.i64
uint_least64_t :: builtin.u64
// Same on Windows, Linux, and FreeBSD
when ODIN_ARCH == .i386 || ODIN_ARCH == .amd64 {
when ODIN_ARCH == .i386 {
int_fast8_t :: builtin.i8
uint_fast8_t :: builtin.u8
int_fast16_t :: builtin.i32
@@ -58,6 +58,15 @@ when ODIN_ARCH == .i386 || ODIN_ARCH == .amd64 {
uint_fast32_t :: builtin.u32
int_fast64_t :: builtin.i64
uint_fast64_t :: builtin.u64
} else when ODIN_ARCH == .amd64 {
int_fast8_t :: builtin.i8
uint_fast8_t :: builtin.u8
int_fast16_t :: long
uint_fast16_t :: ulong
int_fast32_t :: long
uint_fast32_t :: ulong
int_fast64_t :: builtin.i64
uint_fast64_t :: builtin.u64
} else {
int_fast8_t :: builtin.i8
uint_fast8_t :: builtin.u8
+1 -1
View File
@@ -3,7 +3,7 @@ package compress
/*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Jeroen van Rijn: Initial implementation, optimization.
+1 -1
View File
@@ -82,7 +82,7 @@ package compress_gzip
/*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Jeroen van Rijn: Initial implementation.
+1 -1
View File
@@ -2,7 +2,7 @@ package compress_gzip
/*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Jeroen van Rijn: Initial implementation.
+1 -1
View File
@@ -3,7 +3,7 @@ package compress_shoco
/*
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Jeroen van Rijn: Initial implementation.
+1 -1
View File
@@ -44,7 +44,7 @@ package compress_zlib
/*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Jeroen van Rijn: Initial implementation.
+1 -1
View File
@@ -3,7 +3,7 @@ package compress_zlib
/*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Jeroen van Rijn: Initial implementation, optimization.
+1 -1
View File
@@ -309,7 +309,7 @@ Example:
import "core:container/small_array"
import "core:fmt"
non_zero_resize :: proc() {
non_zero_resize_example :: proc() {
a: small_array.Small_Array(5, int)
small_array.push_back(&a, 1)
+1 -1
View File
@@ -29,4 +29,4 @@ constant-time byte comparison.
## License
This library is made available under the BSD-3 license.
This library is made available under the zlib license.
+1 -1
View File
@@ -2,7 +2,7 @@ package _blake2
/*
Copyright 2021 zhibog
Made available under the BSD-3 license.
Made available under Odin's license.
List of contributors:
zhibog, dotbmp: Initial implementation.
+1 -1
View File
@@ -2,7 +2,7 @@ package _sha3
/*
Copyright 2021 zhibog
Made available under the BSD-3 license.
Made available under Odin's license.
List of contributors:
zhibog, dotbmp: Initial implementation.
+1 -1
View File
@@ -9,7 +9,7 @@ package blake2b
/*
Copyright 2021 zhibog
Made available under the BSD-3 license.
Made available under Odin's license.
List of contributors:
zhibog, dotbmp: Initial implementation.
+1 -1
View File
@@ -9,7 +9,7 @@ package blake2s
/*
Copyright 2021 zhibog
Made available under the BSD-3 license.
Made available under Odin's license.
List of contributors:
zhibog, dotbmp: Initial implementation.
+1 -1
View File
@@ -2,7 +2,7 @@ package crypto_hash
/*
Copyright 2021 zhibog
Made available under the BSD-3 license.
Made available under Odin's license.
List of contributors:
zhibog, dotbmp: Initial implementation.
+1 -1
View File
@@ -10,7 +10,7 @@ package keccak
/*
Copyright 2021 zhibog
Made available under the BSD-3 license.
Made available under Odin's license.
List of contributors:
zhibog, dotbmp: Initial implementation.
+1 -1
View File
@@ -12,7 +12,7 @@ package md5
/*
Copyright 2021 zhibog
Made available under the BSD-3 license.
Made available under Odin's license.
List of contributors:
zhibog, dotbmp: Initial implementation.
+1 -1
View File
@@ -13,7 +13,7 @@ package sha1
/*
Copyright 2021 zhibog
Made available under the BSD-3 license.
Made available under Odin's license.
List of contributors:
zhibog, dotbmp: Initial implementation.
+1 -1
View File
@@ -9,7 +9,7 @@ package sha2
/*
Copyright 2021 zhibog
Made available under the BSD-3 license.
Made available under Odin's license.
List of contributors:
zhibog, dotbmp: Initial implementation.
+1 -1
View File
@@ -12,7 +12,7 @@ package sha3
/*
Copyright 2021 zhibog
Made available under the BSD-3 license.
Made available under Odin's license.
List of contributors:
zhibog, dotbmp: Initial implementation.
+1 -1
View File
@@ -11,7 +11,7 @@ package shake
/*
Copyright 2021 zhibog
Made available under the BSD-3 license.
Made available under Odin's license.
List of contributors:
zhibog, dotbmp: Initial implementation.
+1 -1
View File
@@ -11,7 +11,7 @@ package siphash
/*
Copyright 2022 zhibog
Made available under the BSD-3 license.
Made available under Odin's license.
List of contributors:
zhibog: Initial implementation.
+1 -1
View File
@@ -8,7 +8,7 @@ package sm3
/*
Copyright 2021 zhibog
Made available under the BSD-3 license.
Made available under Odin's license.
List of contributors:
zhibog, dotbmp: Initial implementation.
+18 -14
View File
@@ -130,9 +130,9 @@ tag_time_unmarshal :: proc(_: ^Tag_Implementation, d: Decoder, _: Tag_Number, v:
case .U8, .U16, .U32, .U64, .Neg_U8, .Neg_U16, .Neg_U32, .Neg_U64:
switch &dst in v {
case time.Time:
i: i64
_unmarshal_any_ptr(d, &i, hdr) or_return
dst = time.unix(i64(i), 0)
secs: i64
_unmarshal_any_ptr(d, &secs, hdr) or_return
dst = time.unix(i64(secs), 0)
return
case:
return _unmarshal_value(d, v, hdr)
@@ -152,19 +152,23 @@ tag_time_unmarshal :: proc(_: ^Tag_Implementation, d: Decoder, _: Tag_Number, v:
case:
maj, add := _header_split(hdr)
if maj == .Other {
i := _decode_tiny_u8(add) or_return
switch &dst in v {
case time.Time:
dst = time.unix(i64(i), 0)
case:
if _assign_int(v, i) { return }
}
secs: u8
#partial switch maj {
case .Unsigned:
secs = _decode_tiny_u8(add) or_return
case .Other:
secs = u8(_decode_tiny_simple(add) or_return)
case:
return .Bad_Tag_Value
}
// Only numbers and floats are allowed in this tag.
return .Bad_Tag_Value
switch &dst in v {
case time.Time:
dst = time.unix(i64(secs), 0)
return
case:
if _assign_int(v, secs) { return }
}
}
return _unsupported(v, hdr)
+1 -1
View File
@@ -15,7 +15,7 @@ package encoding_unicode_entity
/*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Jeroen van Rijn: Initial implementation.
+14 -25
View File
@@ -1,28 +1,17 @@
BSD 3-Clause License
Copyright (c) 2024-2025 Feoramund, Ginger Bill. All rights reserved.
Copyright (c) 2024, Feoramund
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.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
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. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
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 -1
View File
@@ -2,7 +2,7 @@ package encoding_varint
/*
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Jeroen van Rijn: Initial implementation.
+1 -1
View File
@@ -4,7 +4,7 @@ package encoding_xml
An XML 1.0 / 1.1 parser
Copyright 2021-2022 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
A from-scratch XML implementation, loosely modeled on the [spec](https://www.w3.org/TR/2006/REC-xml11-20060816).
+1 -1
View File
@@ -4,7 +4,7 @@ package encoding_xml
An XML 1.0 / 1.1 parser
Copyright 2021-2022 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
This file contains helper functions.
*/
+1 -1
View File
@@ -4,7 +4,7 @@ package encoding_xml
An XML 1.0 / 1.1 parser
Copyright 2021-2022 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
A from-scratch XML implementation, loosely modeled on the [spec](https://www.w3.org/TR/2006/REC-xml11-20060816).
+1 -1
View File
@@ -3,7 +3,7 @@ package encoding_xml
An XML 1.0 / 1.1 parser
2021-2022 Jeroen van Rijn <nom@duclavier.com>.
available under Odin's BSD-3 license.
available under Odin's license.
List of contributors:
- Jeroen van Rijn: Initial implementation.
+14 -25
View File
@@ -1,28 +1,17 @@
BSD 3-Clause License
Copyright (c) 2024-2025 Feoramund, Ginger Bill. All rights reserved.
Copyright (c) 2024, Feoramund
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.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
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. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
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.
+4 -5
View File
@@ -10,14 +10,14 @@ SomeType :: struct {
My_Custom_Base_Type :: distinct u32
main :: proc() {
// Ensure the fmt._user_formatters map is initialized
// Ensure the fmt._user_formatters map is initialized
fmt.set_user_formatters(new(map[typeid]fmt.User_Formatter))
// Register custom formatters for my favorite types
err := fmt.register_user_formatter(type_info_of(SomeType).id, SomeType_Formatter)
assert(err == .None)
assert(err == .None)
err = fmt.register_user_formatter(type_info_of(My_Custom_Base_Type).id, My_Custom_Base_Formatter)
assert(err == .None)
assert(err == .None)
// Use the custom formatters.
fmt.printfln("SomeType{{42}}: '%v'", SomeType{42})
@@ -53,5 +53,4 @@ My_Custom_Base_Formatter :: proc(fi: ^fmt.Info, arg: any, verb: rune) -> bool {
return false
}
return true
}
}
+61 -7
View File
@@ -1,10 +1,27 @@
package hash
/*
Compute CRC-16 in the manner of CCITT (ITU-T V.41), using the 0x1021 polynomial.
Generator polynomial: x^16 + x^12 + x^5 + 1
Used in the UDF (DVD *.iso) disk format's Volume Descriptor Tag,
and was more historically the ITU-T V.41 CRC-16 used in the XModem protocol,
which uses 0xffff as the initial value.
*/
@(optimization_mode="favor_size")
crc16_ccitt_0x1021 :: proc "contextless" (data: []u8, seed := u16(0)) -> (result: u16) #no_bounds_check {
result = seed
#no_bounds_check for b in data {
result = result << 8 ~ _ccitt_0x1021_table[(result >> 8) ~ u16(b)]
}
return result
}
@(optimization_mode="favor_size")
crc64_ecma_182 :: proc "contextless" (data: []byte, seed := u64(0)) -> (result: u64) #no_bounds_check {
result = seed
#no_bounds_check for b in data {
result = result<<8 ~ _crc64_table_ecma_182[((result>>56) ~ u64(b)) & 0xff]
result = result << 8 ~ _crc64_table_ecma_182[((result>>56) ~ u64(b)) & 0xff]
}
return result
}
@@ -49,9 +66,7 @@ crc64_xz :: proc "contextless" (data: []byte, seed := u64(0)) -> u64 #no_bounds_
return u64(~result)
}
/*
Generator polynomial: x^64 + x^4 + x^3 + x + 1
*/
// Generator polynomial: x^64 + x^4 + x^3 + x + 1
@(optimization_mode="favor_size")
crc64_iso_3306 :: proc "contextless" (data: []byte, seed := u64(0)) -> u64 #no_bounds_check {
@@ -75,7 +90,8 @@ crc64_iso_3306_inverse :: proc "contextless" (data: []byte, seed := u64(0)) -> u
return ~result
}
@private _crc64_table_ecma_182 := [256]u64{
@(private, rodata)
_crc64_table_ecma_182 := [256]u64{
0x0000000000000000, 0x42f0e1eba9ea3693, 0x85e1c3d753d46d26, 0xc711223cfa3e5bb5,
0x493366450e42ecdf, 0x0bc387aea7a8da4c, 0xccd2a5925d9681f9, 0x8e224479f47cb76a,
0x9266cc8a1c85d9be, 0xd0962d61b56fef2d, 0x17870f5d4f51b498, 0x5577eeb6e6bb820b,
@@ -142,7 +158,8 @@ crc64_iso_3306_inverse :: proc "contextless" (data: []byte, seed := u64(0)) -> u
0x5dedc41a34bbeeb2, 0x1f1d25f19d51d821, 0xd80c07cd676f8394, 0x9afce626ce85b507,
}
@private _crc64_table_xz := [8][256]u64le{
@(private, rodata)
_crc64_table_xz := [8][256]u64le{
{
0x0000000000000000, 0xb32e4cbe03a75f6f, 0xf4843657a840a05b, 0x47aa7ae9abe7ff34,
0x7bd0c384ff8f5e33, 0xc8fe8f3afc28015c, 0x8f54f5d357cffe68, 0x3c7ab96d5468a107,
@@ -673,7 +690,8 @@ crc64_iso_3306_inverse :: proc "contextless" (data: []byte, seed := u64(0)) -> u
},
}
@private _crc64_table_iso_3306 := [256]u16{
@(private, rodata)
_crc64_table_iso_3306 := [256]u16{
0x0000, 0x01b0, 0x0360, 0x02d0,
0x06c0, 0x0770, 0x05a0, 0x0410,
0x0d80, 0x0c30, 0x0ee0, 0x0f50,
@@ -739,3 +757,39 @@ crc64_iso_3306_inverse :: proc "contextless" (data: []byte, seed := u64(0)) -> u
0x9480, 0x9530, 0x97e0, 0x9650,
0x9240, 0x93f0, 0x9120, 0x9090,
}
@(private, rodata)
_ccitt_0x1021_table := [256]u16{
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0,
}
+1 -1
View File
@@ -6,7 +6,7 @@ package xxhash
/*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license, based on the original C code.
Made available under Odin's license, based on the original C code.
List of contributors:
Jeroen van Rijn: Initial implementation.
+1 -1
View File
@@ -4,7 +4,7 @@ package xxhash
An implementation of Yann Collet's [xxhash Fast Hash Algorithm](https://cyan4973.github.io/xxHash/).
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license, based on the original C code.
Made available under Odin's license, based on the original C code.
List of contributors:
Jeroen van Rijn: Initial implementation.
+1 -1
View File
@@ -4,7 +4,7 @@ package xxhash
An implementation of Yann Collet's [xxhash Fast Hash Algorithm](https://cyan4973.github.io/xxHash/).
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license, based on the original C code.
Made available under Odin's license, based on the original C code.
List of contributors:
Jeroen van Rijn: Initial implementation.
+1 -1
View File
@@ -4,7 +4,7 @@ package xxhash
An implementation of Yann Collet's [xxhash Fast Hash Algorithm](https://cyan4973.github.io/xxHash/).
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license, based on the original C code.
Made available under Odin's license, based on the original C code.
List of contributors:
Jeroen van Rijn: Initial implementation.
+1 -1
View File
@@ -4,7 +4,7 @@ package xxhash
An implementation of Yann Collet's [xxhash Fast Hash Algorithm](https://cyan4973.github.io/xxHash/).
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license, based on the original C code.
Made available under Odin's license, based on the original C code.
List of contributors:
Jeroen van Rijn: Initial implementation.
+1 -1
View File
@@ -2,7 +2,7 @@ package image
/*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Jeroen van Rijn: Initial implementation, optimization.
+1 -1
View File
@@ -3,7 +3,7 @@ package png
/*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Jeroen van Rijn: Initial implementation.
+1 -1
View File
@@ -5,7 +5,7 @@ package qoi
/*
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Jeroen van Rijn: Initial implementation.
+1 -1
View File
@@ -3,7 +3,7 @@ package tga
/*
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Jeroen van Rijn: Initial implementation.
+1 -1
View File
@@ -2,7 +2,7 @@ package math_big
/*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
This file collects public proc maps and their aliases.
*/
+1 -1
View File
@@ -2,7 +2,7 @@ package math_big
/*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
*/
import "base:intrinsics"
+1 -1
View File
@@ -2,7 +2,7 @@ package math_big
/*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
*/
import "base:intrinsics"
+1 -1
View File
@@ -2,7 +2,7 @@ package math_big
/*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
========================== Low-level routines ==========================
+1 -1
View File
@@ -2,7 +2,7 @@ package math_big
/*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
An arbitrary precision mathematics implementation in Odin.
For the theoretical underpinnings, see Knuth's The Art of Computer Programming, Volume 2, section 4.3.
+1 -1
View File
@@ -2,7 +2,7 @@ package math_big
/*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
An arbitrary precision mathematics implementation in Odin.
For the theoretical underpinnings, see Knuth's The Art of Computer Programming, Volume 2, section 4.3.
+1 -1
View File
@@ -2,7 +2,7 @@ package math_big
/*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
An arbitrary precision mathematics implementation in Odin.
For the theoretical underpinnings, see Knuth's The Art of Computer Programming, Volume 2, section 4.3.
+1 -1
View File
@@ -3,7 +3,7 @@ package math_big
/*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
An arbitrary precision mathematics implementation in Odin.
For the theoretical underpinnings, see Knuth's The Art of Computer Programming, Volume 2, section 4.3.
+1 -1
View File
@@ -2,7 +2,7 @@ package math_big
/*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
An arbitrary precision mathematics implementation in Odin.
For the theoretical underpinnings, see Knuth's The Art of Computer Programming, Volume 2, section 4.3.
+1 -1
View File
@@ -3,7 +3,7 @@ package math_big
/*
Copyright 2021 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
A BigInt implementation in Odin.
For the theoretical underpinnings, see Knuth's The Art of Computer Programming, Volume 2, section 4.3.
+1070 -59
View File
File diff suppressed because it is too large Load Diff
+34 -208
View File
@@ -1,9 +1,8 @@
// Easing procedures and flux easing used for animations.
// Easing procedures used for animations.
package ease
import "core:math"
@require import "core:math"
import "base:intrinsics"
import "core:time"
@(private) PI_2 :: math.PI / 2
@@ -174,7 +173,7 @@ exponential_in_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_f
if p == 0.0 || p == 1.0 {
return p
}
if p < 0.5 {
return 0.5 * math.pow(2, (20 * p) - 10)
} else {
@@ -307,224 +306,51 @@ Ease :: enum {
}
@(require_results)
ease :: proc "contextless" (type: Ease, p: $T) -> T
where intrinsics.type_is_float(T) {
ease :: proc "contextless" (type: Ease, p: $T) -> T where intrinsics.type_is_float(T) {
switch type {
case .Linear: return p
case .Linear: return p
case .Quadratic_In: return quadratic_in(p)
case .Quadratic_Out: return quadratic_out(p)
case .Quadratic_In_Out: return quadratic_in_out(p)
case .Quadratic_In: return quadratic_in(p)
case .Quadratic_Out: return quadratic_out(p)
case .Quadratic_In_Out: return quadratic_in_out(p)
case .Cubic_In: return cubic_in(p)
case .Cubic_Out: return cubic_out(p)
case .Cubic_In_Out: return cubic_in_out(p)
case .Cubic_In: return cubic_in(p)
case .Cubic_Out: return cubic_out(p)
case .Cubic_In_Out: return cubic_in_out(p)
case .Quartic_In: return quartic_in(p)
case .Quartic_Out: return quartic_out(p)
case .Quartic_In_Out: return quartic_in_out(p)
case .Quartic_In: return quartic_in(p)
case .Quartic_Out: return quartic_out(p)
case .Quartic_In_Out: return quartic_in_out(p)
case .Quintic_In: return quintic_in(p)
case .Quintic_Out: return quintic_out(p)
case .Quintic_In_Out: return quintic_in_out(p)
case .Quintic_In: return quintic_in(p)
case .Quintic_Out: return quintic_out(p)
case .Quintic_In_Out: return quintic_in_out(p)
case .Sine_In: return sine_in(p)
case .Sine_Out: return sine_out(p)
case .Sine_In_Out: return sine_in_out(p)
case .Sine_In: return sine_in(p)
case .Sine_Out: return sine_out(p)
case .Sine_In_Out: return sine_in_out(p)
case .Circular_In: return circular_in(p)
case .Circular_Out: return circular_out(p)
case .Circular_In_Out: return circular_in_out(p)
case .Circular_In: return circular_in(p)
case .Circular_Out: return circular_out(p)
case .Circular_In_Out: return circular_in_out(p)
case .Exponential_In: return exponential_in(p)
case .Exponential_Out: return exponential_out(p)
case .Exponential_In: return exponential_in(p)
case .Exponential_Out: return exponential_out(p)
case .Exponential_In_Out: return exponential_in_out(p)
case .Elastic_In: return elastic_in(p)
case .Elastic_Out: return elastic_out(p)
case .Elastic_In_Out: return elastic_in_out(p)
case .Elastic_In: return elastic_in(p)
case .Elastic_Out: return elastic_out(p)
case .Elastic_In_Out: return elastic_in_out(p)
case .Back_In: return back_in(p)
case .Back_Out: return back_out(p)
case .Back_In_Out: return back_in_out(p)
case .Back_In: return back_in(p)
case .Back_Out: return back_out(p)
case .Back_In_Out: return back_in_out(p)
case .Bounce_In: return bounce_in(p)
case .Bounce_Out: return bounce_out(p)
case .Bounce_In_Out: return bounce_in_out(p)
case .Bounce_In: return bounce_in(p)
case .Bounce_Out: return bounce_out(p)
case .Bounce_In_Out: return bounce_in_out(p)
}
// in case type was invalid
return 0
}
Flux_Map :: struct($T: typeid) {
values: map[^T]Flux_Tween(T),
keys_to_be_deleted: [dynamic]^T,
}
Flux_Tween :: struct($T: typeid) {
value: ^T,
start: T,
diff: T,
goal: T,
delay: f64, // in seconds
duration: time.Duration,
progress: f64,
rate: f64,
type: Ease,
inited: bool,
// callbacks, data can be set, will be pushed to callback
data: rawptr, // by default gets set to value input
on_start: proc(flux: ^Flux_Map(T), data: rawptr),
on_update: proc(flux: ^Flux_Map(T), data: rawptr),
on_complete: proc(flux: ^Flux_Map(T), data: rawptr),
}
// init flux map to a float type and a wanted cap
@(require_results)
flux_init :: proc($T: typeid, value_capacity := 8) -> Flux_Map(T) where intrinsics.type_is_float(T) {
return {
values = make(map[^T]Flux_Tween(T), value_capacity),
keys_to_be_deleted = make([dynamic]^T, 0, value_capacity),
}
}
// delete map content
flux_destroy :: proc(flux: Flux_Map($T)) where intrinsics.type_is_float(T) {
delete(flux.values)
delete(flux.keys_to_be_deleted)
}
// clear map content, stops all animations
flux_clear :: proc(flux: ^Flux_Map($T)) where intrinsics.type_is_float(T) {
clear(&flux.values)
}
// append / overwrite existing tween value to parameters
// rest is initialized in flux_tween_init, inside update
// return value can be used to set callbacks
@(require_results)
flux_to :: proc(
flux: ^Flux_Map($T),
value: ^T,
goal: T,
type: Ease = .Quadratic_Out,
duration: time.Duration = time.Second,
delay: f64 = 0,
) -> (tween: ^Flux_Tween(T)) where intrinsics.type_is_float(T) {
if res, ok := &flux.values[value]; ok {
tween = res
} else {
flux.values[value] = {}
tween = &flux.values[value]
}
tween^ = {
value = value,
goal = goal,
duration = duration,
delay = delay,
type = type,
data = value,
}
return
}
// init internal properties
flux_tween_init :: proc(tween: ^Flux_Tween($T), duration: time.Duration) where intrinsics.type_is_float(T) {
tween.inited = true
tween.start = tween.value^
tween.diff = tween.goal - tween.value^
s := time.duration_seconds(duration)
tween.rate = duration > 0 ? 1.0 / s : 0
tween.progress = duration > 0 ? 0 : 1
}
// update all tweens, wait for their delay if one exists
// calls callbacks in all stages, when they're filled
// deletes tween from the map after completion
flux_update :: proc(flux: ^Flux_Map($T), dt: f64) where intrinsics.type_is_float(T) {
clear(&flux.keys_to_be_deleted)
for key, &tween in flux.values {
delay_remainder := f64(0)
// Update delay if necessary.
if tween.delay > 0 {
tween.delay -= dt
if tween.delay < 0 {
// We finished the delay, but in doing so consumed part of this frame's `dt` budget.
// Keep track of it so we can apply it to this tween without affecting others.
delay_remainder = tween.delay
// We're done with this delay.
tween.delay = 0
}
}
// We either had no delay, or the delay has been consumed.
if tween.delay <= 0 {
if !tween.inited {
flux_tween_init(&tween, tween.duration)
if tween.on_start != nil {
tween.on_start(flux, tween.data)
}
}
// If part of the `dt` budget was consumed this frame, then `delay_remainder` will be
// that remainder, a negative value. Adding it to `dt` applies what's left of the `dt`
// to the tween so it advances properly, instead of too much or little.
tween.progress += tween.rate * (dt + delay_remainder)
x := tween.progress >= 1 ? 1 : ease(tween.type, tween.progress)
tween.value^ = tween.start + tween.diff * T(x)
if tween.on_update != nil {
tween.on_update(flux, tween.data)
}
if tween.progress >= 1 {
// append keys to array that will be deleted after the loop
append(&flux.keys_to_be_deleted, key)
if tween.on_complete != nil {
tween.on_complete(flux, tween.data)
}
}
}
}
// loop through keys that should be deleted from the map
if len(flux.keys_to_be_deleted) != 0 {
for key in flux.keys_to_be_deleted {
delete_key(&flux.values, key)
}
}
}
// stop a specific key inside the map
// returns true when it successfully removed the key
@(require_results)
flux_stop :: proc(flux: ^Flux_Map($T), key: ^T) -> bool where intrinsics.type_is_float(T) {
if key in flux.values {
delete_key(&flux.values, key)
return true
}
return false
}
// returns the amount of time left for the tween animation, if the key exists in the map
// returns 0 if the tween doesnt exist on the map
@(require_results)
flux_tween_time_left :: proc(flux: Flux_Map($T), key: ^T) -> f64 {
if tween, ok := flux.values[key]; ok {
return ((1 - tween.progress) * tween.rate) + tween.delay
} else {
return 0
}
}
+250
View File
@@ -0,0 +1,250 @@
// Inverse easing procedures
// These are the mathematical inverses of the corresponding easing functions,
// allowing you to reverse the transformation:
// if y = ease_fn(x), then x = ease_fn_inverse(y) + some_imprecision
package ease
@require import "core:math"
import "base:intrinsics"
// Helper for handling negative bases with fractional exponents
// since math.pow(negative, fraction) returns NaN
@(private)
_signed_pow :: proc "contextless" (x, exp: $T) -> T where intrinsics.type_is_float(T) {
if x >= 0 {
return math.pow(x, exp)
} else {
return -math.pow(-x, exp)
}
}
@(private) PI_2_INV :: 2 / math.PI
// Inverse of quadratic_in
// x = sqrt(y)
@(require_results)
quadratic_in_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
return math.sqrt(p)
}
// Inverse of quadratic_out
// x = 1 - sqrt(1 - y)
@(require_results)
quadratic_out_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
return 1 - math.sqrt(1 - p)
}
// Inverse of quadratic_in_out
// x = sqrt(y/2) ; [0, 0.5)
// x = 1 - sqrt((1-y)/2) ; [0.5, 1]
@(require_results)
quadratic_in_out_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
if p < 0.5 {
return math.sqrt(p * 0.5)
} else {
return 1 - math.sqrt((1 - p) * 0.5)
}
}
// Inverse of cubic_in
// x = y^(1/3)
@(require_results)
cubic_in_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
return math.pow(p, 1.0/3.0)
}
// Inverse of cubic_out
// x = (y - 1)^(1/3) + 1
@(require_results)
cubic_out_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
return _signed_pow(p - 1, 1.0/3.0) + 1
}
// Inverse of cubic_in_out
// x = (y/4)^(1/3) ; [0, 0.5)
// x = ((y-1)*2)^(1/3)/2 + 1 ; [0.5, 1]
@(require_results)
cubic_in_out_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
if p < 0.5 {
return math.pow(p * 0.25, 1.0/3.0)
} else {
return _signed_pow((p - 1) * 2, 1.0/3.0) * 0.5 + 1
}
}
// Inverse of quartic_in
// x = y^(1/4)
@(require_results)
quartic_in_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
return math.pow(p, 0.25)
}
// Inverse of quartic_out
// x = 1 - (1 - y)^(1/4)
@(require_results)
quartic_out_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
return 1 - math.pow(1 - p, 0.25)
}
// Inverse of quartic_in_out
// x = (y/8)^(1/4) ; [0, 0.5)
// x = 1 - ((1-y)/8)^(1/4) ; [0.5, 1]
@(require_results)
quartic_in_out_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
if p < 0.5 {
return math.pow(p * 0.125, 0.25)
} else {
return 1 - math.pow((1 - p) * 0.125, 0.25)
}
}
// Inverse of quintic_in
// x = y^(1/5)
@(require_results)
quintic_in_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
return math.pow(p, 0.2)
}
// Inverse of quintic_out
// x = (y - 1)^(1/5) + 1
@(require_results)
quintic_out_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
return _signed_pow(p - 1, 0.2) + 1
}
// Inverse of quintic_in_out
// x = (y/16)^(1/5) ; [0, 0.5)
// x = ((y-1)*2)^(1/5)/2 + 1 ; [0.5, 1]
@(require_results)
quintic_in_out_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
if p < 0.5 {
return math.pow(0.0625 * p, 0.2)
} else {
return _signed_pow((p - 1) * 2, 0.2) * 0.5 + 1
}
}
// Inverse of sine_in
// x = asin(y - 1) * 2/π + 1
@(require_results)
sine_in_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
return math.asin(p - 1) * PI_2_INV + 1
}
// Inverse of sine_out
// x = asin(y) * 2/π
@(require_results)
sine_out_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
return math.asin(p) * PI_2_INV
}
// Inverse of sine_in_out
// x = acos(1 - 2y) / π
@(require_results)
sine_in_out_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
return math.acos(1 - 2*p) / math.PI
}
// Inverse of circular_in
// x = sqrt(2y - y²)
@(require_results)
circular_in_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
return math.sqrt(2*p - p*p)
}
// Inverse of circular_out
// x = 1 - sqrt(1 - y²)
@(require_results)
circular_out_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
return 1 - math.sqrt(1 - p*p)
}
// Inverse of circular_in_out
// x = sqrt(1 - (1-2y)²) / 2 ; [0, 0.5)
// x = 1 - sqrt(1 - (2y-1)²) / 2 ; [0.5, 1]
@(require_results)
circular_in_out_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
if p < 0.5 {
q := 1 - 2*p
return 0.5 * math.sqrt(1 - q*q)
} else {
q := 2*p - 1
return 1 - 0.5 * math.sqrt(1 - q*q)
}
}
// Inverse of exponential_in
// x = log(y) / 10 + 1
@(require_results)
exponential_in_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
return p == 0.0 ? 0.0 : 0.1 * math.log2(p) + 1
}
// Inverse of exponential_out
// x = -log(1 - y) / 10
@(require_results)
exponential_out_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
return p == 1.0 ? 1.0 : 0.1 * -math.log2(1 - p)
}
// Inverse of exponential_in_out
// x = (log(2y) + 10) / 20 ; [0, 0.5)
// x = (10 - log(2(1-y))) / 20 ; [0.5, 1]
@(require_results)
exponential_in_out_inverse :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) {
if p == 0.0 || p == 1.0 {
return p
}
if p < 0.5 {
return 0.05 * (math.log2(2*p) + 10)
} else {
return 0.05 * (10 - math.log2(2*(1-p)))
}
}
// Additional enum variant
@(require_results)
ease_inverse :: proc "contextless" (type: Ease, p: $T) -> T where intrinsics.type_is_float(T) {
switch type {
case .Linear: return p
case .Quadratic_In: return quadratic_in_inverse(p)
case .Quadratic_Out: return quadratic_out_inverse(p)
case .Quadratic_In_Out: return quadratic_in_out_inverse(p)
case .Cubic_In: return cubic_in_inverse(p)
case .Cubic_Out: return cubic_out_inverse(p)
case .Cubic_In_Out: return cubic_in_out_inverse(p)
case .Quartic_In: return quartic_in_inverse(p)
case .Quartic_Out: return quartic_out_inverse(p)
case .Quartic_In_Out: return quartic_in_out_inverse(p)
case .Quintic_In: return quintic_in_inverse(p)
case .Quintic_Out: return quintic_out_inverse(p)
case .Quintic_In_Out: return quintic_in_out_inverse(p)
case .Sine_In: return sine_in_inverse(p)
case .Sine_Out: return sine_out_inverse(p)
case .Sine_In_Out: return sine_in_out_inverse(p)
case .Circular_In: return circular_in_inverse(p)
case .Circular_Out: return circular_out_inverse(p)
case .Circular_In_Out: return circular_in_out_inverse(p)
case .Exponential_In: return exponential_in_inverse(p)
case .Exponential_Out: return exponential_out_inverse(p)
case .Exponential_In_Out: return exponential_in_out_inverse(p)
case .Elastic_In, .Elastic_Out, .Elastic_In_Out,
.Back_In, .Back_Out, .Back_In_Out,
.Bounce_In, .Bounce_Out, .Bounce_In_Out:
// These do not have simple closed-form inverses
return 0
}
// In case type was invalid
return 0
}
+177
View File
@@ -0,0 +1,177 @@
// Flux easing used for animations
package ease
import "core:time"
Flux_Map :: struct($T: typeid) {
values: map[^T]Flux_Tween(T),
keys_to_be_deleted: [dynamic]^T,
}
Flux_Tween :: struct($T: typeid) {
value: ^T,
start: T,
diff: T,
goal: T,
delay: f64, // in seconds
duration: time.Duration,
progress: f64,
rate: f64,
type: Ease,
inited: bool,
// callbacks, data can be set, will be pushed to callback
data: rawptr, // by default gets set to value input
on_start: proc(flux: ^Flux_Map(T), data: rawptr),
on_update: proc(flux: ^Flux_Map(T), data: rawptr),
on_complete: proc(flux: ^Flux_Map(T), data: rawptr),
}
// init flux map to a float type and a wanted cap
@(require_results)
flux_init :: proc($T: typeid, value_capacity := 8, allocator := context.allocator, loc := #caller_location) -> Flux_Map(T) where intrinsics.type_is_float(T) {
return {
values = make(map[^T]Flux_Tween(T), value_capacity, allocator, loc),
keys_to_be_deleted = make([dynamic]^T, 0, value_capacity, allocator, loc),
}
}
// delete map content
flux_destroy :: proc(flux: Flux_Map($T), allocator := context.allocator, loc := #caller_location) where intrinsics.type_is_float(T) {
delete(flux.values, allocator, loc)
delete(flux.keys_to_be_deleted, allocator, loc)
}
// clear map content, stops all animations
flux_clear :: proc(flux: ^Flux_Map($T)) where intrinsics.type_is_float(T) {
clear(&flux.values)
}
// append / overwrite existing tween value to parameters
// rest is initialized in flux_tween_init, inside update
// return value can be used to set callbacks
@(require_results)
flux_to :: proc(
flux: ^Flux_Map($T),
value: ^T,
goal: T,
type: Ease = .Quadratic_Out,
duration: time.Duration = time.Second,
delay: f64 = 0,
) -> (tween: ^Flux_Tween(T)) where intrinsics.type_is_float(T) {
if res, ok := &flux.values[value]; ok {
tween = res
} else {
flux.values[value] = {}
tween = &flux.values[value]
}
tween^ = {
value = value,
goal = goal,
duration = duration,
delay = delay,
type = type,
data = value,
}
return
}
// init internal properties
flux_tween_init :: proc(tween: ^Flux_Tween($T), duration: time.Duration) where intrinsics.type_is_float(T) {
tween.inited = true
tween.start = tween.value^
tween.diff = tween.goal - tween.value^
s := time.duration_seconds(duration)
tween.rate = duration > 0 ? 1.0 / s : 0
tween.progress = duration > 0 ? 0 : 1
}
// update all tweens, wait for their delay if one exists
// calls callbacks in all stages, when they're filled
// deletes tween from the map after completion
flux_update :: proc(flux: ^Flux_Map($T), dt: f64) where intrinsics.type_is_float(T) {
clear(&flux.keys_to_be_deleted)
for key, &tween in flux.values {
delay_remainder := f64(0)
// Update delay if necessary.
if tween.delay > 0 {
tween.delay -= dt
if tween.delay < 0 {
// We finished the delay, but in doing so consumed part of this frame's `dt` budget.
// Keep track of it so we can apply it to this tween without affecting others.
delay_remainder = tween.delay
// We're done with this delay.
tween.delay = 0
}
}
// We either had no delay, or the delay has been consumed.
if tween.delay <= 0 {
if !tween.inited {
flux_tween_init(&tween, tween.duration)
if tween.on_start != nil {
tween.on_start(flux, tween.data)
}
}
// If part of the `dt` budget was consumed this frame, then `delay_remainder` will be
// that remainder, a negative value. Adding it to `dt` applies what's left of the `dt`
// to the tween so it advances properly, instead of too much or little.
tween.progress += tween.rate * (dt + delay_remainder)
x := tween.progress >= 1 ? 1 : ease(tween.type, tween.progress)
tween.value^ = tween.start + tween.diff * T(x)
if tween.on_update != nil {
tween.on_update(flux, tween.data)
}
if tween.progress >= 1 {
// append keys to array that will be deleted after the loop
append(&flux.keys_to_be_deleted, key)
if tween.on_complete != nil {
tween.on_complete(flux, tween.data)
}
}
}
}
// loop through keys that should be deleted from the map
if len(flux.keys_to_be_deleted) != 0 {
for key in flux.keys_to_be_deleted {
delete_key(&flux.values, key)
}
}
}
// stop a specific key inside the map
// returns true when it successfully removed the key
@(require_results)
flux_stop :: proc(flux: ^Flux_Map($T), key: ^T) -> bool where intrinsics.type_is_float(T) {
if key in flux.values {
delete_key(&flux.values, key)
return true
}
return false
}
// returns the amount of time left for the tween animation, if the key exists in the map
// returns 0 if the tween doesn't exist on the map
@(require_results)
flux_tween_time_left :: proc(flux: Flux_Map($T), key: ^T) -> f64 {
if tween, ok := flux.values[key]; ok {
return ((1 - tween.progress) * tween.rate) + tween.delay
} else {
return 0
}
}
File diff suppressed because it is too large Load Diff
@@ -2,6 +2,42 @@ package math_linalg_hlsl
import "core:math"
@(require_results) cos_half :: proc "c" (x: half) -> half { return math.cos(x) }
@(require_results) sin_half :: proc "c" (x: half) -> half { return math.sin(x) }
@(require_results) tan_half :: proc "c" (x: half) -> half { return math.tan(x) }
@(require_results) acos_half :: proc "c" (x: half) -> half { return math.acos(x) }
@(require_results) asin_half :: proc "c" (x: half) -> half { return math.asin(x) }
@(require_results) atan_half :: proc "c" (x: half) -> half { return math.atan(x) }
@(require_results) atan2_half :: proc "c" (y, x: half) -> half { return math.atan2(y, x) }
@(require_results) cosh_half :: proc "c" (x: half) -> half { return math.cosh(x) }
@(require_results) sinh_half :: proc "c" (x: half) -> half { return math.sinh(x) }
@(require_results) tanh_half :: proc "c" (x: half) -> half { return math.tanh(x) }
@(require_results) acosh_half :: proc "c" (x: half) -> half { return math.acosh(x) }
@(require_results) asinh_half :: proc "c" (x: half) -> half { return math.asinh(x) }
@(require_results) atanh_half :: proc "c" (x: half) -> half { return math.atanh(x) }
@(require_results) sqrt_half :: proc "c" (x: half) -> half { return math.sqrt(x) }
@(require_results) rsqrt_half :: proc "c" (x: half) -> half { return 1.0/math.sqrt(x) }
@(require_results) rcp_half :: proc "c" (x: half) -> half { return 1.0/x }
@(require_results) pow_half :: proc "c" (x, y: half) -> half { return math.pow(x, y) }
@(require_results) exp_half :: proc "c" (x: half) -> half { return math.exp(x) }
@(require_results) log_half :: proc "c" (x: half) -> half { return math.ln(x) }
@(require_results) log2_half :: proc "c" (x: half) -> half { return math.log(x, 2) }
@(require_results) log10_half :: proc "c" (x: half) -> half { return math.log(x, 10) }
@(require_results) exp2_half :: proc "c" (x: half) -> half { return math.pow(half(2), x) }
@(require_results) sign_half :: proc "c" (x: half) -> half { return math.sign(x) }
@(require_results) floor_half :: proc "c" (x: half) -> half { return math.floor(x) }
@(require_results) round_half :: proc "c" (x: half) -> half { return math.round(x) }
@(require_results) ceil_half :: proc "c" (x: half) -> half { return math.ceil(x) }
@(require_results) isnan_half :: proc "c" (x: half) -> bool { return math.classify(x) == .NaN}
@(require_results) fmod_half :: proc "c" (x, y: half) -> half { return math.mod(x, y) }
@(require_results)
frac_half :: proc "c" (x: half) -> half {
if x >= 0 {
return x - math.trunc(x)
}
return math.trunc(-x) + x
}
@(require_results) cos_float :: proc "c" (x: float) -> float { return math.cos(x) }
@(require_results) sin_float :: proc "c" (x: float) -> float { return math.sin(x) }
@(require_results) tan_float :: proc "c" (x: float) -> float { return math.tan(x) }
+4 -4
View File
@@ -208,7 +208,7 @@ Inputs:
Returns:
- val: A random 31 bit value in the range `[0, n)`
WARNING: Panics if n is less than 0
WARNING: Panics if n is less than or equal to 0
Example:
import "core:math/rand"
@@ -249,7 +249,7 @@ Inputs:
Returns:
- val: A random 63 bit value in the range `[0, n)`
WARNING: Panics if n is less than 0
WARNING: Panics if n is less than or equal to 0
Example:
import "core:math/rand"
@@ -290,7 +290,7 @@ Inputs:
Returns:
- val: A random 127 bit value in the range `[0, n)`
WARNING: Panics if n is less than 0
WARNING: Panics if n is less than or equal to 0
Example:
import "core:math/rand"
@@ -331,7 +331,7 @@ Inputs:
Returns:
- val: A random integer value in the range `[0, n)`
WARNING: Panics if n is less than 0
WARNING: Panics if n is less than or equal to 0
Example:
import "core:math/rand"
+2 -2
View File
@@ -99,8 +99,8 @@ panic_allocator :: proc() -> Allocator {
panic_allocator_proc :: proc(
allocator_data: rawptr,
mode: Allocator_Mode,
size, alignment: int,
old_memory: rawptr,
size, alignment: int,
old_memory: rawptr,
old_size: int,
loc := #caller_location,
) -> ([]byte, Allocator_Error) {
+2 -2
View File
@@ -332,7 +332,7 @@ and returns an integer count of the `T` between them.
- `b`: A pointer to a type T
**Returns**
- `b` - `a` in items of T as an `int`.
- `a` - `b` in items of T as an `int`.
Example:
@@ -704,4 +704,4 @@ calc_padding_with_header :: proc "contextless" (ptr: uintptr, align: uintptr, he
}
}
return int(padding)
}
}
+1 -1
View File
@@ -3,7 +3,7 @@ package mem_tlsf
/*
Copyright 2024 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under tlsf's LICENSE (BSD 3-clause).
List of contributors:
Matt Conte: Original C implementation, see LICENSE file in this package
+1 -1
View File
@@ -1,6 +1,6 @@
/*
Copyright 2024 Jeroen van Rijn <nom@duclavier.com>.
Made available under Odin's BSD-3 license.
Made available under tlsf's LICENSE (BSD 3-clause).
List of contributors:
Matt Conte: Original C implementation, see LICENSE file in this package
+1 -1
View File
@@ -11,7 +11,7 @@ package net
Copyright 2022 Colin Davidson <colrdavidson@gmail.com>
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation
+1 -1
View File
@@ -14,7 +14,7 @@ package net
Copyright 2022 Colin Davidson <colrdavidson@gmail.com>
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation
+1 -1
View File
@@ -12,7 +12,7 @@ package net
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Copyright 2025 Christiano Haesbaert <haesbaert@haesbaert.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation
+1 -1
View File
@@ -10,7 +10,7 @@ package net
Copyright 2022 Colin Davidson <colrdavidson@gmail.com>
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation
+1 -1
View File
@@ -11,7 +11,7 @@ package net
Copyright 2022 Colin Davidson <colrdavidson@gmail.com>
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation
+1 -1
View File
@@ -35,7 +35,7 @@ package net
Copyright 2022 Colin Davidson <colrdavidson@gmail.com>
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation
+1 -1
View File
@@ -11,7 +11,7 @@ package net
Copyright 2022 Colin Davidson <colrdavidson@gmail.com>
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation
+1 -1
View File
@@ -11,7 +11,7 @@ package net
Copyright 2022 Colin Davidson <colrdavidson@gmail.com>
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation
+1 -1
View File
@@ -11,7 +11,7 @@ package net
Copyright 2022 Colin Davidson <colrdavidson@gmail.com>
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation
+1 -1
View File
@@ -11,7 +11,7 @@ package net
Copyright 2022 Colin Davidson <colrdavidson@gmail.com>
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation
+1 -1
View File
@@ -11,7 +11,7 @@ package net
Copyright 2022 Colin Davidson <colrdavidson@gmail.com>
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation
+1 -1
View File
@@ -11,7 +11,7 @@ package net
Copyright 2022 Colin Davidson <colrdavidson@gmail.com>
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation
+1 -1
View File
@@ -11,7 +11,7 @@ package net
Copyright 2022 Colin Davidson <colrdavidson@gmail.com>
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation
+1 -1
View File
@@ -11,7 +11,7 @@ package net
Copyright 2022 Colin Davidson <colrdavidson@gmail.com>
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation
+1 -1
View File
@@ -11,7 +11,7 @@ package net
Copyright 2022 Colin Davidson <colrdavidson@gmail.com>
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation
+1 -1
View File
@@ -11,7 +11,7 @@ package net
Copyright 2022-2023 Colin Davidson <colrdavidson@gmail.com>
Copyright 2022-2023 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation
+1 -1
View File
@@ -11,7 +11,7 @@ package net
Copyright 2022 Colin Davidson <colrdavidson@gmail.com>
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation
+1 -1
View File
@@ -11,7 +11,7 @@ package net
Copyright 2022 Colin Davidson <colrdavidson@gmail.com>
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation
+1 -1
View File
@@ -11,7 +11,7 @@ package net
Copyright 2022 Colin Davidson <colrdavidson@gmail.com>
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation
+1 -1
View File
@@ -11,7 +11,7 @@ package net
Copyright 2022 Colin Davidson <colrdavidson@gmail.com>
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation
+1 -1
View File
@@ -9,7 +9,7 @@ package net
Copyright 2022 Colin Davidson <colrdavidson@gmail.com>
Copyright 2022 Jeroen van Rijn <nom@duclavier.com>.
Copyright 2024 Feoramund <rune@swevencraft.org>.
Made available under Odin's BSD-3 license.
Made available under Odin's license.
List of contributors:
Tetralux: Initial implementation

Some files were not shown because too many files have changed in this diff Show More