mahmudov has quit [Remote host closed the connection]
ltriant has quit [Quit: leaving]
<fengb>
"It’s not likely to replace C for me, but it might have a place somewhere in my stack." I wonder why
adamkowalski has joined #zig
schme245 has joined #zig
adamkowalski has quit [Remote host closed the connection]
presiden has left #zig ["WeeChat 2.7"]
return0e has joined #zig
return0e has quit [Ping timeout: 260 seconds]
schme245 has quit [Remote host closed the connection]
return0e has joined #zig
SimonNa has quit [Remote host closed the connection]
marmotini_ has joined #zig
marmotini_ has quit [Remote host closed the connection]
ur5us has joined #zig
return0e_ has joined #zig
marmotini_ has joined #zig
marmotini_ has quit [Read error: Connection reset by peer]
marmotini_ has joined #zig
marmotini_ has quit [Read error: Connection reset by peer]
schme245 has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
marmotini_ has joined #zig
marmotini_ has quit [Ping timeout: 268 seconds]
marmotini_ has joined #zig
lunamn has joined #zig
marmotini_ has quit [Remote host closed the connection]
lunamn has quit [Ping timeout: 260 seconds]
lunamn_ has joined #zig
dddddd has joined #zig
marmotini_ has joined #zig
marmotini_ has quit [Remote host closed the connection]
Astronothing has joined #zig
squeek502 has joined #zig
squeek_ has quit [Ping timeout: 265 seconds]
return0e_ has quit [Remote host closed the connection]
phillyiscool has joined #zig
<phillyiscool>
Is there an equivalent of `void *` in Zig? I would like to have a struct field that can accept any struct type.
<phillyiscool>
I guess the expectation is to use generics instead of having void * fields
phillyiscool has quit [Remote host closed the connection]
schme245 has quit [Remote host closed the connection]
schme245 has joined #zig
<scientes>
ph...ahh they always leave before they get an answer...
return0e_ has joined #zig
return0e_ has quit [Remote host closed the connection]
schme245 has quit [Remote host closed the connection]
phillyiscool has joined #zig
phillyiscool has quit [Remote host closed the connection]
_Vi has quit [Ping timeout: 260 seconds]
Guest65855 has joined #zig
<Astronothing>
I wouldn't mind getting the answer
Guest65855 is now known as dimenus
<scientes>
Astronothing use [*]u8 or []u8
<scientes>
depending if you want a length
<mattmurr>
How are they different?
<scientes>
[*]u8 is a pointer, and []u8 is a slice, so a pointer and a length
<Astronothing>
scientes would I be able to convert [*]u8 to a pointer of a different type?
<scientes>
the * means the length is unknown
<scientes>
using @ptrCast
<Astronothing>
ok, thanks
<mattmurr>
makes sense now 🙂 ty
bheads has quit [Quit: bheads]
bheads has joined #zig
<SyrupThinker>
Wouldn't *@OpaqueType() be the bettet Pointer because one cannot misinterpret it?
<mq32>
SyrupThinker: "const Handle = *OpaqueType();" is a common pattern to address a "unique, but incomplete" type
<scientes>
SyrupThinker, @OpaqueType is just for compatibility with C, where it is possible to have a header define a type that doesn't have a known length
<fengb>
Opaque is generally used for “this is a known type but I don’t know what’s in it”
<scientes>
it also is limited, cause you can't add methods to it
<scientes>
which is annoying when trying to zigify a C library
<SyrupThinker>
All the things I'd want from a void pointer
<scientes>
void * is differen't
<scientes>
cause it doesn't have a type
<scientes>
its the ANY type
<scientes>
but just use what ANSI C uses, char *, or [*]u8
<fengb>
Opaque wasn't designed to hold "any type" but instead for "forward declared struct pointers"
<SyrupThinker>
I think it is bad idea to use a pointer that can be dereferenced if its supposed to represent another type.
_Vi has joined #zig
<fengb>
How about... *c_void? :P
<scientes>
SyrupThinker, zig isn't trying to tell you what to do
<scientes>
that is the C++ madness rabbit hole
<SyrupThinker>
fengb: Eh, good enough I guess, makes the intend more clear when one knows C
<fengb>
C++ gives you 5 different incompatible ropes
<scientes>
you mean nooses?
<fengb>
And one of those was introduced as the latest gold standard
<fengb>
I don't think I've seen any Zig code that literally means "any type" so I'm not sure what the convention should be
<SyrupThinker>
scientes: I am aware, my point was just that using a pointer to OpaqueType forces a pointer case to use any data, forcing the user to think
<fengb>
Most of those cases in C are generics, which is better with comptime comparisons
<SyrupThinker>
*cast
<scientes>
fengb, well, these are all byte machines, so [*]u8 with appropiate alignment is what I would use...
<scientes>
no reason to be as complicated as C
<fengb>
I do agree with SyrupThinker that communicating intent is important
<scientes>
yeah, but we don't want inheritable types
<scientes>
which is what he is asking for
<scientes>
or rather we don't have them
<fengb>
My usual response to that is: issue 130, gonna avoid an internet argument >_>
<SyrupThinker>
I do not believe I asked for that
<SyrupThinker>
Because I have no use for them
<scientes>
i'm just pointing out that this specific thing has a clear abstraction
<scientes>
and I'd rather not support just one instance of it
return0e_ has joined #zig
<SyrupThinker>
Alright, just wanted to have some opinion on that, thanks for responding
mgxm has quit [Quit: ....]
<mq32>
what's the correct type if i want to export a "void * " handle? jus use void * ?
mgxm has joined #zig
nocko` has joined #zig
<mq32>
huh
<mq32>
seems like get_c_type cannot translate function pointers?
<scientes>
and my patch to support vectors on that never got merged....
<nocko`>
I'm new to zig and trying to write a high-level wrapper for the init_module syscall. I'm using the std.os.linux sources as a guide, but I cannot seem to make a parameter of the sentinel-terminated pointer type.
<nocko`>
This seems to be the pattern in the std sources...
<scientes>
nocko`, is this just for fund? cause you realize libkmod was created not that long ago to solve all the problems with the old modprobe
<scientes>
*fun
<scientes>
also, you probably want finit_module()
<nocko`>
The project is a statically linked app to unlock mtd and update bootloader on embedded linux. I'm embedding the ko and the new flash contents.
<scientes>
why can't you just statically link libkmod?
<scientes>
but yeah, that seems reasonable
<nocko`>
It's quite possible that I could, maybe overkill for one syscall. I'm secondarily intereseted in why I can't declare a function with a parameter that matches the stdlib.
<nocko`>
non-variadic std.debug.warn feels clunky. Probably I should stop being lazy and use better output apis...
<nocko`>
ooh, but output while building libc is very nice!
<scientes>
nocko`, yeah i just ran into that
<scientes>
i couldn't even get std.debug.warn to work...
<mikdusan>
andrewrk: I'm still working on adding an arena allocator to stage1; would like to know if it's a big no-no to use constructors/destructors? eg. I have coded an ArenaList to replace ZigList but it needs to be associated with an arena instance
FireFox317 has quit [Remote host closed the connection]
<pixelherodev>
"Zig requires LLVM to be built with all default targets enabled." There a way to deliberately work around this and only build native compilation?
<pixelherodev>
Otherwise I'm going to be held up for a few hours recompiling LLVM :P
* pixelherodev
sighs in pain
schme245 has joined #zig
<pixelherodev>
Guess I'll update LLVM/Clang to 9.0.1 while I'm at it
<scientes>
pixelherodev, yeah the in-tree build was also rejected, which adds even more pain
<scientes>
when doing something that requires modifying both
<scientes>
or when doing a bisection
<leeward>
I ran `zig build test-std` with a test in heap/logging_allocator.zig and it didn't get run. The same test in heap.zig did execute (and fail, correctly). Is there something I have to do to add a file to the set of files with tests?
<pixelherodev>
Does zig at least support LLVM 10?
<pixelherodev>
If so, might as well jump to 10 so I can start working on AVR
<scientes>
master is on 9
<pixelherodev>
Drats
<scientes>
9 works on avr
<pixelherodev>
What?
<scientes>
I think....
<pixelherodev>
Hmm... not on Gentoo...
<leeward>
Oh, does 10 have good AVR support?
<leeward>
9's is...not great.
<scientes>
pixelherodev, you just have to turn it on
<pixelherodev>
Nah, I mean it's not an option
<scientes>
oh , it was out of tree?
<pixelherodev>
Gentoo doesn't have it as an option until LLVM 10
<scientes>
anyways, gcc's avr was always better
<pixelherodev>
Sure, but that doesn't work with Zig
<pixelherodev>
Unless LLVM has a secret GIMPLE backend
<scientes>
pixelherodev, noone wants to maintain such a thing
<scientes>
in either direction
<pixelherodev>
shocker
<pixelherodev>
Would be neat to have bidirectional translation though
<pixelherodev>
I'd be interested in seeing what could be done optimization-wise then
<leeward>
It would give LLVM languages like Zig and Rust instant support for so many platforms.
<leeward>
How many people out there really want to maintain an ARC compiler?
dimenus has quit [Remote host closed the connection]
schme245 has quit [Remote host closed the connection]
schme245 has joined #zig
<pixelherodev>
Yeah, but it's also extremely outdated
<pixelherodev>
LLVM 3.3 is the last supported release AFAICT
<leeward>
That's your thing about nobody being interested in maintaining it.
<leeward>
I'm not really sure why it exists. All of LLVM's target platforms are supported by GCC, and the optimizer isn't so much better that I'd stick something like that in the loop.
<fengb>
LLVM originated as a backend for GCC before it got frontends
<leeward>
Maybe GCC didn't support LTO when it existed?
<leeward>
scientes: I guess that LLVM/GCC integration thing didn't pan out.
<scientes>
leeward, that was 2005
<leeward>
I noticed.
<scientes>
i just sent you it so you could understand the history a little better
<leeward>
The proposal there was to use LLVM's LTO with GCC, which was still pondering the idea at the time.
<scientes>
that is more an excuse
<scientes>
the real proposal is for apple not to have to spend all the money to develop clang
<fengb>
Didn't Lattner/Apple want more flexible integration and GNU said no help for proprietary software?
<leeward>
It's not proprietary software, and they floated the idea of assigning copyright to the FSF.
<leeward>
Or are you talking about the software Apple was building with it?
<scientes>
leeward, you can build propiatary software with gcc
<leeward>
I know.
<fengb>
Yeah, Apple hired Lattner to work on compilers. That eventually led to inhouse Clang
<fengb>
I don't think that was the original intention but then a pissing contest involved :P
<fengb>
I can't English
<BaroqueLarouche>
since GCC changed to GPL3, corporations become hesistant to use it
<scientes>
fengb, he also got hired right after GPL3 came out, and gcc immediately switched
pmwhite1 has joined #zig
<scientes>
that said, LLVM does have a better architecture, even if the code is so-so
<BaroqueLarouche>
on PS3 for instance, the GCC version was stuck to the last GCC version using GPL2.
<leeward>
I don't see the problem with GPLv3 for GCC as long as it has the same exceptions to GPLv2 that it had before.
<scientes>
I don't say that lightly
<scientes>
gcc and llvm both have their advantages
<lupine>
in fairness, destroy all proprietary software
<pixelherodev>
There a reason a `fn` isn't the same as an `extern fn`?
<BaroqueLarouche>
extern fn makes the function uses the C ABI
<leeward>
I think that compilers as a whole are better off for there being competition.
<pixelherodev>
Ah
<scientes>
BaroqueLarouche, except that the PS3 doesn't ship gcc, so the gpl3 anti-tivo clause doesn't apply
<scientes>
BaroqueLarouche, same in regards to android
<BaroqueLarouche>
sorry mixing it up with export
<pixelherodev>
Yeah that's what I thought
<scientes>
(although i believe android is entirely built with llvm/clang these days)
<pixelherodev>
Using a C import
<pixelherodev>
Which uses function pointers
<BaroqueLarouche>
Android has moved to clang
<pixelherodev>
And apparently ` = struct{fn func...}.func` isn't good enough
<leeward>
lupine: Hard to justify not letting people license the software they write the way they want.
<pixelherodev>
Does work with exported function though
<lupine>
nah
<lupine>
morality is good like that
<leeward>
I don't see the moral superiority of denying people options.
<fengb>
I've heard that GCC is intentionally architected poorly to prevent proprietary extensions
* lupine
denies leeward the option to kill lots of other people
<lupine>
oh how immoral of me
<leeward>
Ok, so you're comparing shipping binary-only software to killing people now?
<companion_cube>
I heard the same, so they've brought llvm on themselves
<lupine>
yeah
<lupine>
we're not going to get this to a reasonable level of complexity without destroying this channel, so let's leave it
<leeward>
Good point.
<leeward>
Also, fengb, I hadn't heard that, but it sounds like a joke.
<companion_cube>
nah, they explicitely didn't want gcc to have an API
<mikdusan>
fengb: I heard they intentionally kept GIMPLE undocumented and opaque
<pixelherodev>
argh - `Generate .h...TODO implement get_c_type for more types`
<pixelherodev>
and then a crash
<pixelherodev>
I don't even need a .h!
<leeward>
Whoopsie.
<pixelherodev>
Oh right --disable-gen-h
<leeward>
Don't expect it to get a lot better before self-hosted is a thing, pixelherodev.
<pixelherodev>
Yeah, it's fine
<pixelherodev>
Yay, plugin building is working now!
<leeward>
\o/
pmwhite1 is now known as pmwhite
<mikdusan>
frmdstryr: I added a variation on that code - apparently you can deref a string literal to get at the array literal if desired. https://hastebin.com/iqotakumov.js
<frmdstryr>
Won't that modify the original then? I need both
<mikdusan>
yes. just saying if you needed a buffer and not orig.
<frmdstryr>
Gotcha, both are useful, so thanks for sharing
GrooveStomp has quit [Quit: GrooveStomp]
mahmudov has joined #zig
marmotini_ has joined #zig
mahmudov has quit [Ping timeout: 268 seconds]
marmotini_ has quit [Remote host closed the connection]
schme245 has joined #zig
mahmudov has joined #zig
<pixelherodev>
Huh
<pixelherodev>
Zig just, oddly, started only compiling needed parts of libc
<pixelherodev>
It's actually fast now
schme245 has quit [Remote host closed the connection]
mahmudov has quit [Read error: Connection reset by peer]
<terinjokes>
is there a correct way to import from lib/os/bits from a user program?
<terinjokes>
i'm currently thunking a syscall with asm myself (and I do plan on sending a PR to add it to the os package), but was hoping for a "correct" way to do it in the meantime
<pixelherodev>
Uh
<pixelherodev>
That should already be in std.os
<pixelherodev>
Anything in std.os.bits should be
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen1 has joined #zig
dingenskirchen1 is now known as dingenskirchen
mahmudov has joined #zig
mahmudov has quit [Read error: Connection reset by peer]
waleee-cl has quit [Quit: Connection closed for inactivity]
<daurnimator>
leeward: I beat you when/how?
ltriant has joined #zig
<terinjokes>
pixelherodev: I do see the usingnamespace to import it, and I can see the SYS_ cnstants on std.os. I don't however see std.os.syscall4, which I would expect
<daurnimator>
terinjokes: that's under e.g. std.os.linux.syscall4
<daurnimator>
which syscall are you missing anyway?
<terinjokes>
ahh, excellent! I'm still getting used to reading zig code. i see this is exported on line 31 of os.zig
<terinjokes>
on linux I'm using sendfile/sendfile64. I wouldn't mind trying my hand at sending a PR adding it to std