ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
ryan__ has joined #zig
dimenus has quit [Ping timeout: 240 seconds]
cenomla has joined #zig
cenomla has quit [Quit: cenomla]
cenomla has joined #zig
dimenus has joined #zig
ryan__ has quit [Ping timeout: 240 seconds]
ryan__ has joined #zig
dimenus has quit [Ping timeout: 276 seconds]
dimenus has joined #zig
ryan__ has quit [Ping timeout: 276 seconds]
ryan__ has joined #zig
dimenus has quit [Ping timeout: 240 seconds]
<GitHub185> [zig] andrewrk pushed 1 new commit to master: https://git.io/vbTIz
<GitHub185> zig/master 7066283 Andrew Kelley: translate-c: support const ptr initializer
cenomla has quit [Quit: cenomla]
dimenus has joined #zig
ryan__ has quit [Ping timeout: 260 seconds]
ryan__ has joined #zig
dimenus has quit [Ping timeout: 248 seconds]
dimenus has joined #zig
ryan__ has quit [Ping timeout: 276 seconds]
ryan__ has joined #zig
dimenus has quit [Ping timeout: 276 seconds]
dimenus has joined #zig
ryan__ has quit [Ping timeout: 276 seconds]
ryan__ has joined #zig
dimenus has quit [Ping timeout: 240 seconds]
arBmind has joined #zig
dimenus has joined #zig
ryan__ has quit [Ping timeout: 268 seconds]
jjido has joined #zig
ryan__ has joined #zig
dimenus has quit [Ping timeout: 248 seconds]
dimenus has joined #zig
ryan__ has quit [Ping timeout: 240 seconds]
arBmind has quit [Quit: Leaving.]
<skyfex> Hmm, having a bool field in a packed struct seems to mess up @offsetOf (always returns 0)
<skyfex> Same with @IntType(false, 1)
arBmind has joined #zig
ryan__ has joined #zig
dimenus has quit [Ping timeout: 264 seconds]
dimenus has joined #zig
ryan__ has quit [Ping timeout: 276 seconds]
ryan__ has joined #zig
dimenus has quit [Ping timeout: 240 seconds]
jjido has quit [Ping timeout: 248 seconds]
dimenus has joined #zig
ryan__ has quit [Ping timeout: 260 seconds]
ryan__ has joined #zig
dimenus has quit [Ping timeout: 248 seconds]
dimenus has joined #zig
ryan__ has quit [Ping timeout: 258 seconds]
ryan__ has joined #zig
dimenus has quit [Ping timeout: 248 seconds]
jjido has joined #zig
dimenus has joined #zig
ryan__ has quit [Ping timeout: 246 seconds]
ryan__ has joined #zig
dimenus_ has joined #zig
dimenus has quit [Ping timeout: 240 seconds]
dimenus_ has quit [Quit: Leaving]
dimenus has joined #zig
ryan__ has quit [Ping timeout: 248 seconds]
<andrewrk> skyfex, can I see your packed struct definition?
<andrewrk> thank you for the pledge btw :)
ryan__ has joined #zig
<skyfex> const PinCnf = packed struct { dir: bool, input: bool, pull: u4, reserved1: u4, drive: u3, sense: u2 };
<skyfex> And then @offsetOf(PinCnf, "drive") returns 0
<andrewrk> what would you expect it to return?
dimenus has quit [Ping timeout: 268 seconds]
<andrewrk> maybe it should be renamed to @byteOffsetOf
<skyfex> Hmm, I haven't tested it enough, seems I get the same if I set dir/input/pull to u2 as well
<andrewrk> oh, there's an extra byte in here I didn't see
<andrewrk> it should return 1 for drive
<andrewrk> oh wait, I know what's going on
<andrewrk> ok so if you walk over the fields 1 by 1 and notice when you hit a byte boundary
<andrewrk> there's a byte boundary at offset 0
<andrewrk> then we see 1 bit (bit offset 1), 1 bit (bit offset 2), 4 bits (bit offset 6), 4 bits (bit offset 10), 3 bits (bit offset 13), 2 bits (bit offset 15)
<andrewrk> none of those are on a byte boundary
<andrewrk> so the whole thing is represented as a u16 and masking/shifting is done to load/store
<andrewrk> so the offset of all the fields is 0, which is the offset of the u16 where the bit fields are inside
<andrewrk> if you explain what you need to use @offsetOf for, maybe I can suggest the best way to accomplish your goal
<skyfex> Odd, but I guess that makes sense in a way
<jjido> OffsetOf is little help with packed isn't it
<skyfex> I wasn't really after byte offset anyway, I was just trying it out. What I'd really be interested in is bit offset
<andrewrk> we could have that
<andrewrk> maybe we rename @offsetOf to @byteOffsetOf and add @bitOffsetOf
<andrewrk> jjido, yes, the problem is you need a special kind of pointer to point to a bit field - a pointer that has the bit offset from the address in the type
<skyfex> But hopefully, if packed structs are implemented well enough, you wouldn't need it. But if it's possible to specify all of a microcontrollers register with packed structs, it would be nice to be able to get their offsets from there, instead of having to define a whole bunch of constants in addition
<skyfex> Just in case
<andrewrk> I see
<andrewrk> yeah, that would make sense, and it's a straightforward builtin function to add
<skyfex> FYI, I got a piece of Zig code to run on the micro:bit / nRF51822 on monday.
<jjido> You could have offsetOf and an additional bitShift (relative to offset) for packed struct
<andrewrk> awesome! what cpu arch is that?
<skyfex> Although I had to use GCC to link.. some issue with the linker script and LLVM
<skyfex> ARM Cortex M0
<andrewrk> I'd be curious to reproduce the linker issue - I could get a bug report filed for the LLD project. it's pretty active
<andrewrk> I could also try it with llvm6 which has a lot of LLD improvements
<skyfex> I can put up my example on github.. it's quite small, so should be useful for reproduction
<andrewrk> I'd appreciate that
<skyfex> And I hope I can make a decent example and writeup to illustrate how Zig could be useful on microcontrollers. Not sure if I should wait for 0.2 or not though.. depends on what issues I find
<andrewrk> I'm interested to work with you on working out all the major issues you run into, such as this linker thing
<skyfex> Ah yeah, like i wrote in the Github comment, specifying the type for enum tags would be great
<andrewrk> the enum tag type should be reasonably easy to implement too
<skyfex> Then I could generate a really nice struct definition of the registers from the XML spec
<andrewrk> nice
<andrewrk> there's one more issue relevant to you I believe: https://github.com/zig-lang/zig/issues/307
<andrewrk> there was some confusion on that issue, but now I know how to proceed
<skyfex> cool. I was worried that the packing was incorrect, but since it's not I can continue to play around with mapping registers to struct, but without enums for now
<skyfex> i would like to play around a bit with io and fmt over UART as well, before I publish anything. That might lead to some valuable feedback
<andrewrk> agreed
dimenus has joined #zig
ryan__ has quit [Ping timeout: 248 seconds]
cenomla has joined #zig
ryan__ has joined #zig
cenomla has quit [Ping timeout: 276 seconds]
dimenus has quit [Ping timeout: 248 seconds]
cenomla has joined #zig
dimenus has joined #zig
ryan__ has quit [Ping timeout: 248 seconds]
ryan__ has joined #zig
dimenus has quit [Ping timeout: 268 seconds]
jjido has quit [Ping timeout: 276 seconds]
cenomla has quit [Quit: cenomla]
cenomla has joined #zig
dimenus has joined #zig
ryan__ has quit [Ping timeout: 248 seconds]
jjido has joined #zig
cenomla has quit [Quit: cenomla]
ryan__ has joined #zig
dimenus has quit [Ping timeout: 276 seconds]
jjido has quit [Ping timeout: 260 seconds]
arBmind has quit [Quit: Leaving.]
arBmind has joined #zig
dimenus has joined #zig
ryan__ has quit [Ping timeout: 248 seconds]
ryan__ has joined #zig
dimenus has quit [Ping timeout: 250 seconds]
dimenus has joined #zig
ryan__ has quit [Ping timeout: 248 seconds]
ryan__ has joined #zig
dimenus has quit [Ping timeout: 240 seconds]
dimenus has joined #zig
ryan__ has quit [Ping timeout: 260 seconds]
jjido has joined #zig
ryan__ has joined #zig
dimenus has quit [Ping timeout: 276 seconds]
arBmind has quit [Quit: Leaving.]
jjido has quit [Read error: No route to host]
dimenus has joined #zig
ryan__ has quit [Ping timeout: 255 seconds]
ryan__ has joined #zig
dimenus has quit [Ping timeout: 276 seconds]
dimenus has joined #zig
ryan__ has quit [Ping timeout: 248 seconds]
ryan__ has joined #zig
dimenus has quit [Ping timeout: 248 seconds]
dimenus has joined #zig
ryan__ has quit [Ping timeout: 268 seconds]