Merge tag 'dev-2025-04'

This commit is contained in:
ed
2025-04-14 14:36:56 -04:00
158 changed files with 8269 additions and 1630 deletions
+28
View File
@@ -888,6 +888,34 @@ make_aligned :: proc(
return runtime.make_aligned(T, len, alignment, allocator, loc)
}
/*
Allocate a new slice with alignment for allocators that might not support the
specified alignment requirement.
This procedure allocates a new slice of type `T` with length `len`, aligned
on a boundary specified by `alignment` from an allocator specified by
`allocator`, and returns the allocated slice.
The user should `delete` the return `original_data` slice not the typed `slice`.
*/
@(require_results)
make_over_aligned :: proc(
$T: typeid/[]$E,
#any_int len: int,
alignment: int,
allocator: runtime.Allocator,
loc := #caller_location,
) -> (slice: T, original_data: []byte, err: Allocator_Error) {
size := size_of(E)*len + alignment-1
original_data, err = runtime.make([]byte, size, allocator, loc)
if err == nil {
ptr := align_forward(raw_data(original_data), uintptr(alignment))
slice = ([^]E)(ptr)[:len]
}
return
}
/*
Allocate a new slice.
+19 -20
View File
@@ -171,16 +171,15 @@ If the return value is:
The comparison is performed as follows:
1. Each byte, upto `min(len(a), len(b))` bytes is compared between `a` and `b`.
- If the byte in slice `a` is smaller than a byte in slice `b`, then comparison
stops and this procedure returns `-1`.
- If the byte in slice `a` is bigger than a byte in slice `b`, then comparison
stops and this procedure returns `+1`.
- Otherwise the comparison continues until `min(len(a), len(b))` are compared.
2. If all the bytes in the range are equal, then the lengths of the slices are
compared.
- If the length of slice `a` is smaller than the length of slice `b`, then `-1` is returned.
- If the length of slice `b` is smaller than the length of slice `b`, then `+1` is returned.
- Otherwise `0` is returned.
- If the byte in slice `a` is smaller than a byte in slice `b`, then comparison
stops and this procedure returns `-1`.
- If the byte in slice `a` is bigger than a byte in slice `b`, then comparison
stops and this procedure returns `+1`.
- Otherwise the comparison continues until `min(len(a), len(b))` are compared.
2. If all the bytes in the range are equal, then the lengths of the slices are compared.
- If the length of slice `a` is smaller than the length of slice `b`, then `-1` is returned.
- If the length of slice `b` is smaller than the length of slice `b`, then `+1` is returned.
- Otherwise `0` is returned.
*/
@(require_results)
compare :: proc "contextless" (a, b: []byte) -> int {
@@ -207,11 +206,11 @@ If the return value is:
The comparison is performed as follows:
1. Each byte, upto `n` bytes is compared between `a` and `b`.
- If the byte in `a` is smaller than a byte in `b`, then comparison stops
and this procedure returns `-1`.
- If the byte in `a` is bigger than a byte in `b`, then comparison stops
and this procedure returns `+1`.
- Otherwise the comparison continues until `n` bytes are compared.
- If the byte in `a` is smaller than a byte in `b`, then comparison stops
and this procedure returns `-1`.
- If the byte in `a` is bigger than a byte in `b`, then comparison stops
and this procedure returns `+1`.
- Otherwise the comparison continues until `n` bytes are compared.
2. If all the bytes in the range are equal, this procedure returns `0`.
*/
@(require_results)
@@ -233,11 +232,11 @@ If the return value is:
The comparison is performed as follows:
1. Each byte, upto `n` bytes is compared between `a` and `b`.
- If the byte in `a` is smaller than a byte in `b`, then comparison stops
and this procedure returns `-1`.
- If the byte in `a` is bigger than a byte in `b`, then comparison stops
and this procedure returns `+1`.
- Otherwise the comparison continues until `n` bytes are compared.
- If the byte in `a` is smaller than a byte in `b`, then comparison stops
and this procedure returns `-1`.
- If the byte in `a` is bigger than a byte in `b`, then comparison stops
and this procedure returns `+1`.
- Otherwise the comparison continues until `n` bytes are compared.
2. If all the bytes in the range are equal, this procedure returns `0`.
*/
@(require_results)