Finally implemented TLS in Ghost today. Thanks a lot again sortie.
I have a question though, you use this calculation for the alignment:
Code:
max(master_tls_alignment, alignof(struct uthread));
This confused me a little trying to figure out how to align the address of the location that contains the self-pointer (and therefore the location of the user-thread-struct) properly. What if the alignment of the TLS was 4, but the alignment of the user-thread struct was 8 - wouldn't the location that contains the self-pointer of the user-thread struct be set off by 4 bytes too much?
Also, I made this little visualization, is it correct & maybe helpful for the wiki?