<scientes>
this isn't getting optimized out in --release-fast
<scientes>
guess that is a llvm bug
<andrewrk>
tgschultz, have a look at std.mem.Allocator.alignedAlloc
<tgschultz>
Oh, right!
<tgschultz>
I'd forgotten completely about those functions
<scientes>
andrewrk, yeah, but why can't it put that when you use alloc() from directallocator
<scientes>
as it knows it is 4096 or the page size
muffindrake has quit [Ping timeout: 246 seconds]
<andrewrk>
scientes, in theory that should actually give more information to the optimizer. but if llvm can't deal with it, let's omit it in release fast mode
<andrewrk>
scientes, you mean when you call the function pointer that has to match the non-aligned Allocator interface API?
<scientes>
I could do it with @alignCast() but alignment is a run-time value, not comptime
<scientes>
also we kind of need two @alignCast()s--one that only bumbs the alignment up, and one that sets it definitively
muffindrake has joined #zig
<scientes>
but really it should jsut go up, and to set it definitely you need to use @ptrCast() IMHO
<scientes>
because if it wasn't right, they you already have UB
dingenskirchen has quit [Read error: Connection reset by peer]
dingenskirchen1 has joined #zig
dingenskirchen1 is now known as dingenskirchen
SimonN has joined #zig
SimonNa has quit [Ping timeout: 240 seconds]
doublex has joined #zig
vexu has joined #zig
_whitelogger has joined #zig
<mq32>
thanks andrewrk and LemonBoy for fixing all those bugs :)
traviss has quit [Remote host closed the connection]
casaca has quit [Ping timeout: 276 seconds]
jjido has joined #zig
FireFox317 has joined #zig
casaca has joined #zig
traviss has joined #zig
dantix has joined #zig
dingenskirchen has quit [Remote host closed the connection]
dingenskirchen has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
return0e_ has joined #zig
traviss has quit [Remote host closed the connection]
vexu has quit [Quit: WeeChat 2.6]
FireFox317 has quit [Remote host closed the connection]
Ichorio_ has quit [Ping timeout: 264 seconds]
<muffindrake>
It seems to be possible to currently use something like 'array = {};' in code - does that simply zero-initialize the given object, or is there some other thing that does?
<muffindrake>
It's not mentioned in the documentation, if I'm not mistaken, but it will compile.
bjorob has joined #zig
bjorob has quit [Ping timeout: 240 seconds]
dingenskirchen has quit [Quit: dingenskirchen]
return0__ has joined #zig
return0e_ has quit [Ping timeout: 240 seconds]
<dantix>
muffindrake: It will not compile as you've described. You can use `const all_zero = [_]u16{0} ** 10;` where `10` is array length or `undefined` if you are okay with uninitialized memory.
return0e_ has joined #zig
<muffindrake>
Then what does {} mean if you assign it to a variable? Because doing that actually compiles at the moment.
<mikdusan>
euantor: if i remember correct, due to a compiler upgrade, 0.5.0 release on windows introduced a new runtime .dll requirement,
<mikdusan>
and sometime thereafter, the windows master builds were enhanced to drastically reduce .dll requirements
<mikdusan>
long story short, if a recent master build is used that should solve the issue
<tgschultz>
see #3391, but should have been fixed in #3467
<euantor>
Right, I'll need to update the Chocolatey package then and work out what exact dependencies it has. The commenter claims to have VC redist installed so I'll need to set up a clean windows environment to test
<euantor>
The chocolatey packages currently only have released versions, as it takes a while for reviews to complete so maintianing master builds would be a pain
<mikdusan>
euantor: commenter claims up to 2017 redistributable installed. vcruntime140_1.dll is a '2019 thing
<euantor>
Ah, will reply again recommending 2019 and add it as a dependency
return0e_ has quit [Remote host closed the connection]
porky11 has joined #zig
wootehfoot has joined #zig
clktmr has joined #zig
doublex has quit [Ping timeout: 264 seconds]
dimenus has quit [Read error: Connection reset by peer]
jjido has joined #zig
Akuli has joined #zig
porky11 has quit [Remote host closed the connection]
wink_ has quit [Remote host closed the connection]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
doublex has joined #zig
porky11 has joined #zig
doublex has quit [Read error: Connection reset by peer]
doublex has joined #zig
lunamn has joined #zig
porky11 has quit [Quit: Leaving]
doublex_ has joined #zig
doublex has quit [Read error: Connection reset by peer]
doublex has joined #zig
doublex_ has quit [Read error: Connection reset by peer]
doublex has quit [Ping timeout: 240 seconds]
jjido has joined #zig
<shakesoda>
does zig have a way to do lambda functions/closures
vexu has joined #zig
Akuli has quit [Quit: Leaving]
<shakesoda>
oh, looks like #1717 is about this
<leeward>
If I have a function that wants to take an array of 2 bytes as input and never change them, what should the type of the argument be? I'd also like to be able to pass slices of a bigger array in.
<fengb>
[]const u8 ?
<tgschultz>
if you want to take slices, then []const u8
<leeward>
I'd like to communicate in the interface that it expects exactly 2 bytes. Is that just not a thing I can do?
<tgschultz>
[2]u8
<leeward>
But not `[2] const u8`
<tgschultz>
no, slices do not have comptime known length
<tgschultz>
you could say *const [2]u8
<leeward>
I guess the issue is where I raise the error, right?
<tgschultz>
I'm not sure if any simple slicing syntax will work though...
<fengb>
[2]u8 implies const already. It's Zig's fancy pass ref by const value
<leeward>
I can have it take []const u8, but the function now returns !whatever
<leeward>
Ohhh, ok
<fengb>
It's the same as declaring "const foo: [2]u8". You won't be able to edit the data
<leeward>
I think I might submit a suggestion then: s/error: const qualifier invalid on array type/error: const qualifier superfluous on array type/
<fengb>
Equivalent to*. Obviously not the same :P
<fengb>
tgschultz: can Zig downcast larger arrays to fit into 2 bytes?
<tgschultz>
I'm not sure, but I doubt it
<tgschultz>
I mean, array[0..N] should be able to cast to *const [N]u8 if N is a comptime constant, but I'm not sure the compiler does that.
<fengb>
`error: expected type '[2]u8', found '[3]u8'` :(
<tgschultz>
That isn't surprising, but try what I posted above.
<tgschultz>
because downcasting an array to a smaller array would be hidden behavior anyway
<andrewrk>
fengb, I was thinking to change @sliceToBytes and @bytesToSlice to be more powerful
<andrewrk>
@toBytes and @fromBytes
<andrewrk>
hmm maybe @ptrToBytes and @valueToBytes
<tgschultz>
just moving mem.as/fromBytes into builtins?
<andrewrk>
no it has to operate on a pointer. always a pointer. ok so it accepts a pointer, but the point is that it would return *[N]u8 if the len was comptime known
<andrewrk>
oh right. this can be std lib
<andrewrk>
does this already exist?
<tgschultz>
pretty sure it was added by Hejsil and I in the meta pr (though it is part of mem).
<andrewrk>
oh nice tgschultz I forgot you did this
<mq32>
do we have a thing like @sizeOf that has bits size?
<tgschultz>
Not really, because it would only really work for primitives given the complexities of what you mean when you'd use it on a struct, and for primitives it is simple math.
<andrewrk>
I think it will become meaningfully once 3133 is done
<andrewrk>
it basically tells you how much space the type fills up in a packed struct if you leave it unaligned
<mq32>
right now i have this error: error: array of 'Entry' not allowed in packed struct due to padding bits
<andrewrk>
mq32, yes this is what #3133 is addressing - let you put any type in a packed struct
<leeward>
Is there a way to cast a `[]const u8` to `[2]u8`?
<marijnfs_>
is there a nice binary serialization library for zig?
<waleee-cl>
I guess you could half-ass it by using C's fopen/fwrite if nothing else
<scientes>
I don't tihnk that is what he is asking
<THFKA4>
someone was working on integrating protos
<andrewrk>
I don't think that addresses marijnfs's use case. zig std lib has clear facilities for writing files. this question is about some kind of reflection-based system
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vexu has quit [Quit: WeeChat 2.6]
FireFox317 has joined #zig
FireFox317 has quit [Remote host closed the connection]
FireFox317 has joined #zig
<FireFox317>
Someone in here with uart experience? I'm trying andrewrk's clashos bootloader, but I'm having a weird issue which only happens with real hardware and not in qemu. When I'm sending a new image over uart after two null bytes have been send, the raspberry only receives null bytes afterwards.
<FireFox317>
I tried using different usb to uart bridges, but that didn't help
<andrewrk>
something to do with baud rate maybe?
<andrewrk>
I'm a total beginner at bare metal coding
<andrewrk>
FireFox317, oh, have you tried #osdev? it's a helpful channel
<FireFox317>
Nope I haven't thanks for the suggestions
<FireFox317>
I'm getting close to the usb keyboard support in clashos btw, but Its super annoying when i constantly have to switch sd cards between the rpi and my pc. Thats why I'm trying the bootloader, but no success yet
wootehfoot has quit [Read error: Connection reset by peer]
<andrewrk>
does the bootloader work for you in qemu?
<FireFox317>
Jup it does
<FireFox317>
I also tried a much lower baudrate, but exactly the same problem
<FireFox317>
So weird
<marijnfs_>
c++ has a nice serialization library called Cereal
<marijnfs_>
something like that would be nice
<marijnfs_>
with all the introspection it might be possible
<andrewrk>
FireFox317, hmm ok. if I were working on this right now, trying to get the bootloader working on real hardware would be my top priority
protty has quit [Remote host closed the connection]
<FireFox317>
andrewrk: I went back to this commit a804d7d, before markfirmware's framebuffer stuff, just so you know
<andrewrk>
good to know
<mq32>
FireFox317: how do you connect to your uart?
<mq32>
because you may need to change your tt settings
kllr_sbstn has quit [Quit: leaving]
<FireFox317>
Well using a bus pirate actually
<FireFox317>
Setting that into transparant bridge mode
<Snektron>
every time i see how c++ allocators work i get reminded how nice those of Zig work
<shakesoda>
every time i see how pretty much anything in c++ works i run for my life
<Snektron>
oh, come on, enable_if is not so hard ;)
<fengb>
I’m always impressed that not having a default allocator exposes so many nice benefits
Guest75066 has quit [Remote host closed the connection]