I implemented a version of SRWLOCK that looks a bit more like Windows'.
I tried my hardest to make this correct, but given how convoluted this is I am sure there are still problems left. So please help me scrutinize the code.
Honestly Windows' way of doing SRWLOCK is pretty cursed. They store waiters in a _doubly_ linked list, and each node also stores a pointer to the head of the list. The list has to support appending from one end and removing from the other. All these make implementing it with atomics a nightmare. My brain is properly fried right now.