| ▲ | uecker 3 hours ago | |||||||
This is a good example. Without trampolines, this could look like this (Godbolt: https://godbolt.org/z/nK5fqMxjs).
There are slightly different ways how to define the helper macros, I am still experimenting a bit. Here you could avoid the typedef if defined differently. But ideally, there would be native language support that avoids these macros. | ||||||||
| ▲ | listeria 2 hours ago | parent | next [-] | |||||||
Well, if you're already using qsort_r, what's the point of using nested functions, if you can have a context pointer with the target? And if you're not using qsort_r, but reaching for _Thread_local, the target can be _Thread_local instead of dsq. | ||||||||
| ||||||||
| ▲ | uecker 3 hours ago | parent | prev [-] | |||||||
Or without qsort_r, you could use a thread local variable:
https://godbolt.org/z/3e157c6b1 | ||||||||