0.5.5 features (#1151)

0.5.5 Disallow multiple `_` in a row in digits, e.g. `1__000`. #1138. Fixed toposort example. Struct/union members now correctly rejects members without storage size #1147. `math::pow` will now correctly promote integer arguments. `math::pow` will now correctly promote integer arguments. Added `new_aligned` and `alloc_aligned` functions to prevent accidental under-alignment when allocating simd. Pointer difference would fail where alignment != size (structs etc) #1150. Add test that overalignment actually works for lists. Fixed array calculation for npot2 vectors. Use native aligned alloc on Windows and POSIX. Deprecates "offset". Simplification of the Allocator interface.
This commit is contained in:
Christoffer Lerno
2024-02-22 17:13:51 +01:00
committed by GitHub
parent b7f4fd9074
commit 7ea3d230bb
39 changed files with 749 additions and 310 deletions

View File

@@ -0,0 +1,17 @@
import std;
struct Overalign
{
double[<33>] x;
}
fn void main()
{
List(<Overalign>) l;
Overalign y;
for (int i = 0; i < 1000; i++)
{
io::printfn("Pushing %d", i);
l.push(y);
if (i > 3) io::printfn("Diff %d", (usz)l.get_ref(i) - (usz)l.get_ref(i - (usz)1));
}
}

View File

@@ -1,6 +1,5 @@
module topologicalsort;
extern fn void printf(char* x, ...);
import std::io;
struct InputPair
{
@@ -24,10 +23,9 @@ struct TopoList
fn void sort(InputPair[] pairs, uint elements)
{
InputPair[] result = mem::alloc_array(InputPair, pairs.len);
TopoList* top = mem::alloc_array(TopoList, elements);
for (int i = 0; i < pairs.len; i++)
TopoList* top = mem::new_array(TopoList, elements);
foreach (pair : pairs)
{
InputPair pair = pairs[i];
assert(pair.value >= 0 && pair.value < elements);
assert(pair.successor >= 0 && pair.successor < elements);
top[pair.successor].count++;
@@ -60,10 +58,10 @@ fn void sort(InputPair[] pairs, uint elements)
}
break;
}
printf("Got %d elements.\n", count);
for (int i = 0; i < count; i++)
io::printfn("Got %d elements.", count);
foreach (val : intout[:count])
{
printf("%d\n", intout[i]);
io::printn(val);
}
}