On Fri Dec 22 19:55:29 2023 +0000, Alexandre Julliard wrote:
In practice trying to make that sort of code generic adds more complexity than it's worth. Especially as soon as there's some platform-specific quirk that you want to test.
What Julliard said. Your specific example already have *two* limitations:
1. It cannot handle variably-sized contexts (`CONTEXT_EX`). 2. It cannot handle 32-bit ARM: Windows uses Thumb mode, which requires you to sst the LSB of the function pointer to 1. (See `test_thread_context()` for ARM example).
Once you generalize to cover these, you can see the code get quickly complicated. :/
If you still want it deduplicated, consider introducing abstraction or factoring out architecture-agnostic logic into own function *without* #if(def)s. **However, take this advice with a caution: it can make tests less straightforward.**
Notice the disclaimer; in general, it's a good idea to avoid introducing abstraction until you have explored the full problem space :')