Sign in

thephd.dev

@thephd.dev
0 followers 0 following 0 posts
PostsRepliesMedia
Björkus "No time_t to Die" Dorkus @thephd.dev · 22/08/2026
C standards committee meeting ended today i should really write a blog about it but for now,,,
3611
Björkus "No time_t to Die" Dorkus @thephd.dev · 17/07/2026
I {HEART} working with C++ Modules !!!
An image of a potato growing through a wall, its reddish roots climbed up all past the corner of the desk against the wall and spiraling out in all sorts of directions in search of nutrients and water. The text above sets the wall-puncturing, overgrown potato in contrast with its normal counterparts as a metaphor for C++ modularized code:

Normal modules: "You must store us in the right folder next to all our other source files unless you provide an explicit mapping that is also documented by the specification."

C++ modules: "WHERE'S MY TRANSLATION UNITS ?"
2346
Björkus "No time_t to Die" Dorkus @thephd.dev · 13/07/2026
Fine-tuned API control that can have real attributes present on real declarations, and can have some good reporting with high quality-of-implementation. I like it.
A code snippet which reads:

``cpp
#include <stdio.h>

#define V0_DEPRECATED 1

const char* v1_name = "treehouse.systems!";

#if defined(V0_DEPRECATED) && (V0_DEPRECATED != 0)
[[deprecated("v0_name will be removed in version 2, please upgrade")]]
#endif
_Alias v0_name = v1_name;
_Alias v2_name = v0_name;

int main () {
  printf("v1: %s\n", v1_name);
  printf("v0: %s\n", v0_name); // diagnostic encouraged
  printf("v2: %s\n", v2_name); // diagnostic encouraged
}
```A compiler invocation with output which reads:

> .make/foxscotch/install/bin/gcc -std=c2y -Wall -Wpedantic main.c -o main.c.exe
main.c: In function 'main':
main.c:15:3: warning: 'v0_name' is deprecated: v0_name will be removed in version 2, please upgrade [-Wdeprecated-declarations]
   15 |   printf("v0: %s\n", v0_name); // diagnostic encouraged
      |   ^~~~~~
main.c:10:1: note: declared here
   10 | _Alias v0_name = v1_name;
      | ^~~~~~
main.c:10:1: note: through transparent alias here
main.c:16:3: warning: 'v0_name' is deprecated: v0_name will be removed in version 2, please upgrade [-Wdeprecated-declarations]
   16 |   printf("v2: %s\n", v2_name); // diagnostic encouraged
      |   ^~~~~~
main.c:10:1: note: declared here
   10 | _Alias v0_name = v1_name;
      | ^~~~~~
main.c:11:1: note: through transparent alias here
   11 | _Alias v2_name = v0_name;
      | ^~~~~~
1181
Björkus "No time_t to Die" Dorkus @thephd.dev · 11/07/2026
Took way too long but this code now works in GCC.
C code that reads:

#include <stdio.h>

#define bar(x) _Generic(x, \
	int v: v, \
	const double: (int)2.0,\
	const int v: v * 2,\
	struct foo v: v.name \
)

struct foo { char* name; };

extern int x;

int fn(void) {
	return x += 1;
}

double fnd(void) {
	return (double)(x += 1);
}

int main() {
	struct foo f = { "test" };
	int v1 = _Generic(3, int v [[maybe_unused]]: 3);
	printf("%d (expected: 3)\n", v1);

	int v2 = _Generic(x, int v [[maybe_unused]]: v, double v: (int)v);
	printf("%d (expected: 20)\n", v2);
	bar(f) = "something";
	printf("%s (expected: something)\n", f.name);

	printf("(part 1, x before = %d)\n", x);
	int v3 = _Generic(fn(), int v: 0, double v: (int)v);
	printf("%d (expected: 0)\n", v3);
	printf("(part 1, x after  = %d)\n", x);


	printf("(part 2, x before = %d)\n", x);
	int v4 = _Generic(fn(), int v: v * v, double v: (int)v);
	printf("%d (expected: 484)\n", v4);
	printf("(part 2, x after  = %d)\n", x);

	printf("(part 3, x before = %d)\n", x);
	int v5 = _Generic(fnd(), int v: v * v, double: 3.0);
	printf("%d (expected: 3)\n", v5);
	printf("(part 3, x after  = %d)\n", x);

	const int xc = 20;
	int v6 = _Generic(xc,
		int v: v * v,
		double: 3.0
	);
	printf("%d (expected: 400)\n", v6);

	return 0;
}

int x = 20;
1111
Björkus "No time_t to Die" Dorkus @thephd.dev · 20/06/2026
Guh. Finally fixed this up, and it tosses exceptions on failure now too.
Command and console output:

cat ./main2.c++ && ./main2.c++.exe || echo return result value: $?
#include <embed>

#depend "MAINTAINERS"

int main () {
        static constexpr std::span<const unsigned char> data =
                std::embed<unsigned char>("MAINTAINERS", 0, 1);
        static constexpr std::span<const std::byte> data2 =
                std::embed<std::byte>("MAINTAINERS", 3, 1);
        static constexpr std::span<const char> data3 =
                std::embed<char>("MAINTAINERS", 6, 2);

        static_assert(data.size() == 1);
        static_assert(data[0] == 'N');
        static_assert(data2.size() == 1);
        static_assert((unsigned char)(data2[0]) == 'e');
        static_assert(data3.size() == 2);
        static_assert(data3[0] == '=');
        static_assert(data3[1] == '=');

        return (int)data2[0];
}
return result value: 101
1130
Björkus "No time_t to Die" Dorkus @thephd.dev · 03/05/2026
Jumpscare a "Nobody Reviews Compiler Output" person with One Simple Image.
The logo of Matt Goldbolt's compiler explorer website - https://godbolt.org
2384
Björkus "No time_t to Die" Dorkus @thephd.dev · 03/05/2026
A better look, since I actually learned how to use texi stuff better. (The note for `locus` is also much less snobby.) Double image because alt text limits are bullshit.

Built-in Function: template <typename Ty, typename Ch>
consteval Ty const * __builtin_std_embed (
unsigned int locus, int &sstatus, size_t &out_size, Ty const *indicator_ptr,
size_t resource_name_size, Ch const *resource_name, size_t offset[, size_t limit])

    Returns a pointer to backing storage suitably-sized to access out_size elements of a contiguous sequence of const T objects. The signature above is not exact and the builtin does not behave exactly as a function template with Ty and Ch template types, but is a decent approximation for a regular function that can infer Ty and Ch from what is passed in. Template arguments cannot be passed in explicitly and will result in a parsing errors.

    locus is broken down as do-local-search = (locus & 0x1) and call-stack-distance = (locus >> 1). do-local-search is whether a local file location-based search should be performed at all. call-stack-distance is the distance that this builtin call is removed from where a normal user would be interfacing with this builtin for aforementioned file-based local search. For example, from within the depths of a std::embed call, locus would likely be 0b101 or 0b111.

    Note: The locus argument should typically be 1 (do quoted search) and is typically significant for implementers wrapping this builtin. If you are asking the question "am I an implementer?", then you should probably be passing in a value equivalent to 1 (do quoted search) or 0 (do not do quoted search). Complex recursive calls may require the use of locus with extra depth. In general, it is not advisable to rely on local file-based search: use --embed-dir=... to provide a proper directory and #depend <...> to rely on that directory, with appropriate * or ** markers in the #depend as needed.

    The limit argument is optional.    status is one of:

        0 - The file could not be found.
        1 - The file was found, #depended on, and not empty.
        2 - The file was found but was not properly #depended on.
        3 - The file was found and #depended on, but it was empty. 

    If the function returns, status will be one of the above returns. The compiler will emit an error if some other case such as improper arguments is violated.

    The resource is considered empty if the combination of offset and limit causes the effective size of the resource to be 0. In all cases where status is not 3, a null pointer of type T const* is returned and out_size is untouched. offset is applied from the start of the found resource, before limit is applied.

    Otherwise, if status is 3, out_size is the number of T elements in the returned non-null pointer.

    T must be an integral or enumeration type where sizeof(T) == 1 && alignof(T) == 1 is true.

    Ch must be one of char, wchar_t, or char8_t.

    Note: Strings that are 8-bits wide are treated as byte strings and typically sent directly to underlying file systems. Wide wchar_t strings of size 16-bits is typically treated as UTF-16, and wide wchar_t strings of size 32-bits is typically treated as UTF-32, unless otherwise dictated by command line options such as -fwide-exec-charset=.... If a conversion has to be done and it fails, an error occurs. Users may try different strings inputs and various options to try to pass through paths as faithfully as possible. -fexec-charset=... does not affect this because all 8-bit strings are treated the same. When ported to Windows systems, this may not be the case as the native file system interface utilizes UTF-16.

    For the best portability and results, utilize paths that are clean UTF-8.

    Important: The returned pointer is not unique to the invocation of the builtin and it is not guaranteed to return a unique pointer to unique data. Its address is non-unique.
130
Björkus "No time_t to Die" Dorkus @thephd.dev · 02/05/2026
GCC docs. Looks nice. Both GCC and Clang patches fully completed. Could use some tweaking but tbh it's done. No point submitting to either since it's C++29 stuff but yeah, I'm all set.
1241
Björkus "No time_t to Die" Dorkus @thephd.dev · 02/05/2026
It's live! godbolt.org/z/71f3xxcYh
A code snippet using a new feature of _Generic selection in C, which reads:

#include <stdio.h>

#define bar(x) _Generic(x, \
  int v: v, \
  struct foo v: v.name \
)

struct foo { char* name; };

int main() {
  struct foo f = { "test" };
  bar(3);
  bar(f) = "something";
  puts(f.name); // prints "something"
}
0321
Björkus "No time_t to Die" Dorkus @thephd.dev · 25/04/2026
"Why not a sheep for the Obvious Reasons of what you are?" Mission already accomplished, soldier:
A screenshot of an editor open, where a file nam ed "art.txt" has an ASCII-art sheep that's 10 rows tall and 35 columns wide.
0254
Björkus "No time_t to Die" Dorkus @thephd.dev · 13/04/2026
C... Cinema...?
Some beautiful macros:

#define expand_if_necessary(ptr, size, idx, small_buf) if (idx == size) { char *new_ptr = XCNEWVEC(char, size * 2); memcpy(new_ptr, ptr, size * 2); if (ptr != small_buf) { free(ptr); } ptr = new_ptr; size *= 2; }
#define safe_push(ptr, size, idx, c, small_buf) { expand_if_necessary(ptr, size, idx, small_buf); ptr[idx] = c; ++idx;  }
#define safe_append(ptr, size, idx, cfirst, csize, small_buf) { for(unsigned int i = 0; i < csize; ++i) { safe_push(ptr, size, idx, cfirst[i], small_buf); } }
150
Björkus "No time_t to Die" Dorkus @thephd.dev · 06/04/2026
"This is going to destroy my build system" Nope! It's able to determine everything that will be processed by Phase 7 at Phase 4, and presents all of that information through already-available means, meaning CMake/build2/meson/make/ninja/etc. can all understand the dependency chain here natively!
A screenshot of of a "main.d" file, showing dependencies from a Lua file parsed at compile-time. The full file contents read:

main.exe: main.c++ zres\base.lua zres\main.lua
1220
Björkus "No time_t to Die" Dorkus @thephd.dev · 06/04/2026
A r e y o u r e a d y t o h a v e s o m e 『 f u n 』 ? :3
A screenshot of a piece of Lua code being processed at compile-time in C++. Notably, it's also able to pull in data from a "requires" clause...!

```cpp
int main() {
	constexpr auto original_file_span = std::embed<char>("zres/main.lua");
	constexpr auto original_file = comptime_make_array<original_file_span.size(), true>(original_file_span);
	constexpr big_buffer glob = recursive_parse("zres/main.lua");

	std::printf("original file (\"%s\"):\n\n%s", "zres/main.lua", original_file.data());
	std::printf("\n\n=================================================================================\n");
	std::printf("`consteval recursive_parse` result:\n\n%s", glob.data());

	return 0;
}
```

Output:
```sh
function main()
        return 1 + base.value;
end


=================================================================================
`consteval recursive_parse` result:

-- base.lua
base = {
        ["value"] = 30
}


function main()
        return 1 + base.value;
end
```
3679
Björkus "No time_t to Die" Dorkus @thephd.dev · 24/02/2026
Defer TS is now out with Clang 22.1.0. Read about the changes in Clang here: releases.llvm.org/22.1.0/tools... Just need to wait for an official cut of the GCC to have defer out and then I can consider the job done.
"...
Implemented the defer draft Technical Specification (WG14 N3734); it is enabled in C mode by passing -fdefer-ts. Note, the details of this feature are subject to change given that the Technical Specification is not yet ratified.
...."
1557
Björkus "No time_t to Die" Dorkus @thephd.dev · 28/12/2025
HEARTBREAKING: You Thought The Standard Was Wrong But It Is Actually Correct, And It Is Clang That Is Fucking You Up. I don't have the heart to make a bug report for something that's been in the standard text since C9x or whatever. I'll just avoid using the comma operator.
5402
Björkus "No time_t to Die" Dorkus @thephd.dev · 28/12/2025
Works on Windows, fails everywhere else. At least it's fixable with just slapping on more `;` instead of using the parenthesized comma expressions as a direct-replacement inside of the `return` expression like before. Utter designslop. I can't wait for this to be fixed in C2y.
A screenshot of a bug due to unspecified order of operations, where this code works on Windows but fails on non-Windows platforms:

int a            = (B_self_transport = x4, x4->B());
int b            = (B_self_transport = x5, x5->B());
return a + b;A screenshot of the code that's been fixed, using separate statements to guarantee ordering because the comma operator is the most braindead thing to exist ever:

B_self_transport = x4;
int a            = x4->B();
B_self_transport = x5;
int b            = x5->B();
return a + b;
2240
Björkus "No time_t to Die" Dorkus @thephd.dev · 24/12/2025
- Type-safe, checked branches - Evaluation of the input expression only once - No errors on unused branches Pick three.
Example C2y code showing how a proposed enhancement to _Generic works:

#include <stdio.h>

#define bar(x) _Generic(x, \
  int v: v, \
  struct foo v: v.name \
)

struct foo { char* name; };

int main() {
  struct foo f = { "test" };
  bar(3);
  bar(f) = "something";
  puts(f.name); // prints "something"
}
0120
Björkus "No time_t to Die" Dorkus @thephd.dev · 12/12/2025
Doing that can actually net you speedups that get you close to (but still not as good as) lambdas, and further tweaks to the Rosetta Code itself can make it perform slightly faster by not giving every `arg*`/`ARG*` a unique instance per run like the rosetta code does. The results then look like:
280
Björkus "No time_t to Die" Dorkus @thephd.dev · 10/12/2025
061
Björkus "No time_t to Die" Dorkus @thephd.dev · 02/12/2025
Not all closures in C and C++ were made equal, unfortunately.
6231
Björkus "No time_t to Die" Dorkus @thephd.dev · 30/11/2025
If the bug in this code is what I think it is, then WG14 owes me a lot of fucking money for my wasted time on `__self_func`.
A code snippet using Apple Blocks in C that reads:

	static int a(int k, fn_t ^ x1, fn_t ^ x2, fn_t ^ x3, fn_t ^ x4, fn_t ^ x5) {
		fn_t ^ b = ^(void) { return a(k - 1, b, x1, x2, x3, x4); };
		return k <= 0 ?
			x4() + x5()
			:
			b();
	}
3351
Björkus "No time_t to Die" Dorkus @thephd.dev · 17/10/2025
"Build syste-" YEAH NAH, NOT LISTENING ANYMORE, SKIP!!!!
An arrow points to a man with an expensive watch and a suit on, with a thick gem-encrusted ring and a diamond earring. He's listening to people's pitches, and the big caption over the top-right of the image is:

"I'M OUT!"
1.3 seconds

showing that he's leaving extremely early and not putting up with this.
110
Björkus "No time_t to Die" Dorkus @thephd.dev · 10/10/2025
It's haapppeenniiiing! Get in there and Thumb It Up, gogogogogogo: github.com/llvm/llvm-pr...
A screenshot of the landing page at: https://github.com/llvm/llvm-project/pull/162848
4332
Björkus "No time_t to Die" Dorkus @thephd.dev · 04/09/2025
Yeah. I also am having other problems with imported stuff I'm using for indexing, which is having... uh, struggles with some of this stuff. I might need to figure out a way to say "only do this paragraph stuff in this section", but I need to modify my template even more for it to help....
010
Björkus "No time_t to Die" Dorkus @thephd.dev · 04/09/2025
Yeah I think the way I set up my headings disqualifies them as "normal" headings, or rather inserts paragraphs into the heading so its making things worse:
140
Björkus "No time_t to Die" Dorkus @thephd.dev · 18/08/2025
You hear that Mr. Kernighan? ... That is the sound of inevitability... It is the sound of improvement... It's time, Mr. Kernighan....
A screenshot of a mail sent to the gcc-patches mailing list on August 2nd, 2025, with the subject:

[PATCH 0/4] implement defer statements as per ts 25755

https://gcc.gnu.org/pipermail/gcc-patches/2025-August/691461.html
2414
Björkus "No time_t to Die" Dorkus @thephd.dev · 09/08/2025
"Oh, that guy? Yeah, he'll help us fix it."
2220
Björkus "No time_t to Die" Dorkus @thephd.dev · 06/08/2025
IT'S GETTING STUCK IN MY BRAIN AAAAA
0220
Björkus "No time_t to Die" Dorkus @thephd.dev · 04/08/2025
The Rust Propaganda continues!
An anthropomorphic sheep is pressed against the window of a stranger's house, looking in as a crescent moon shines above. Their eyebrows are slanted down, half-moon glasses rest on the bridge of their noise and their mouth is curved up in a gleefully sadistic grin. Across their black shirt is emblazoned one word in all caps, detailing them for what they are:

"SICKOS".

They speak as they observe, enjoying every minute of what they're seeing inside the stranger's house: "Yes... Haha HA.... YES!"
1151
Björkus "No time_t to Die" Dorkus @thephd.dev · 28/07/2025
Alright. Progress has been made. I am now running an independent version of Bluesky. Now it's time to make a (fake) account and get into fixing the things I need to fix. Somehow.
A screenshot of the localhost on port 19006, which are the defaults for the Bluesky Webapp service.
1100
Björkus "No time_t to Die" Dorkus @thephd.dev · 17/07/2025
Not a bad spread of features, really.
A screenshot to the bottom of the design section of the paper, showing an HTML table with a comparison of "C Lambdas" against "Capture Functions".
0110
Björkus "No time_t to Die" Dorkus @thephd.dev · 11/07/2025
Alright. Finished the introduction / motivation section and have a clear path. Let's get to work.
A screenshot of a table showing various properties of different solutions for functions-with-data. The table and all of the prose can be found at: https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Functional%20Functions.html#intro.solutions
2170
Björkus "No time_t to Die" Dorkus @thephd.dev · 08/07/2025
Having to write this out just to really hammer it home "hey, stop F$*(#ing the ecosystem with vulnerabilities" is not something I really wanted to do but, here we are.
The text is too long to fit into the ALT text, but can be read verbatim here: https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Functional%20Functions.html#intro-nested.functions-security-popularity
080
Björkus "No time_t to Die" Dorkus @thephd.dev · 25/06/2025
INSHALLAH
A picture of the WINNER OF THE DEMOCRACTIC PRIMARY ZOHRAN MAMDANI with a photoshopped hand offering you a BLUNT BAYBEEEE.
1220
Björkus "No time_t to Die" Dorkus @thephd.dev · 23/06/2025
People get really mad when you accurately diagnose industry-wide problems, huh?
A two-part comic from SUNNY STREET that's been modified.

The first panel is labeled "KNOW THE WORK RULES: APPROPRIATE". A handsome man -- called "Library Vendors" -- in a suit is making a suave pointing gesture with one hand while the other is in his perfectly-ironed grey suit pants. With a smiling smirk, he says "Careful ! Realloc is Dangerous !" to a lady in a red-blouse over a collared white shirt. She responds "Aww, You're Sweet!" While a red heart floats up near her.

Later, A portly man -- called "WG14" -- wearing a sweater-vest with a white button-up, collared shirt, glasses, a brown belt and gold-beige pants stands in the same place as the "Library Vendors" man. He says "Careful ! Realloc is Dangerous !" and the same woman from before immediately grabs her phone and clutches her chest, saying "Hello, Human Resources ?!"
0280
Björkus "No time_t to Die" Dorkus @thephd.dev · 22/06/2025
A proper rebinding optional..... with room for variant<T&> too.... We're gonna be.... we're gonna be okay........
190
Björkus "No time_t to Die" Dorkus @thephd.dev · 20/06/2025
Fascinating. We made it a Recommended Practice to warn on this, with discussion during the meeting to do it at only on raw constants and not e.g. macros. But the actual landscape is... ... quite different, from what I was told / expected.
A screenshot of the following testing code:

extern int n;
extern void f(void);

#define LO 0
#define HI 50

#if HAVE_CONSTEXPR
constexpr int lo = 60;
constexpr int hi = 99;
#endif
#if HAVE_CONSTANTS
static const int lo_impl = 100;
static const int hi_impl = 241;
#endif

int main () {
	switch(n) {
#if HAVE_CONSTANTS
	case hi_impl...lo_impl-1: // Minneapolis 2024 recommendation: DO NOT diagnose!!
#endif
	case HI...LO-1: // Minneapolis 2024 recommendation: DO NOT diagnose!!
#if HAVE_CONSTEXPR
	case hi...lo-1: // Minneapolis 2024 recommendation: DO NOT diagnose!!
#endif
		f();
		break;
	}
#if 0
	switch(n) {
	case HI..<LO: // mistake: constraint violated!
	case hi..<lo: // mistake: constraint violated!
		f();
		break;
	}
#endif
	return 0;
}
2120
Björkus "No time_t to Die" Dorkus @thephd.dev · 18/06/2025
Interesting that GCC only considers this a constant under optimization, but does not when no optimizations. Pretty weird behavior! Clang is consistent all the way. Probably just another reason why this should be mandated to be a constant expression in the standard... godbolt.org/z/eq1jWPoen
A screenshot of the following code:

_Thread_local static const int x = 1;

int main () {
    _Thread_local static const int y = 1;
    static_assert(x == 1);
    static_assert(y == 1);
    return x + y;
}
0180
Björkus "No time_t to Die" Dorkus @thephd.dev · 30/05/2025
An anthropomorphic sheep is pressed against the window of a stranger's house, looking in as a crescent moon shines above. Their eyebrows are slanted down, half-moon glasses rest on the bridge of their noise and their mouth is curved up in a gleefully sadistic grin. Across their black shirt is emblazoned one word in all caps, detailing them for what they are:

"SICKOS".

They speak as they observe, enjoying every minute of what they're seeing inside the stranger's house: "Yes... Haha HA.... YES!"
0190
Björkus "No time_t to Die" Dorkus @thephd.dev · 12/05/2025
I really hate this is an example I have to write to illustrate the point for my upcoming standard work. Worst part is this was just sort of a quiet failure you couldn't check for, lmfao.
EXAMPLE    The following is correct for all implementations where a pointer to void and a pointer to any object type have representational equivalence on a hosted implementation:

#include <stdio.h>

int main () {
  static_assert(__STDC_PTR_COMPAT_OBJECT_AND_VOID__
    == __STDC_PTR_REPR_EQUIVALENT__,
    "Representational equivalence is required.");
  struct toto* p = nullptr;
  printf("%p\n", p);
  return 0;
}Otherwise, a cast to void* may be required to ensure well-defined behavior on a hosted implementation:

#include <stdio.h>

int main () {
  struct toto* p = nullptr;
  printf("%p\n", (void*)p); // cast first to perform appropriate conversion
  return 0;
}
3170
Björkus "No time_t to Die" Dorkus @thephd.dev · 12/04/2025
1130
Björkus "No time_t to Die" Dorkus @thephd.dev · 11/04/2025
Glorious orchestrations.
A screenshot of ztd.idk GitHub Actions showing a fraction of tests running and going green
2260
Björkus "No time_t to Die" Dorkus @thephd.dev · 07/04/2025
Took a bit, but YAY!
Everything is now green on the CI -- all four entries.
090
Björkus "No time_t to Die" Dorkus @thephd.dev · 27/03/2025
Job's Done. ztdthread.readthedocs.io/en/latest/
A screenshot of the landing page for https://ztdthread.readthedocs.io/en/latest/
2240
Björkus "No time_t to Die" Dorkus @thephd.dev · 25/03/2025
Tripled my documentation and paper writing workload for this, but added some important functionality. Now, you can check if a platform actually gave a damn and honored the thrd_attr_* that you passed in. It works out pretty nicely! github.com/soasis/threa... github.com/soasis/threa...
A screenshot of the full program available at: https://github.com/soasis/thread/blob/main/examples/source/handle_unknown_attribute.c#L47-L89
1180
Björkus "No time_t to Die" Dorkus @thephd.dev · 23/03/2025
Finally. All tests green, all things passing. Time to get this shit standardized now that I have a non-intrusive implementation that works across all major platforms.
2330
Björkus "No time_t to Die" Dorkus @thephd.dev · 20/03/2025
Job's done. Let's get this shit standardized so not one single person has to ever do this again in their life, what a waste of programmer time. (Now reposted with better quality.)
A screenshot of a program, showing the output:

thread id: 0
thread name: meow?!

thread id: 1
thread name: bark?!?!

It comes from the following program:

#include <ztd/idk/threads.h>
#include <ztd/idk/size.h>

#include <stdio.h>

extern "C" inline int thrd_main(void* arg) {
	int t_id           = *(int*)arg;
	char name_buf[128] = {};
	pthread_getname_np(thrd_current(), name_buf, sizeof(name_buf));
	const char* t_name = name_buf;
	printf("thread id: %d\n", t_id);
	printf("thread name: %s\n", t_name);
	printf("\n");
	thrd_exit(t_id);
}

int main() {
	thrd_t t0 = {};
	thrd_t t1 = {};

	ztdc_thrd_attr_name name_attr = { // format
		.kind = ztdc_thrd_attr_kind_name,
		.name = "meow?!"
	};
	ztdc_thrd_attr_stack_size stack_size_attr = {
		.kind = ztdc_thrd_attr_kind_stack_size,
		.size = 1'024,
	};
	struct ztdc_thrd_attr_priority {
		ztdc_thrd_attr_kind kind;
		int priority;
	} priority_attr = {
		// some custom attribute or whatever
		.kind     = ztdc_thrd_attr_kind_impl_def_priority,
		.priority = INT_MAX,
	};

	ztdc_thrd_attr_kind* attrs[] = {
		&priority_attr.kind,
		&stack_size_attr.kind,
		&name_attr.kind,
	};

	int t0_id = 0;
	ztdc_thrd_create_attrs(&t0, thrd_main, &t0_id, ztdc_c_array_size(attrs), attrs);
	name_attr.name = "bark?!?!";
	int t1_id      = 1;
	ztdc_thrd_create_attrs(&t1, thrd_main, &t1_id, ztdc_c_array_size(attrs), attrs);

	int res0 = 0;
	int res1 = 0;
	thrd_join(t0, &res0);
	thrd_join(t1, &res1);
	return res0 + res1;
}
1260
Björkus "No time_t to Die" Dorkus @thephd.dev · 19/03/2025
Forgot how much I hate POSIX and most other C APIs, in general. "Hey, if this thread is not joinable, it's EINVAL." Cool, thanks, I apprecia- "It's also EINVAL if another thread is waiting to join this one." .....
An anthropomorphic sheep with their hands held up near their face, fingers pointing up. Their head is leaned forward just a tiny bit, their eyebrows are up high, their eyes are open very wide even while their pupils are very constricted and beady just over their half-spectacles. They look very bothered, and are saying

"Listen Motherfucker,"
3571
Björkus "No time_t to Die" Dorkus @thephd.dev · 13/03/2025
@gankra.bsky.social ... 🤔
A picture of Björkus in Waluigi Cosplay, and Aria in Wario Cosplay. They definitely look like they have nefarious intentions, and could easily force-wario you....
1120
Björkus "No time_t to Die" Dorkus @thephd.dev · 27/02/2025
C meeting isn't even over yet and my brain is checked out.
212313