ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
davr0s has joined #zig
mnoronha has quit [Ping timeout: 244 seconds]
reductum has quit [Quit: WeeChat 2.2]
mnoronha has joined #zig
mnoronha has quit [Ping timeout: 250 seconds]
mnoronha has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
mnoronha has quit [Ping timeout: 240 seconds]
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
mnoronha has joined #zig
mnoronha has quit [Ping timeout: 244 seconds]
phrost has joined #zig
phrost has left #zig [#zig]
mnoronha has joined #zig
mnoronha has quit [Ping timeout: 245 seconds]
mnoronha has joined #zig
_whitelogger has joined #zig
reductum has joined #zig
<tyler569> I am working on some network code, and the way you take a dhcp address on linux and open a socket to it is to cast a char * (h_addr) to a struct in_addr *, but doing this in zig is causing pointer alignment problems, anyone know how I can convince the compiler that this is ok?
<tyler569> I tried @bitCast, but it doesn't seem to like casting from an 8 bit value to a 32 bit value, since it's not taking the addresses as far as I can tell
<scientes> x86 doesn't have alignment problems
<tyler569> right, but I get a compile error
<tyler569> "error: cast increases pointer alignment"
<scientes> ahh yeah there needs to be a way to get around that
<scientes> use @alignCast()
<tyler569> aha, that seemed to do the trick!
<scientes> you could also use @memcpy, but that doesn't accept any type yet, open a bug to bother andrewrk about it
<scientes> any memcpy would avoid undefined behavior
<tyler569> what do you mean by it doesn't accept any type?
<scientes> you have to cast to [*]u8
<tyler569> oh, I see, that it's just [*]const u8
<scientes> andrew said he was considering changing that however, and i think its a good idea
<tyler569> ah ok
<scientes> welcome to zig! hope you stay and contribute
<tyler569> thanks! I've been watching for a while, but this is the first major thing I've done, really enjoying it so far
mnoronha has quit [Ping timeout: 246 seconds]
davr0s has joined #zig
<kristate> scientes: what's going on here? https://github.com/ziglang/zig/pull/1453
<kristate> scientes: is that test case failing, or is it a valid case?
<kristate> scientes: it's failing -- lowercase: 0febabe
<kristate> it should be double width...
<scientes> <kristate> it should be double width...
<scientes> yep
<kristate> scientes: this is bigger than just printing strings -- it should be the same for all hexbytes
<scientes> I just was using it to print the value of a promise and notice the bug
<kristate> hmm, not only that \x0E prints 0
<kristate> rather
<kristate> \x0E prints E
<kristate> scientes: okay, I have a patch
<kristate> I will add you as a co-author and setup a PR
<scientes> you can push it directly to my pull request
<scientes> if you have commit access
<scientes> i guess you are not a member however
mnoronha has joined #zig
mnoronha has quit [Quit: Ping timeout (120 seconds)]
mnoronha has joined #zig
mnoronha has quit [Read error: Connection reset by peer]
mnoronha has joined #zig
reductum has quit [Quit: WeeChat 2.2]
<kristate> scientes: we are already using futexes where available
<scientes> oh, the event stuff said no syscalls
<kristate> do a grep on the repo
<scientes> yeah i just did
<kristate> what we are generally aiming for is for co-routines to be implementation independent from the event loop
<kristate> rather, we can use coroutines to build the event loop
<scientes> yeah i just read inaccurate comments https://github.com/ziglang/zig/blob/master/std/event/rwlock.zig#L10
<scientes> if it uses Loop it makes syscalls
<scientes> should have used grep
<kristate> yeah, good idea to grep the stdlib
<kristate> i'm glad that andy outlined the problem so well
<scientes> can you fallow my proposal, its kinda complicated?
<scientes> yeah
<kristate> reading
unique_id has joined #zig
<kristate> co routines are backed by llvm intrinsics
<kristate> so the keywords are easier to implement
<scientes> yes i've read that
<scientes> but cancel is not an llvm intrinsic, destroy is
<scientes> and doing .scheduleCancellation() is difficult
<kristate> ir_render_cancel -> get_coro_destroy_fn_val -> llvm.coro.destroy
<kristate> cancel keyword is connected to the llvm.coro.destroy intrinsic
<scientes> no, ir_render_suspend calls destroy
<scientes> if the is_cancelled_bit is set
<scientes> which gets set by ir_render_cancel
<kristate> I don't see a ir_render_suspend ?
<scientes> oh ir_gen suspend
<kristate> hmm, we should try to keep coros as simple as possible
<scientes> we could drop cancel, and replace it with destroy
<scientes> yeah that is the clean way to do it
<kristate> I think we should make a diagram outlining each process
<kristate> there are only so many states --
<scientes> my proposal is entirely user-space
<scientes> if we replace cancel with destroy...
<kristate> scientes: yeah, I don't know if we should have co-routines be half compiler half user-space
<kristate> it's kind of like a bridge without guardrails
<scientes> yeah i don't like cancel
<kristate> obviously
<kristate> rather
<kristate> obviously co-routines will be used in userspace to create loops, etc.
<scientes> and getting rid of cancel brings promise back to alignment 4
<kristate> what is it at right now? 8?
<scientes> yeah
<kristate> I thought that using lower 8 bits was nifty
<kristate> rather lower 3
<scientes> 3
<scientes> yeah i use the low bit in my rb.zig
<scientes> back, my graphics driver crashed ---i need a new video card
<scientes> last line i got:
<scientes> <scientes> yeah i use the low bit in my rb.zig
mnoronha has quit [Quit: Ping timeout (120 seconds)]
mnoronha has joined #zig
mnoronha has quit [Read error: Connection reset by peer]
mnoronha has joined #zig
<kristate> back
<kristate> scientes: remember to sleep
mnoronha has quit [Remote host closed the connection]
stratact has joined #zig
_whitelogger has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
very-mediocre has joined #zig
<scientes> kristate, back
<kristate> hey
<scientes> all this complicated stuff with co-routines is why I was proposing the go threading model
<scientes> but we want to be like c, so we can build that on top
<scientes> futex is quite complicated to do right: https://www.kernel.org/doc/Documentation/robust-futexes.txt
<tyler569> ls
<tyler569> ach oops
davr0s has joined #zig
ofelas has joined #zig
<kristate> andrewrk: what are your thoughts on the current co-routine situation ?
<kristate> I've been trying to map it out in some ASCII art
<scientes> Mutexs should be done right so they can be shared (in shared memory) between 32-bit and 64-bit processes and even on heterogeneous systems
<scientes> which would be an improovement over glibc
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
Thorn has quit [Quit: Quit]
Thorn has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
<scientes> i have to look at the source more
<scientes> IrBasicBlock *canceled_block = ir_create_basic_block(irb, parent_scope, "IsCanceled");
<scientes> what does that do?
<scientes> IrInstruction *destroy_ourselves = ir_build_phi(irb, parent_scope, node, 2, incoming_blocks, incoming_values);
<scientes> yeah the co-routine destroys itsself, despite the docs saying,
<scientes> The ‘llvm.coro.destroy’ intrinsic destroys a *suspended* coroutine.
<scientes> i guess that just means the co-routine can't do anything after llvm.coro.destroy is called---the docs should be updated
<scientes> (if that is the case)
<scientes> this bears the question: Does llvm.coro.destroy use the stack?
<kristate> hmm
<kristate> check-out this pdf
dbandstra has joined #zig
<scientes> yeah i think we are using llvm.coro.destroy wrong
<scientes> but it might be necessary for NM scheduling, so we could ask that it be supported
<scientes> this might be why optimizations are not working with co-routines
<scientes> wtf::lock look beautiful except for being written in C++
<scientes> its so complicated thought that re-implementing it would be time-consuming, making it temping to wrap it in a C API
<scientes> we are going to be tempted to bring in c/C++ code to zig for regular expressions to, I think that needs to be discussed
<scientes> oh WTF::Lock doesn't use robust mutexes anyways, so they can't be shared accross processes
<scientes> kristate, ParkingLot is like go's netpoller threading model, but for locks
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
very-mediocre has quit [Quit: Page closed]
dbandstra has quit [Quit: Leaving]
clownpriest has joined #zig
clownpriest has quit [Client Quit]
clownpriest has joined #zig
clownpriest has quit [Quit: Textual IRC Client: www.textualapp.com]
clownpriest has joined #zig
clownpriest has quit [Quit: Textual IRC Client: www.textualapp.com]
clownpriest has joined #zig
clownpriest has left #zig [#zig]
<andrewrk> I'm about to merge this
clownpriest has joined #zig
stratact has quit [Remote host closed the connection]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
kristate has quit [Remote host closed the connection]
kristate has joined #zig
kristate has quit [Remote host closed the connection]
kristate has joined #zig
dbandstra has joined #zig
kristate has quit [Ping timeout: 246 seconds]
minus has quit [Ping timeout: 240 seconds]