Post AwAgiMd4YYESoF0Abo by navi@social.vlhl.dev
(DIR) More posts by navi@social.vlhl.dev
(DIR) Post #AwAZgrM8e0AHqgPt2G by navi@social.vlhl.dev
2025-07-15T20:57:29.565899Z
0 likes, 0 repeats
question: since thread_local exists, is there any technical issue to giving the user of a library extra failure information out of band in a errno-like way?most of my personal code returns an status enum from the function anywayso i'm just curious if there's any actual issues with the alternative of a thread_local status flag, maybe around ffi? or something else?
(DIR) Post #AwAZgswgjazmmKWae0 by lanodan@queer.hacktivis.me
2025-07-15T21:11:32.687020Z
0 likes, 0 repeats
@navi Well given most errno are implemented via thread_local, I doubt there would be FFI issues
(DIR) Post #AwAgiMd4YYESoF0Abo by navi@social.vlhl.dev
2025-07-15T22:27:40.892883Z
1 likes, 0 repeats
@ska @lanodan i don’t really use errno for it (aside from openrc, where like 90% of the errors are errno set by libc, and 10% we set)i was thinking of something like a lib doing thread_local enum libfoo_status status;, and if say a function returns NULL or false, then status would have a lib-specific more detailed code, or even thread_local struct libfoo_status status; with even more info, like maybe failure location in a parsermost new code i usually see does that with what you called the pthreads or something similar, return that enum or struct by either the return value or a pointer argument, e.g.enum libfoo_status func(struct foo *out, int somearg);orstruct foo *func(int somearg, enum libfoo_status *status); (this one usually allows NULL status to “ignore” it)so my brain was just wondering if there’s anything technically wrong with doing the thread_local thing, or if thread_local vars just suck in general and thus everyone prefers to return the status locally one way or another
(DIR) Post #AwAh20xkoyURP62swi by navi@social.vlhl.dev
2025-07-15T22:32:34.897520Z
1 likes, 0 repeats
@ska @lanodan what i've done in the past is defining an status enum and providing a `strerror` function
(DIR) Post #AwAj1Q685GHOyfo6j2 by navi@social.vlhl.dev
2025-07-15T22:53:37.336253Z
1 likes, 0 repeats
@ska @lanodan gettext is posix now too so I'll just use it