<ask6155>
I was using DefaultPrng in my program. It needed a seed so I was thinking of using... OS time? How would I do that?
xd1le has quit [Read error: Connection reset by peer]
xackus has joined #zig
dermetfan has joined #zig
<ifreund>
ask6155: std.time has various function for doing that
xd1le has joined #zig
<ask6155>
all the funcs in std.time return i64 whereas DefaultPrng requires u64 Numbers...
<ifreund>
ask6155: it's just a seed, so it doesn't matter what the actual number is
<ifreund>
just @bitCast() it to u64
<ask6155>
oh okay
dermetfan has quit [Ping timeout: 244 seconds]
JohnB99 has quit [Ping timeout: 244 seconds]
<ask6155>
Can I random assign an option to a enum?
<ask6155>
*randomly
<ifreund>
ask6155: sure, use @intToEnum()
<ifreund>
and you can get the number of fields with @typeInfo(foo).Enum.fields.len
SimonNa has joined #zig
riba has joined #zig
<ask6155>
if I getStdIn and pass it to std.os.read(stdin, buffer) isn't it supposed to wait and take input while running?
<ask6155>
wait read takes a fd but getStdIn gives a File... What to do?
<Nypsie[m]>
You can get the fd from the File, pretty sure it's called .handle. The easiest way to read from stdin however, would be by using the reader interface like so: std.io.getStdIn().reader().readAll(buffer);
<ifreund>
getStdInHandle() returns the fd directly alternatively
<ifreund>
but yeah, you most likely want to use the reader interface
<ask6155>
when I called the reader with readInt and gave it type u2 it gave error as exact division had a remainder
<ask6155>
oh wait it has to be divisible by 8
riba has quit [Ping timeout: 260 seconds]
dermetfan has joined #zig
<ask6155>
I gave readAll a file and a buffer (stdin's File) but it's not pausing to get input
<Nypsie[m]>
What size is the buffer you're providing?
<ask6155>
[]u8 undefined
<ifreund>
uh, that's not a buffer, that's an undefined slice
<ifreund>
a slice is like a pointer, it needs to be backed by some memory
<ask6155>
How do I provide a buffer?
<ifreund>
so you could do e.g. var buffer: [1024]u8 = undefined; file.read(&buffer);
<ifreund>
or you could use something like reader.readUntilDelimiterAlloc() if you want to read input one line at a time and allocate memory to read into
<ask6155>
I made a buffer [1024]u8 = undefined and then gave *buffer to readAll. I gave error expected 'type' found [1024]u8
ask6155 has left #zig ["Later!"]
dec05eba has joined #zig
<dec05eba>
are zig compiled binaries portable? or does the compiler do the equivalent of -march=native by default?
<ifreund>
the default is -march=native
<ifreund>
you can set the target with -target though,
<dec05eba>
i thought -target was only for choose the target architecture, and not which generation of instructions to use
<ifreund>
oh my bad, I meant -mcpu
<ifreund>
though wait, I think if you use target with x86_64-linux-gnu over native-linux-gnu it already disables the cpu-specific stuff
<dec05eba>
i see, thanks
xackus has quit [Ping timeout: 244 seconds]
frett27_ has joined #zig
frett27 has quit [Ping timeout: 258 seconds]
mattmurr_ has joined #zig
<daurnimator>
dec05eba: yeah as soon as you specify x86_64 it changes to use the baseline CPU feature set for x86_64
waleee-cl has joined #zig
xd1le has quit [Read error: Connection reset by peer]
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
cole-h has quit [Quit: Goodbye]
a_chou has joined #zig
<andrewrk>
ifreund, for future reference recommend std.crypto.randomBytes for the seed rather than time
<andrewrk>
I'll put that in the doc comments
<ifreund>
good to know, I haven't really done anything with that part of the std yet
<andrewrk>
for pseudo random numbers it doesn't matter as much but for cryptographically secure ones it's the difference between exploitable code or not
<ifreund>
neat, looks like I can build my pam module thing without linking libc
<andrewrk>
cool!
<ifreund>
hmm, that does mean that I don't share the allocator with PAM though, allocating a whole page just to use 4 bytes of it seems wasteful
<andrewrk>
I think if your plugin is going to get used by other code that already links libc, linking libc in your plugin is probably the way to go
<andrewrk>
that's sorta why we have the ability to do both
<ifreund>
yeah, the daemon part is pure zig now though since the prctl thing got merged
<andrewrk>
after I get this beast #6250 landed let's reexamine your use cases and make sure everything is solved
<andrewrk>
it's gonna have a main.zig instead of main.cpp
<ifreund>
the only outstanding issue in master is that I can't get rid of the "lib" prefix on the dynamic library
<andrewrk>
gotcha. yeah I think that can be an option. you willing to wait a couple weeks for me to finish this work or would it be beneficial to update master in the meantime?
<ifreund>
this could be solved post #6250 by simply exposing the -femit-bin=foo thing in the zig build system, which we probably want to do anyways
<ifreund>
nah it's really not a big deal, I can be patient
<ifreund>
I think I'm gonna write some more idiomatic wlroots bindings next, which will 1. make river's code cleaner and 2. make it build on musl
<andrewrk>
nice
<ifreund>
I also want to get back to wasm in stage2 at some point, though that may wait till october when I have more brainpower to spare from Uni
<andrewrk>
looking forward to that
marnix has quit [Ping timeout: 260 seconds]
marnix has joined #zig
<andrewrk>
oh man I'm about to use readlink in stage2 to store hash digest in the file system metadata instead of contents, and I think it's actually a good idea
<andrewrk>
shave off 2 read()s and a close()
<andrewrk>
thank you to whomever contributed ReadLink for windows
<andrewrk>
looks like it was kubkon :)
kristoff_it has quit [Ping timeout: 260 seconds]
marnix has quit [Ping timeout: 240 seconds]
<ifreund>
nice
mokafolio has quit [Quit: Bye Bye!]
a_chou has quit [Ping timeout: 265 seconds]
mokafolio has joined #zig
ur5us has joined #zig
wootehfoot has quit [Quit: Leaving]
nvmd has joined #zig
<pixelherodev>
Whoa, nice
a_chou has joined #zig
a_chou has quit [Client Quit]
_Vi has quit [Ping timeout: 272 seconds]
st4ll1 has joined #zig
xackus has joined #zig
Patrice_ has quit [Ping timeout: 240 seconds]
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
xackus has quit [Ping timeout: 244 seconds]
marnix has joined #zig
marnix has quit [Ping timeout: 244 seconds]
<andrewrk>
nvidia is buying arm
<pixelherodev>
...
<pixelherodev>
What's the channel's rule on cursing?